@uicopilot/storybook-addon 0.5.7 → 0.5.9

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 CHANGED
@@ -1,47 +1,47 @@
1
- var yF=Object.create;var Pa=Object.defineProperty;var bF=Object.getOwnPropertyDescriptor;var SF=Object.getOwnPropertyNames;var wF=Object.getPrototypeOf,vF=Object.prototype.hasOwnProperty;var kF=(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})},CF=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of SF(t))!vF.call(e,o)&&o!==n&&Pa(e,o,{get:()=>t[o],enumerable:!(r=bF(t,o))||r.enumerable});return e};var La=(e,t,n)=>(n=e!=null?yF(wF(e)):{},CF(t||!e||!e.__esModule?Pa(n,"default",{value:e,enumerable:!0}):n,e));var Zn=(e,t,n)=>kF(e,typeof t!="symbol"?t+"":t,n);function Jx(){try{return typeof window<"u"&&localStorage.getItem(EF)==="true"}catch{return!1}}var EF,y,De=$(()=>{"use strict";EF="uicopilot:debug";y={debug:(...e)=>{Jx()&&console.log(...e)},info:(...e)=>{Jx()&&console.info(...e)},warn:(...e)=>console.warn(...e),error:(...e)=>console.error(...e)}});import AF,{createContext as PF,useContext as LF,useReducer as MF,useMemo as Zx}from"react";function BF(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]=MF(BF,NF),r=Zx(()=>({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=Zx(()=>({...t,...r}),[t,r]);return AF.createElement(ty.Provider,{value:o},e)}function Se(){let e=LF(ty);if(!e)throw new Error("useAuthStore must be used within an AuthProvider");return e}var DF,RF,zF,ey,NF,ty,ou=$(()=>{"use strict";De();DF=()=>{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"))};DF();RF=()=>typeof localStorage>"u"?null:localStorage.getItem("uicopilot_session_token"),zF=()=>typeof localStorage>"u"?"":localStorage.getItem("uicopilot_api_key")||"",ey=RF(),NF={isConnected:!!ey,sessionToken:ey,apiKey:zF(),authMethod:"oauth",deviceCode:null,userCode:null,verificationUri:null,pollingInterval:null,usageData:null,usageLastFetched:null,authError:null},ty=PF(null)});import OF,{createContext as _F,useContext as $F,useReducer as UF,useMemo as ny,useRef as jF,useEffect as HF}from"react";function WF(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]=UF(WF,GF),r=jF(t);HF(()=>{r.current=t},[t]);let o=ny(()=>({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=ny(()=>({...t,...o}),[t,o]);return OF.createElement(ry.Provider,{value:i},e)}function Ze(){let e=$F(ry);if(!e)throw new Error("useProjectStore must be used within a ProjectProvider");return e}var VF,GF,ry,su=$(()=>{"use strict";VF=()=>typeof localStorage>"u"?null:localStorage.getItem("uicopilot_selected_project_id"),GF={projects:[],selectedProjectId:VF(),loadingProjects:!1,currentStorybookPath:null},ry=_F(null)});import qF,{createContext as YF,useContext as KF,useReducer as XF,useMemo as oy}from"react";function QF(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>iy)for(let o of r.slice(0,r.length-iy))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]=XF(QF,JF),r=oy(()=>({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=oy(()=>({...t,...r}),[t,r]);return qF.createElement(sy.Provider,{value:o},e)}function rt(){let e=KF(sy);if(!e)throw new Error("useFigmaStore must be used within a FigmaProvider");return e}var iy,JF,sy,lu=$(()=>{"use strict";iy=200;JF={showComponentBrowser:!1,figmaFileUrl:"",currentStoryId:null,currentStoryName:"",currentMapping:null,mappingsRefreshKey:0,reviewFigmaUrl:"",mappingSource:null,loadingMapping:!1,showFigmaQuality:!1,framesCache:null,isLoadingFrames:!1,variantThumbnailsCache:{}},sy=YF(null)});var ay=$(()=>{"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 eE(e){return e>=97&&e<=122}function tE(e){return za(e)||eE(e)}function nE(e){return e>=128}function Ra(e){return tE(e)||nE(e)||e===95}function Na(e){return Ra(e)||_t(e)||e===45}function rE(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,oE,is,pu,$a,du,ss=$(()=>{"use strict";uu=new Array(128),oE=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||rE(e)&&du||e||oE});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 ly(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 py(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===cy||c===uy||c===iE)&&(c===uy&&u+1<n&&t.charCodeAt(u+1)===cy&&(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 cy,iE,uy,Ga,dy=$(()=>{"use strict";mu();ss();cy=10,iE=12,uy=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||py(this),{source:n,offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]}}getLocationRange(t,n,r){return this.computed||py(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 fy(e,t,n){return e<t?t:e>n?n:e}var gr,mr,cs,Ya,ao,hr,qa,gy=$(()=>{"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[fy(t,0,this.tokenCount)]&gr}getTokenType(t){return t===this.tokenIndex?this.tokenType:this.offsetAndType[fy(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();dy();gy()});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 xy({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(`
1
+ var PF=Object.create;var Na=Object.defineProperty;var LF=Object.getOwnPropertyDescriptor;var MF=Object.getOwnPropertyNames;var BF=Object.getPrototypeOf,DF=Object.prototype.hasOwnProperty;var RF=(e,t,n)=>t in e?Na(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var $=(e,t)=>()=>(e&&(t=e(e=0)),t);var er=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Se=(e,t)=>{for(var n in t)Na(e,n,{get:t[n],enumerable:!0})},zF=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of MF(t))!DF.call(e,o)&&o!==n&&Na(e,o,{get:()=>t[o],enumerable:!(r=LF(t,o))||r.enumerable});return e};var Oa=(e,t,n)=>(n=e!=null?PF(BF(e)):{},zF(t||!e||!e.__esModule?Na(n,"default",{value:e,enumerable:!0}):n,e));var tr=(e,t,n)=>RF(e,typeof t!="symbol"?t+"":t,n);function ay(){try{return typeof window<"u"&&localStorage.getItem($F)==="true"}catch{return!1}}var $F,y,Ne=$(()=>{"use strict";$F="uicopilot:debug";y={debug:(...e)=>{ay()&&console.log(...e)},info:(...e)=>{ay()&&console.info(...e)},warn:(...e)=>console.warn(...e),error:(...e)=>console.error(...e)}});import UF,{createContext as jF,useContext as HF,useReducer as WF,useMemo as ly}from"react";function VF(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 du({children:e}){let[t,n]=WF(VF,KF),r=ly(()=>({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=ly(()=>({...t,...r}),[t,r]);return UF.createElement(uy.Provider,{value:o},e)}function we(){let e=HF(uy);if(!e)throw new Error("useAuthStore must be used within an AuthProvider");return e}var GF,qF,YF,cy,KF,uy,gu=$(()=>{"use strict";Ne();GF=()=>{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"))};GF();qF=()=>typeof localStorage>"u"?null:localStorage.getItem("uicopilot_session_token"),YF=()=>typeof localStorage>"u"?"":localStorage.getItem("uicopilot_api_key")||"",cy=qF(),KF={isConnected:!!cy,sessionToken:cy,apiKey:YF(),authMethod:"oauth",deviceCode:null,userCode:null,verificationUri:null,pollingInterval:null,usageData:null,usageLastFetched:null,authError:null},uy=jF(null)});import XF,{createContext as QF,useContext as JF,useReducer as ZF,useMemo as py,useRef as eE,useEffect as tE}from"react";function nE(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 fu({children:e}){let[t,n]=ZF(nE,oE),r=eE(t);tE(()=>{r.current=t},[t]);let o=py(()=>({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=py(()=>({...t,...o}),[t,o]);return XF.createElement(dy.Provider,{value:i},e)}function Je(){let e=JF(dy);if(!e)throw new Error("useProjectStore must be used within a ProjectProvider");return e}var rE,oE,dy,mu=$(()=>{"use strict";rE=()=>typeof localStorage>"u"?null:localStorage.getItem("uicopilot_selected_project_id"),oE={projects:[],selectedProjectId:rE(),loadingProjects:!1,currentStorybookPath:null},dy=QF(null)});import iE,{createContext as sE,useContext as aE,useReducer as lE,useMemo as gy}from"react";function cE(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>fy)for(let o of r.slice(0,r.length-fy))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 hu({children:e}){let[t,n]=lE(cE,uE),r=gy(()=>({setShowComponentBrowser:i=>n({type:"SET_STATE",payload:{showComponentBrowser:i}}),setFigmaFileUrl:i=>n({type:"SET_STATE",payload:{figmaFileUrl:i}}),setCurrentStoryId:i=>n({type:"SET_STATE",payload:{currentStoryId:i}}),setCurrentStoryName:i=>n({type:"SET_STATE",payload:{currentStoryName:i}}),setCurrentMapping:i=>{n({type:"SET_STATE",payload:{currentMapping:i}})},setMappingsByStoryId:i=>n({type:"SET_STATE",payload:{mappingsByStoryId:i}}),refreshMappings:()=>n({type:"REFRESH_MAPPINGS"}),setReviewFigmaUrl:i=>n({type:"SET_STATE",payload:{reviewFigmaUrl:i}}),setMappingSource:i=>n({type:"SET_STATE",payload:{mappingSource:i}}),setLoadingMapping:i=>n({type:"SET_STATE",payload:{loadingMapping:i}}),setShowFigmaQuality:i=>n({type:"SET_STATE",payload:{showFigmaQuality:i}}),setFramesCache:i=>n({type:"SET_STATE",payload:{framesCache:i}}),setIsLoadingFrames:i=>n({type:"SET_STATE",payload:{isLoadingFrames:i}}),updateFramesThumbnails:i=>n({type:"UPDATE_FRAMES_THUMBNAILS",payload:i}),setVariantThumbnails:(i,s)=>n({type:"SET_VARIANT_THUMBNAILS",payload:{componentSetId:i,thumbnails:s}}),clearVariantThumbnailsForSet:i=>n({type:"CLEAR_VARIANT_THUMBNAILS_FOR_SET",payload:i}),clearAllVariantThumbnails:()=>n({type:"CLEAR_ALL_VARIANT_THUMBNAILS"})}),[]),o=gy(()=>({...t,...r}),[t,r]);return iE.createElement(my.Provider,{value:o},e)}function nt(){let e=aE(my);if(!e)throw new Error("useFigmaStore must be used within a FigmaProvider");return e}var fy,uE,my,xu=$(()=>{"use strict";fy=200;uE={showComponentBrowser:!1,figmaFileUrl:"",currentStoryId:null,currentStoryName:"",currentMapping:null,mappingsRefreshKey:0,mappingsByStoryId:{},reviewFigmaUrl:"",mappingSource:null,loadingMapping:!1,showFigmaQuality:!1,framesCache:null,isLoadingFrames:!1,variantThumbnailsCache:{}},my=sE(null)});var hy=$(()=>{"use strict"});var yu=$(()=>{"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 Ha(e){return e>=65&&e<=90}function dE(e){return e>=97&&e<=122}function gE(e){return Ha(e)||dE(e)}function fE(e){return e>=128}function ja(e){return gE(e)||fE(e)||e===95}function Wa(e){return ja(e)||$t(e)||e===45}function mE(e){return e>=0&&e<=8||e===11||e>=14&&e<=31||e===127}function ls(e){return e===10||e===13||e===12}function Dr(e){return ls(e)||e===32||e===9}function An(e,t){return!(e!==92||ls(t)||t===0)}function pi(e,t,n){return e===45?ja(t)||t===45||An(t,n):ja(e)?!0:e===92?An(e,t):!1}function Va(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 Ga(e){return e===65279||e===65534?1:0}function Ya(e){return e<128?bu[e]:qa}var bu,hE,cs,Su,qa,wu,us=$(()=>{"use strict";bu=new Array(128),hE=128,cs=130,Su=131,qa=132,wu=133;for(let e=0;e<bu.length;e++)bu[e]=Dr(e)&&cs||$t(e)&&Su||ja(e)&&qa||mE(e)&&wu||e||hE});function di(e,t){return t<e.length?e.charCodeAt(t):0}function Ka(e,t,n){return n===13&&di(e,t+1)===10?2:1}function Wr(e,t,n){let r=e.charCodeAt(t);return Ha(r)&&(r=r|32),r===n}function Vr(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(Ha(s)&&(s=s|32),s!==i)return!1}return!0}function xy(e,t){for(;t>=0&&Dr(e.charCodeAt(t));t--);return t+1}function ps(e,t){for(;t<e.length&&Dr(e.charCodeAt(t));t++);return t}function vu(e,t){for(;t<e.length&&$t(e.charCodeAt(t));t++);return t}function Gr(e,t){if(t+=2,Pn(di(e,t-1))){for(let r=Math.min(e.length,t+5);t<r&&Pn(di(e,t));t++);let n=di(e,t);Dr(n)&&(t+=Ka(e,t,n))}return t}function ds(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(!Wa(n)){if(An(n,di(e,t+1))){t=Gr(e,t)-1;continue}break}}return t}function Ho(e,t){let n=e.charCodeAt(t);if((n===43||n===45)&&(n=e.charCodeAt(t+=1)),$t(n)&&(t=vu(e,t+1),n=e.charCodeAt(t)),n===46&&$t(e.charCodeAt(t+1))&&(t+=2,t=vu(e,t)),Wr(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=vu(e,t+1+r+1))}return t}function Xa(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n===41){t++;break}An(n,di(e,t+1))&&(t=Gr(e,t))}return t}function Qa(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 Ja=$(()=>{"use strict";us()});var gi,ku=$(()=>{"use strict";gi=["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 fi(e=null,t){return e===null||e.length<t?new Uint32Array(Math.max(t+1024,16384)):e}var Cu=$(()=>{"use strict"});function Sy(e){let t=e.source,n=t.length,r=t.length>0?Ga(t.charCodeAt(0)):0,o=fi(e.lines,n),i=fi(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===yy||c===by||c===xE)&&(c===by&&u+1<n&&t.charCodeAt(u+1)===yy&&(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 yy,xE,by,Za,wy=$(()=>{"use strict";Cu();us();yy=10,xE=12,by=13;Za=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||Sy(this),{source:n,offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]}}getLocationRange(t,n,r){return this.computed||Sy(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 vy(e,t,n){return e<t?t:e>n?n:e}var hr,xr,gs,tl,xo,yr,el,ky=$(()=>{"use strict";Cu();Ja();ku();hr=16777215,xr=24,gs=1,tl=2,xo=new Uint8Array(32);xo[2]=22;xo[21]=22;xo[19]=20;xo[23]=24;yr=new Uint8Array(32);yr[2]=gs;yr[21]=gs;yr[19]=gs;yr[23]=gs;yr[22]=tl;yr[20]=tl;yr[24]=tl;el=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=fi(this.offsetAndType,t.length+1),i=fi(this.balance,t.length+1),s=0,a=-1,u=0,c=t.length;this.offsetAndType=null,this.balance=null,i.fill(0),n(t,(l,p,g)=>{let d=s++;if(o[d]=l<<xr|g,a===-1&&(a=p),i[d]=c,l===u){let m=i[c];i[c]=d,c=m,u=xo[o[m]>>xr]}else this.isBlockOpenerTokenType(l)&&(c=d,u=xo[l])}),o[s]=0<<xr|r,i[s]=s;for(let l=0;l<s;l++){let p=i[l];if(p<=l){let g=i[p];g!==l&&(i[l]=g)}else p>s&&(i[l]=s)}this.source=t,this.firstCharOffset=a===-1?0:a,this.tokenCount=s,this.offsetAndType=o,this.balance=i,this.reset(),this.next()}lookupType(t){return t+=this.tokenIndex,t<this.tokenCount?this.offsetAndType[t]>>xr:0}lookupTypeNonSC(t){for(let n=this.tokenIndex;n<this.tokenCount;n++){let r=this.offsetAndType[n]>>xr;if(r!==13&&r!==25&&t--===0)return r}return 0}lookupOffset(t){return t+=this.tokenIndex,t<this.tokenCount?this.offsetAndType[t-1]&hr:this.source.length}lookupOffsetNonSC(t){for(let n=this.tokenIndex;n<this.tokenCount;n++){let r=this.offsetAndType[n]>>xr;if(r!==13&&r!==25&&t--===0)return n-this.tokenIndex}return 0}lookupValue(t,n){return t+=this.tokenIndex,t<this.tokenCount?Vr(this.source,this.offsetAndType[t-1]&hr,this.offsetAndType[t]&hr,n):!1}getTokenStart(t){return t===this.tokenIndex?this.tokenStart:t>0?t<this.tokenCount?this.offsetAndType[t-1]&hr:this.offsetAndType[this.tokenCount]&hr:this.firstCharOffset}getTokenEnd(t){return t===this.tokenIndex?this.tokenEnd:this.offsetAndType[vy(t,0,this.tokenCount)]&hr}getTokenType(t){return t===this.tokenIndex?this.tokenType:this.offsetAndType[vy(t,0,this.tokenCount)]>>xr}substrToCursor(t){return this.source.substring(t,this.tokenStart)}isBlockOpenerTokenType(t){return yr[t]===gs}isBlockCloserTokenType(t){return yr[t]===tl}getBlockTokenPairIndex(t){let n=this.getTokenType(t);if(yr[n]===1){let r=this.balance[t],o=this.getTokenType(r);return xo[n]===o?r:-1}else if(yr[n]===2){let r=this.balance[t],o=this.getTokenType(r);return xo[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]&hr,n=this.offsetAndType[n],this.tokenType=n>>xr,this.tokenEnd=n&hr):(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>>xr,this.tokenEnd=t&hr):(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]&hr:this.firstCharOffset,n(this.source.charCodeAt(i))){case 1:break e;case 2:r++;break e;default:this.isBlockOpenerTokenType(this.offsetAndType[r]>>xr)&&(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&hr,a=i>>xr;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:gi[n],chunk:this.source.substring(r,o),balance:this.balance[i]}}),t}}});function yo(e,t){function n(p){return p<a?e.charCodeAt(p):0}function r(){if(c=Ho(e,c),pi(n(c),n(c+1),n(c+2))){l=12,c=ds(e,c);return}if(n(c)===37){l=11,c++;return}l=10}function o(){let p=c;if(c=ds(e,c),Vr(e,p,c,"url")&&n(c)===40){if(c=ps(e,c+1),n(c)===34||n(c)===39){l=2,c=p+4;return}s();return}if(n(c)===40){l=2,c++;return}l=1}function i(p){for(p||(p=n(c++)),l=5;c<e.length;c++){let g=e.charCodeAt(c);switch(Ya(g)){case p:c++;return;case cs:if(ls(g)){c+=Ka(e,c,g),l=6;return}break;case 92:if(c===e.length-1)break;let d=n(c+1);ls(d)?c+=Ka(e,c+1,d):An(g,d)&&(c=Gr(e,c)-1);break}}}function s(){for(l=7,c=ps(e,c);c<e.length;c++){let p=e.charCodeAt(c);switch(Ya(p)){case 41:c++;return;case cs:if(c=ps(e,c),n(c)===41||c>=e.length){c<e.length&&c++;return}c=Xa(e,c),l=8;return;case 34:case 39:case 40:case wu:c=Xa(e,c),l=8;return;case 92:if(An(p,n(c+1))){c=Gr(e,c)-1;break}c=Xa(e,c),l=8;return}}}e=String(e||"");let a=e.length,u=Ga(n(0)),c=u,l;for(;c<a;){let p=e.charCodeAt(c);switch(Ya(p)){case cs:l=13,c=ps(e,c+1);break;case 34:i();break;case 35:Wa(n(c+1))||An(n(c+1),n(c+2))?(l=4,c=ds(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:Va(p,n(c+1),n(c+2))?r():(l=9,c++);break;case 44:l=18,c++;break;case 45:Va(p,n(c+1),n(c+2))?r():n(c+1)===45&&n(c+2)===62?(l=15,c=c+3):pi(p,n(c+1),n(c+2))?o():(l=9,c++);break;case 46:Va(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:pi(n(c+1),n(c+2),n(c+3))?(l=3,c=ds(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 Su:r();break;case qa:o();break;default:l=9,c++}t(l,u,u=c)}}var rr=$(()=>{"use strict";us();Ja();yu();yu();ku();us();Ja();wy();ky()});var mi,qn,ms=$(()=>{"use strict";mi=null,qn=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 mi!==null?(r=mi,mi=mi.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=mi,mi=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 Vo(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 rl=$(()=>{"use strict"});function Iy({source:e,line:t,column:n,baseLine:r,baseColumn:o},i){function s(m,C){return c.slice(m,C).map((T,E)=>String(m+E+1).padStart(g)+" |"+T).join(`
3
3
  `)}let a=`
4
- `.repeat(Math.max(r-1,0)),u=" ".repeat(Math.max(o-1,0)),c=(a+u+e).split(/\r\n?|\n|\f/),l=Math.max(1,t-i)-1,p=Math.min(t+i,c.length+1),f=Math.max(4,String(p).length)+1,d=0;n+=(hy.length-1)*(c[t-1].substr(0,n-1).match(/\t/g)||[]).length,n>hu&&(d=n-my+3,n=my-2);for(let m=l;m<=p;m++)m>=0&&m<c.length&&(c[m]=c[m].replace(/\t/g,hy),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
- `).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 xy({source:t,line:r,column:o,baseLine:i,baseColumn:s},isNaN(u)?0:u)},get formattedMessage(){return`Parse error: ${e}
6
- `+xy({source:t,line:r,column:o,baseLine:i,baseColumn:s},2)}})}var hu,my,hy,yy=$(()=>{"use strict";Xa();hu=100,my=60,hy=" "});function by(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 Sy=$(()=>{"use strict"});function uE(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 pE(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]=uE(r);break}return{config:t,...t,...t.node}}function ky(e){let t="",n="<unknown>",r=!1,o=ci,i=!1,s=new Ga,a=Object.assign(new qa,pE(e||{}),{parseAtrulePrelude:!0,parseRulePrelude:!0,parseValue:!0,parseCustomProperty:!1,readSequence:by,consumeUntilBalanceEnd:()=>0,consumeUntilLeftCurlyBracket(l){return l===wy?1:0},consumeUntilLeftCurlyBracketOrSemicolon(l){return l===wy||l===yu?1:0},consumeUntilExclamationMarkOrSemicolon(l){return l===sE||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!==vy);return vy},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(aE)&&(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(ly(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?cE:lE),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,sE,aE,yu,wy,vy,lE,cE,Cy=$(()=>{"use strict";ps();yy();nr();Sy();ci=()=>{},sE=33,aE=35,yu=59,wy=123,vy=0,lE={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}},cE={createList(){return new Vn},createSingleNodeList(e){return new Vn().appendData(e)},getFirstListNode(e){return e&&e.first},getLastListNode(e){return e&&e.last}}});var Iy=Jn(Su=>{"use strict";var Ty="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");Su.encode=function(e){if(0<=e&&e<Ty.length)return Ty[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 Ly=Jn(vu=>{"use strict";var Fy=Iy(),wu=5,Ey=1<<wu,Ay=Ey-1,Py=Ey;function dE(e){return e<0?(-e<<1)+1:(e<<1)+0}function fE(e){var t=(e&1)===1,n=e>>1;return t?-n:n}vu.encode=function(t){var n="",r,o=dE(t);do r=o&Ay,o>>>=wu,o>0&&(r|=Py),n+=Fy.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=Fy.decode(t.charCodeAt(n++)),u===-1)throw new Error("Invalid base64 digit: "+t.charAt(n-1));a=!!(u&Py),u&=Ay,i=i+(u<<s),s+=wu}while(a);r.value=fE(i),r.rest=n}});var Qa=Jn(nn=>{"use strict";function gE(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=gE;var My=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,mE=/^data:.+\,.+$/;function ds(e){var t=e.match(My);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 hE=32;function xE(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>hE&&t.pop(),i}}var ku=xE(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 By(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(mE))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=By;nn.isAbsolute=function(e){return e.charAt(0)==="/"||My.test(e)};function yE(e,t){e===""&&(e="."),e=e.replace(/\/$/,"");for(var n=0;t.indexOf(e+"/")!==0;){var r=e.lastIndexOf("/");if(r<0||(e=e.slice(0,r),e.match(/^([^\/]+:\/)?\/*$/)))return t;++n}return Array(n+1).join("../")+t.substr(e.length+1)}nn.relative=yE;var Dy=(function(){var e=Object.create(null);return!("__proto__"in e)})();function Ry(e){return e}function bE(e){return zy(e)?"$"+e:e}nn.toSetString=Dy?Ry:bE;function SE(e){return zy(e)?e.slice(1):e}nn.fromSetString=Dy?Ry:SE;function zy(e){if(!e)return!1;var t=e.length;if(t<9||e.charCodeAt(t-1)!==95||e.charCodeAt(t-2)!==95||e.charCodeAt(t-3)!==111||e.charCodeAt(t-4)!==116||e.charCodeAt(t-5)!==111||e.charCodeAt(t-6)!==114||e.charCodeAt(t-7)!==112||e.charCodeAt(t-8)!==95||e.charCodeAt(t-9)!==95)return!1;for(var n=t-10;n>=0;n--)if(e.charCodeAt(n)!==36)return!1;return!0}function wE(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=wE;function vE(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=vE;function kE(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=kE;function CE(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=CE;function jr(e,t){return e===t?0:e===null?1:t===null?-1:e>t?1:-1}function TE(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=TE;function IE(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))}nn.parseSourceMapInput=IE;function FE(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=By(ui(r),t)}return ku(t)}nn.computeSourceURL=FE});var Oy=Jn(Ny=>{"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()};Ny.ArraySet=Hr});var Uy=Jn($y=>{"use strict";var _y=Qa();function EE(e,t){var n=e.generatedLine,r=t.generatedLine,o=e.generatedColumn,i=t.generatedColumn;return r>n||r==n&&i>=o||_y.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){EE(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(_y.compareByGeneratedPositionsInflated),this._sorted=!0),this._array};$y.MappingList=Ja});var Hy=Jn(jy=>{"use strict";var fs=Ly(),$t=Qa(),Za=Oy().ArraySet,AE=Uy().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 AE,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())};jy.SourceMapGenerator=rr});function Gy(e){let t=new Vy.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&&Wy.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&&Wy.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 Vy,Wy,qy=$(()=>{"use strict";Vy=La(Hy(),1),Wy=new Set(["Atrule","Selector","Declaration"])});var el={};xe(el,{safe:()=>Fu,spec:()=>BE});function Ky(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===LE&&r!==1&&r!==2&&r!==15||s===PE?t.has((n&65534)<<16|s<<7):t.has((n&65534)<<16|i);return i|a}}var PE,LE,Iu,Yy,ME,BE,Fu,Xy=$(()=>{"use strict";PE=43,LE=45,Iu=(e,t)=>(e===9&&(e=t),typeof e=="string"&&(e=Math.min(e.charCodeAt(0),128)<<6),e<<1),Yy=[[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],["/","*"]],ME=Yy.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,"-"]]);BE=Ky(Yy),Fu=Ky(ME)});function RE(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 Qy(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)===DE&&this.emit(`
7
- `,13,!0)},emit(u){o+=u},result(){return o}};r&&(typeof r.decorator=="function"&&(s=r.decorator(s)),r.sourceMap&&(s=Gy(s)),r.mode in el&&(s.tokenBefore=el[r.mode]));let a={node:u=>s.node(u),children:RE,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 DE,Jy=$(()=>{"use strict";nr();qy();Xy();DE=92});function Zy(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 eb=$(()=>{"use strict";ps()});function tb(e){return typeof e=="function"?e:gs}function nb(e,t){return function(n,r,o){n.type===t&&e.call(this,n,r,o)}}function zE(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 NE(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]=zE(n,r)}return t}function rb(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 ob({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 ib(e){let t=NE(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]=rb(t[c],!1),r[c]=rb(t[c],!0));let s=ob(n),a=ob(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=tb(l.enter),d=tb(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=nb(f,l.visit),d=nb(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,sb=$(()=>{"use strict";({hasOwnProperty:Eu}=Object.prototype),gs=function(){}});function OE(e){return e}function _E(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 UE(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=UE(e,t,n,r)+(e.disallowEmpty?"!":"");break;case"Multiplier":return tl(e.term,t,n,r)+t(_E(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=OE,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 jE(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(ab,c),p=ms(l)):(l=nl(i,"start")||ms(nl(t,"start")||ab,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 ab,di,lb,cb=$(()=>{"use strict";Xa();Au();ab={offset:0,line:1,column:1};di=function(e,t){let n=zo("SyntaxReferenceError",e+(t?" `"+t+"`":""));return n.reference=t,n},lb=function(e,t,n,r){let o=zo("SyntaxMatchError",e),{css:i,mismatchOffset:s,mismatchLength:a,start:u,end:c}=jE(r,n);return o.rawMessage=e,o.syntax=t?pi(t):"<generic>",o.css=i,o.mismatchOffset=s,o.mismatchLength=a,o.message=e+`
4
+ `.repeat(Math.max(r-1,0)),u=" ".repeat(Math.max(o-1,0)),c=(a+u+e).split(/\r\n?|\n|\f/),l=Math.max(1,t-i)-1,p=Math.min(t+i,c.length+1),g=Math.max(4,String(p).length)+1,d=0;n+=(Ty.length-1)*(c[t-1].substr(0,n-1).match(/\t/g)||[]).length,n>Tu&&(d=n-Cy+3,n=Cy-2);for(let m=l;m<=p;m++)m>=0&&m<c.length&&(c[m]=c[m].replace(/\t/g,Ty),c[m]=(d>0&&c[m].length>d?"\u2026":"")+c[m].substr(d,Tu-2)+(c[m].length>d+Tu-1?"\u2026":""));return[s(l,t),new Array(n+g+2).join("-")+"^",s(t,p)].filter(Boolean).join(`
5
+ `).replace(/^(\s+\d+\s+\|\n)+/,"").replace(/\n(\s+\d+\s+\|)+$/,"")}function Iu(e,t,n,r,o,i=1,s=1){return Object.assign(Vo("SyntaxError",e),{source:t,offset:n,line:r,column:o,sourceFragment(u){return Iy({source:t,line:r,column:o,baseLine:i,baseColumn:s},isNaN(u)?0:u)},get formattedMessage(){return`Parse error: ${e}
6
+ `+Iy({source:t,line:r,column:o,baseLine:i,baseColumn:s},2)}})}var Tu,Cy,Ty,Fy=$(()=>{"use strict";rl();Tu=100,Cy=60,Ty=" "});function Ey(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 Ay=$(()=>{"use strict"});function vE(e){return function(){return this[e]()}}function Eu(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 kE(e){let t={context:Object.create(null),features:Object.assign(Object.create(null),e.features),scope:Object.assign(Object.create(null),e.scope),atrule:Eu(e.atrule),pseudo:Eu(e.pseudo),node:Eu(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]=vE(r);break}return{config:t,...t,...t.node}}function My(e){let t="",n="<unknown>",r=!1,o=hi,i=!1,s=new Za,a=Object.assign(new el,kE(e||{}),{parseAtrulePrelude:!0,parseRulePrelude:!0,parseValue:!0,parseCustomProperty:!1,readSequence:Ey,consumeUntilBalanceEnd:()=>0,consumeUntilLeftCurlyBracket(l){return l===Py?1:0},consumeUntilLeftCurlyBracketOrSemicolon(l){return l===Py||l===Fu?1:0},consumeUntilExclamationMarkOrSemicolon(l){return l===yE||l===Fu?1:0},consumeUntilSemicolonIncluded(l){return l===Fu?2:0},createList:hi,createSingleNodeList:hi,getFirstListNode:hi,getLastListNode:hi,parseWithFallback(l,p){let g=this.tokenIndex;try{return l.call(this)}catch(d){if(i)throw d;this.skip(g-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!==Ly);return Ly},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 Wr(t,l,p)},cmpStr(l,p,g){return Vr(t,l,p,g)},consume(l){let p=this.tokenStart;return this.eat(l),this.substrToCursor(p)},consumeFunctionName(){let l=t.substring(this.tokenStart,this.tokenEnd-1);return this.eat(2),l},consumeNumber(l){let p=t.substring(this.tokenStart,Ho(t,this.tokenStart));return this.eat(l),p},eat(l){if(this.tokenType!==l){let p=gi[l].slice(0,-6).replace(/-/g," ").replace(/^./,m=>m.toUpperCase()),g=`${/[[\](){}]/.test(p)?`"${p}"`:p} is expected`,d=this.tokenStart;switch(l){case 1:this.tokenType===2||this.tokenType===7?(d=this.tokenEnd-1,g="Identifier is expected but function found"):g="Identifier is expected";break;case 4:this.isDelim(bE)&&(this.next(),d++,g="Name is expected");break;case 11:this.tokenType===10&&(d=this.tokenEnd,g="Percent sign is expected");break}this.error(g,d)}this.next()},eatIdent(l){(this.tokenType!==1||this.lookupValue(0,l)===!1)&&this.error(`Identifier "${l}" is expected`),this.next()},eatDelim(l){this.isDelim(l)||this.error(`Delim "${String.fromCharCode(l)}" is expected`),this.next()},getLocation(l,p){return r?s.getLocationRange(l,p,n):null},getLocationFromList(l){if(r){let p=this.getFirstListNode(l),g=this.getLastListNode(l);return s.getLocationRange(p!==null?p.loc.start.offset-s.startOffset:this.tokenStart,g!==null?g.loc.end.offset-s.startOffset:this.tokenStart,n)}return null},error(l,p){let g=typeof p<"u"&&p<t.length?s.getLocation(p):this.eof?s.getLocation(xy(t,t.length-1)):s.getLocation(this.tokenStart);throw new Iu(l||"Unexpected input",t,g.offset,g.line,g.column,s.startLine,s.startColumn)}}),u=()=>({filename:n,source:t,tokenCount:a.tokenCount,getTokenType:l=>a.getTokenType(l),getTokenTypeName:l=>gi[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,yo),s.setSource(t,p.offset,p.line,p.column),n=p.filename||"<unknown>",r=!!p.positions,o=typeof p.onParseError=="function"?p.onParseError:hi,i=!1,a.parseAtrulePrelude="parseAtrulePrelude"in p?!!p.parseAtrulePrelude:!0,a.parseRulePrelude="parseRulePrelude"in p?!!p.parseRulePrelude:!0,a.parseValue="parseValue"in p?!!p.parseValue:!0,a.parseCustomProperty="parseCustomProperty"in p?!!p.parseCustomProperty:!1;let{context:g="default",list:d=!0,onComment:m,onToken:C}=p;if(!(g in a.context))throw new Error("Unknown context `"+g+"`");Object.assign(a,d?wE:SE),Array.isArray(C)?a.forEachToken((E,I,D)=>{C.push({type:E,start:I,end:D})}):typeof C=="function"&&a.forEachToken(C.bind(u())),typeof m=="function"&&a.forEachToken((E,I,D)=>{if(E===25){let R=a.getLocation(I,D),_=Vr(t,D-2,D,"*/")?t.slice(I+2,D-2):t.slice(I+2,D);m(_,R)}});let T=a.context[g].call(a,p);return a.eof||a.error(),T},{SyntaxError:Iu,config:a.config})}var hi,yE,bE,Fu,Py,Ly,SE,wE,By=$(()=>{"use strict";ms();Fy();rr();Ay();hi=()=>{},yE=33,bE=35,Fu=59,Py=123,Ly=0,SE={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}},wE={createList(){return new qn},createSingleNodeList(e){return new qn().appendData(e)},getFirstListNode(e){return e&&e.first},getLastListNode(e){return e&&e.last}}});var Ry=er(Au=>{"use strict";var Dy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");Au.encode=function(e){if(0<=e&&e<Dy.length)return Dy[e];throw new TypeError("Must be between 0 and 63: "+e)};Au.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 $y=er(Lu=>{"use strict";var zy=Ry(),Pu=5,Ny=1<<Pu,Oy=Ny-1,_y=Ny;function CE(e){return e<0?(-e<<1)+1:(e<<1)+0}function TE(e){var t=(e&1)===1,n=e>>1;return t?-n:n}Lu.encode=function(t){var n="",r,o=CE(t);do r=o&Oy,o>>>=Pu,o>0&&(r|=_y),n+=zy.encode(r);while(o>0);return n};Lu.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=zy.decode(t.charCodeAt(n++)),u===-1)throw new Error("Invalid base64 digit: "+t.charAt(n-1));a=!!(u&_y),u&=Oy,i=i+(u<<s),s+=Pu}while(a);r.value=TE(i),r.rest=n}});var ol=er(on=>{"use strict";function IE(e,t,n){if(t in e)return e[t];if(arguments.length===3)return n;throw new Error('"'+t+'" is a required argument.')}on.getArg=IE;var Uy=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,FE=/^data:.+\,.+$/;function hs(e){var t=e.match(Uy);return t?{scheme:t[1],auth:t[2],host:t[3],port:t[4],path:t[5]}:null}on.urlParse=hs;function xi(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}on.urlGenerate=xi;var EE=32;function AE(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>EE&&t.pop(),i}}var Mu=AE(function(t){var n=t,r=hs(t);if(r){if(!r.path)return t;n=r.path}for(var o=on.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,xi(r)):n});on.normalize=Mu;function jy(e,t){e===""&&(e="."),t===""&&(t=".");var n=hs(t),r=hs(e);if(r&&(e=r.path||"/"),n&&!n.scheme)return r&&(n.scheme=r.scheme),xi(n);if(n||t.match(FE))return t;if(r&&!r.host&&!r.path)return r.host=t,xi(r);var o=t.charAt(0)==="/"?t:Mu(e.replace(/\/+$/,"")+"/"+t);return r?(r.path=o,xi(r)):o}on.join=jy;on.isAbsolute=function(e){return e.charAt(0)==="/"||Uy.test(e)};function PE(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)}on.relative=PE;var Hy=(function(){var e=Object.create(null);return!("__proto__"in e)})();function Wy(e){return e}function LE(e){return Vy(e)?"$"+e:e}on.toSetString=Hy?Wy:LE;function ME(e){return Vy(e)?e.slice(1):e}on.fromSetString=Hy?Wy:ME;function Vy(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 BE(e,t,n){var r=qr(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:qr(e.name,t.name)}on.compareByOriginalPositions=BE;function DE(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:qr(e.name,t.name)}on.compareByOriginalPositionsNoSource=DE;function RE(e,t,n){var r=e.generatedLine-t.generatedLine;return r!==0||(r=e.generatedColumn-t.generatedColumn,r!==0||n)||(r=qr(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:qr(e.name,t.name)}on.compareByGeneratedPositionsDeflated=RE;function zE(e,t,n){var r=e.generatedColumn-t.generatedColumn;return r!==0||n||(r=qr(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:qr(e.name,t.name)}on.compareByGeneratedPositionsDeflatedNoLine=zE;function qr(e,t){return e===t?0:e===null?1:t===null?-1:e>t?1:-1}function NE(e,t){var n=e.generatedLine-t.generatedLine;return n!==0||(n=e.generatedColumn-t.generatedColumn,n!==0)||(n=qr(e.source,t.source),n!==0)||(n=e.originalLine-t.originalLine,n!==0)||(n=e.originalColumn-t.originalColumn,n!==0)?n:qr(e.name,t.name)}on.compareByGeneratedPositionsInflated=NE;function OE(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))}on.parseSourceMapInput=OE;function _E(e,t,n){if(t=t||"",e&&(e[e.length-1]!=="/"&&t[0]!=="/"&&(e+="/"),t=e+t),n){var r=hs(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=jy(xi(r),t)}return Mu(t)}on.computeSourceURL=_E});var qy=er(Gy=>{"use strict";var Bu=ol(),Du=Object.prototype.hasOwnProperty,Go=typeof Map<"u";function Yr(){this._array=[],this._set=Go?new Map:Object.create(null)}Yr.fromArray=function(t,n){for(var r=new Yr,o=0,i=t.length;o<i;o++)r.add(t[o],n);return r};Yr.prototype.size=function(){return Go?this._set.size:Object.getOwnPropertyNames(this._set).length};Yr.prototype.add=function(t,n){var r=Go?t:Bu.toSetString(t),o=Go?this.has(t):Du.call(this._set,r),i=this._array.length;(!o||n)&&this._array.push(t),o||(Go?this._set.set(t,i):this._set[r]=i)};Yr.prototype.has=function(t){if(Go)return this._set.has(t);var n=Bu.toSetString(t);return Du.call(this._set,n)};Yr.prototype.indexOf=function(t){if(Go){var n=this._set.get(t);if(n>=0)return n}else{var r=Bu.toSetString(t);if(Du.call(this._set,r))return this._set[r]}throw new Error('"'+t+'" is not in the set.')};Yr.prototype.at=function(t){if(t>=0&&t<this._array.length)return this._array[t];throw new Error("No element indexed by "+t)};Yr.prototype.toArray=function(){return this._array.slice()};Gy.ArraySet=Yr});var Xy=er(Ky=>{"use strict";var Yy=ol();function $E(e,t){var n=e.generatedLine,r=t.generatedLine,o=e.generatedColumn,i=t.generatedColumn;return r>n||r==n&&i>=o||Yy.compareByGeneratedPositionsInflated(e,t)<=0}function il(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}il.prototype.unsortedForEach=function(t,n){this._array.forEach(t,n)};il.prototype.add=function(t){$E(this._last,t)?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t))};il.prototype.toArray=function(){return this._sorted||(this._array.sort(Yy.compareByGeneratedPositionsInflated),this._sorted=!0),this._array};Ky.MappingList=il});var Jy=er(Qy=>{"use strict";var xs=$y(),Ut=ol(),sl=qy().ArraySet,UE=Xy().MappingList;function or(e){e||(e={}),this._file=Ut.getArg(e,"file",null),this._sourceRoot=Ut.getArg(e,"sourceRoot",null),this._skipValidation=Ut.getArg(e,"skipValidation",!1),this._ignoreInvalidMapping=Ut.getArg(e,"ignoreInvalidMapping",!1),this._sources=new sl,this._names=new sl,this._mappings=new UE,this._sourcesContents=null}or.prototype._version=3;or.fromSourceMap=function(t,n){var r=t.sourceRoot,o=new or(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=Ut.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=Ut.relative(r,i)),o._sources.has(s)||o._sources.add(s);var a=t.sourceContentFor(i);a!=null&&o.setSourceContent(i,a)}),o};or.prototype.addMapping=function(t){var n=Ut.getArg(t,"generated"),r=Ut.getArg(t,"original",null),o=Ut.getArg(t,"source",null),i=Ut.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}))};or.prototype.setSourceContent=function(t,n){var r=t;this._sourceRoot!=null&&(r=Ut.relative(this._sourceRoot,r)),n!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[Ut.toSetString(r)]=n):this._sourcesContents&&(delete this._sourcesContents[Ut.toSetString(r)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))};or.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=Ut.relative(i,o));var s=new sl,a=new sl;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=Ut.join(r,u.source)),i!=null&&(u.source=Ut.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=Ut.join(r,u)),i!=null&&(u=Ut.relative(i,u)),this.setSourceContent(u,c))},this)};or.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)}};or.prototype._serializeMappings=function(){for(var t=0,n=1,r=0,o=0,i=0,s=0,a="",u,c,l,p,g=this._mappings.toArray(),d=0,m=g.length;d<m;d++){if(c=g[d],u="",c.generatedLine!==n)for(t=0;c.generatedLine!==n;)u+=";",n++;else if(d>0){if(!Ut.compareByGeneratedPositionsInflated(c,g[d-1]))continue;u+=","}u+=xs.encode(c.generatedColumn-t),t=c.generatedColumn,c.source!=null&&(p=this._sources.indexOf(c.source),u+=xs.encode(p-s),s=p,u+=xs.encode(c.originalLine-1-o),o=c.originalLine-1,u+=xs.encode(c.originalColumn-r),r=c.originalColumn,c.name!=null&&(l=this._names.indexOf(c.name),u+=xs.encode(l-i),i=l)),a+=u}return a};or.prototype._generateSourcesContent=function(t,n){return t.map(function(r){if(!this._sourcesContents)return null;n!=null&&(r=Ut.relative(n,r));var o=Ut.toSetString(r);return Object.prototype.hasOwnProperty.call(this._sourcesContents,o)?this._sourcesContents[o]:null},this)};or.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};or.prototype.toString=function(){return JSON.stringify(this.toJSON())};Qy.SourceMapGenerator=or});function tb(e){let t=new eb.SourceMapGenerator,n={line:1,column:0},r={line:0,column:0},o={line:1,column:0},i={generated:o},s=1,a=0,u=!1,c=e.node;e.node=function(g){if(g.loc&&g.loc.start&&Zy.has(g.type)){let d=g.loc.start.line,m=g.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:g.loc.source,original:r,generated:n}))}c.call(this,g),u&&Zy.has(g.type)&&(o.line=s,o.column=a)};let l=e.emit;e.emit=function(g,d,m){for(let C=0;C<g.length;C++)g.charCodeAt(C)===10?(s++,a=0):a++;l(g,d,m)};let p=e.result;return e.result=function(){return u&&t.addMapping(i),{css:p(),map:t}},e}var eb,Zy,nb=$(()=>{"use strict";eb=Oa(Jy(),1),Zy=new Set(["Atrule","Selector","Declaration"])});var al={};Se(al,{safe:()=>zu,spec:()=>VE});function ob(e){let t=new Set(e.map(([n,r])=>Ru(n)<<16|Ru(r)));return function(n,r,o){let i=Ru(r,o),s=o.charCodeAt(0),a=s===HE&&r!==1&&r!==2&&r!==15||s===jE?t.has((n&65534)<<16|s<<7):t.has((n&65534)<<16|i);return i|a}}var jE,HE,Ru,rb,WE,VE,zu,ib=$(()=>{"use strict";jE=43,HE=45,Ru=(e,t)=>(e===9&&(e=t),typeof e=="string"&&(e=Math.min(e.charCodeAt(0),128)<<6),e<<1),rb=[[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],["/","*"]],WE=rb.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,"-"]]);VE=ob(rb),zu=ob(WE)});function qE(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 sb(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:zu,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)===GE&&this.emit(`
7
+ `,13,!0)},emit(u){o+=u},result(){return o}};r&&(typeof r.decorator=="function"&&(s=r.decorator(s)),r.sourceMap&&(s=tb(s)),r.mode in al&&(s.tokenBefore=al[r.mode]));let a={node:u=>s.node(u),children:qE,token:(u,c)=>s.token(u,c),tokenize:u=>yo(u,(c,l,p)=>{s.token(c,u.slice(l,p),l!==0)})};return s.node(n),s.result()}}var GE,ab=$(()=>{"use strict";rr();nb();ib();GE=92});function lb(e){return{fromPlainObject(t){return e(t,{enter(n){n.children&&!(n.children instanceof qn)&&(n.children=new qn().fromArray(n.children))}}),t},toPlainObject(t){return e(t,{leave(n){n.children&&n.children instanceof qn&&(n.children=n.children.toArray())}}),t}}}var cb=$(()=>{"use strict";ms()});function ub(e){return typeof e=="function"?e:ys}function pb(e,t){return function(n,r,o){n.type===t&&e.call(this,n,r,o)}}function YE(e,t){let n=t.structure,r=[];for(let o in n){if(Nu.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 KE(e){let t={};for(let n in e.node)if(Nu.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]=YE(n,r)}return t}function db(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 gb({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 fb(e){let t=KE(e),n={},r={},o=Symbol("break-walk"),i=Symbol("skip-node");for(let c in t)Nu.call(t,c)&&t[c]!==null&&(n[c]=db(t[c],!1),r[c]=db(t[c],!0));let s=gb(n),a=gb(r),u=function(c,l){function p(E,I,D){let R=g.call(T,E,I,D);return R===o?!0:R===i?!1:!!(m.hasOwnProperty(E.type)&&m[E.type](E,T,p,C)||d.call(T,E,I,D)===o)}let g=ys,d=ys,m=n,C=(E,I,D,R)=>E||p(I,D,R),T={break:o,skip:i,root:c,stylesheet:null,atrule:null,atrulePrelude:null,rule:null,selector:null,block:null,declaration:null,function:null};if(typeof l=="function")g=l;else if(l&&(g=ub(l.enter),d=ub(l.leave),l.reverse&&(m=r),l.visit)){if(s.hasOwnProperty(l.visit))m=l.reverse?a[l.visit]:s[l.visit];else if(!t.hasOwnProperty(l.visit))throw new Error("Bad value `"+l.visit+"` for `visit` option (should be: "+Object.keys(t).sort().join(", ")+")");g=pb(g,l.visit),d=pb(d,l.visit)}if(g===ys&&d===ys)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");p(c)};return u.break=o,u.skip=i,u.find=function(c,l){let p=null;return u(c,function(g,d,m){if(l.call(this,g,d,m))return p=g,o}),p},u.findLast=function(c,l){let p=null;return u(c,{reverse:!0,enter(g,d,m){if(l.call(this,g,d,m))return p=g,o}}),p},u.findAll=function(c,l){let p=[];return u(c,function(g,d,m){l.call(this,g,d,m)&&p.push(g)}),p},u}var Nu,ys,mb=$(()=>{"use strict";({hasOwnProperty:Nu}=Object.prototype),ys=function(){}});function XE(e){return e}function QE(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 JE(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 ZE(e,t,n,r){let o=e.combinator===" "||r?e.combinator:" "+e.combinator+" ",i=e.terms.map(s=>ll(s,t,n,r)).join(o);return e.explicit||n?(r||i[0]===","?"[":"[ ")+i+(r?"]":" ]"):i}function ll(e,t,n,r){let o;switch(e.type){case"Group":o=ZE(e,t,n,r)+(e.disallowEmpty?"!":"");break;case"Multiplier":return ll(e.term,t,n,r)+t(QE(e),e);case"Boolean":o="<boolean-expr["+ll(e.term,t,n,r)+"]>";break;case"Type":o="<"+e.name+(e.opts?t(JE(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 yi(e,t){let n=XE,r=!1,o=!1;return typeof t=="function"?n=t:t&&(r=!!t.forceBraces,o=!!t.compact,typeof t.decorate=="function"&&(n=t.decorate)),ll(e,n,r,o)}var Ou=$(()=>{"use strict"});function eA(e,t){let n=e.tokens,r=e.longestMatch,o=r<n.length&&n[r].node||null,i=o!==t?o:null,s=0,a=0,u=0,c="",l,p;for(let g=0;g<n.length;g++){let d=n[g].value;g===r&&(a=d.length,s=c.length),i!==null&&n[g].node===i&&(g<=r?u++:u=0),c+=d}return r===n.length||u>1?(l=cl(i||t,"end")||bs(hb,c),p=bs(l)):(l=cl(i,"start")||bs(cl(t,"start")||hb,c.slice(0,s)),p=cl(i,"end")||bs(l,c.substr(s,a))),{css:c,mismatchOffset:s,mismatchLength:a,start:l,end:p}}function cl(e,t){let n=e&&e.loc&&e.loc[t];return n?"line"in n?bs(n):n:null}function bs({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 hb,bi,xb,yb=$(()=>{"use strict";rl();Ou();hb={offset:0,line:1,column:1};bi=function(e,t){let n=Vo("SyntaxReferenceError",e+(t?" `"+t+"`":""));return n.reference=t,n},xb=function(e,t,n,r){let o=Vo("SyntaxMatchError",e),{css:i,mismatchOffset:s,mismatchLength:a,start:u,end:c}=eA(r,n);return o.rawMessage=e,o.syntax=t?yi(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 sl(e,t){return t=t||0,e.length-t>=2&&e.charCodeAt(t)===ol&&e.charCodeAt(t+1)===ol}function ub(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 HE(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?"":ub(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 WE(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?"":ub(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=HE,Pu=WE});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,GE,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,GE,pb=$(()=>{"use strict";nr();xs=43,Pr=45,Lu=110,mi=!0,GE=!1});function Ru(e,t){return e!==null&&e.type===9&&e.value.charCodeAt(0)===t}function KE(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===db&&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),fb);){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,YE)||(e=t(++n),e===null))return 0;if(Ru(e,qE))return e=t(++n),e===null?0:e.type===1?cl(ys(e,0,!0),++n,t):Ru(e,fb)?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?!KE(e,db)||!ys(e,1,!1)?0:n+1:cl(r,n,t))}return e.type===12?cl(ys(e,1,!0),++n,t):0}var qE,db,fb,YE,gb=$(()=>{"use strict";nr();qE=43,db=45,fb=63,YE=117});function yr(e,t){return t<e.length?e.charCodeAt(t):0}function hb(e,t){return $r(e,0,e.length,t)}function xb(e,t){for(let n=0;n<t.length;n++)if(hb(e,t[n]))return!0;return!1}function yb(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 eA(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&&xb(n.value,t)?eA(n,r):e(n,r,o)}}function Ft(e){return function(t){return t===null||t.type!==e?0:1}}function tA(e){if(e===null||e.type!==1)return 0;let t=e.value.toLowerCase();return xb(t,gi)||hb(t,"default")?0:1}function bb(e){return e===null||e.type!==1||yr(e.value,0)!==45||yr(e.value,1)!==45?0:1}function nA(e){return!bb(e)||e.value==="--"?0:1}function rA(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 oA(e){return e===null||e.type!==4||!oi(yr(e.value,1),yr(e.value,2),yr(e.value,3))?0:1}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 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 sA(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||!yb(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 aA(e,t,n){return e===null||e.type!==11||ul(n,e.value,e.value.length-1)?0:1}function Sb(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 lA(e,t,n){if(e===null)return 0;let r=Do(e.value,0);return!(r===e.value.length)&&!yb(e.value,r)||ul(n,e.value,r)?0:1}function cA(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 fA(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(Sb(Vr(i)),Wr),resolution:or(Vr(s),Wr),semitones:or(Vr(a),Wr),time:or(Vr(u),Wr)}}function gA(e){let t=new Set;for(let n of dA)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 wb(e){return{...uA,...pA,...fA(e),"attr-unit":gA(e)}}var Nu,Ou,_u,XE,QE,JE,$u,Uu,mb,ZE,Wr,ju,uA,pA,dA,vb=$(()=>{"use strict";ll();pb();gb();nr();Nu=["calc(","-moz-calc(","-webkit-calc("],Ou=["min(","max(","clamp("],_u=["round(","mod(","rem("],XE=["sin(","cos(","tan("],QE=["asin(","acos(","atan(","atan2("],JE=["pow(","sqrt(","log(","exp(","sign("],$u=["hypot("],Uu=["abs("],mb=[...Nu,...Ou,..._u,...XE,...JE,...$u,...Uu],ZE=[...Nu,...Ou,..._u,...$u,...Uu],Wr=[...Nu,...Ou,..._u,...QE,...$u,...Uu],ju=new Map([[2,22],[21,22],[19,20],[23,24]]);uA={"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)},pA={string:Ft(5),ident:Ft(1),percentage:or(aA,ZE),zero:Sb(),number:or(lA,mb),integer:or(cA,mb),"custom-ident":tA,"dashed-ident":bb,"custom-property-name":nA,"hex-color":rA,"id-selector":oA,"an-plus-b":Du,urange:zu,"declaration-value":iA,"any-value":sA},dA=["length","angle","time","frequency","resolution","flex","decibel","semitones"]});var pl={};xe(pl,{angle:()=>hA,decibel:()=>wA,flex:()=>SA,frequency:()=>yA,length:()=>mA,resolution:()=>bA,semitones:()=>vA,time:()=>xA});var mA,hA,xA,yA,bA,SA,wA,vA,kb=$(()=>{"use strict";mA=["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"],hA=["deg","grad","rad","turn"],xA=["s","ms"],yA=["hz","khz"],bA=["dpi","dpcm","dppx","x"],SA=["fr"],wA=["db"],vA=["st"]});function Cb(e,t,n){return Object.assign(zo("SyntaxError",e),{input:t,offset:n,rawMessage:e,message:e+`
10
+ --------`+new Array(o.mismatchOffset+1).join("-")+"^",Object.assign(o,u),o.loc={source:n&&n.loc&&n.loc.source||"<unknown>",start:u,end:c},o}});function gl(e,t){return t=t||0,e.length-t>=2&&e.charCodeAt(t)===pl&&e.charCodeAt(t+1)===pl}function bb(e,t){if(t=t||0,e.length-t>=3&&e.charCodeAt(t)===pl&&e.charCodeAt(t+1)!==pl){let n=e.indexOf("-",t+2);if(n!==-1)return e.substring(t,n+1)}return""}function tA(e){if(ul.has(e))return ul.get(e);let t=e.toLowerCase(),n=ul.get(t);if(n===void 0){let r=gl(t,0),o=r?"":bb(t,0);n=Object.freeze({basename:t.substr(o.length),name:t,prefix:o,vendor:o,custom:r})}return ul.set(e,n),n}function nA(e){if(Si.has(e))return Si.get(e);let t=e,n=e[0];n==="/"?n=e[1]==="/"?"//":"/":n!=="_"&&n!=="*"&&n!=="$"&&n!=="#"&&n!=="+"&&n!=="&"&&(n="");let r=gl(t,n.length);if(!r&&(t=t.toLowerCase(),Si.has(t))){let a=Si.get(t);return Si.set(e,a),a}let o=r?"":bb(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 Si.set(e,s),s}var ul,Si,pl,dl,_u,fl=$(()=>{"use strict";ul=new Map,Si=new Map,pl=45,dl=tA,_u=nA});var wi,ml=$(()=>{"use strict";wi=["initial","inherit","unset","revert","revert-layer"]});function ju(e,t){return e!==null&&e.type===9&&e.value.charCodeAt(0)===t}function Ss(e,t,n){for(;e!==null&&(e.type===13||e.type===25);)e=n(++t);return t}function bo(e,t,n,r){if(!e)return 0;let o=e.value.charCodeAt(t);if(o===ws||o===Rr){if(n)return 0;t++}for(;t<e.value.length;t++)if(!$t(e.value.charCodeAt(t)))return 0;return r+1}function Uu(e,t,n){let r=!1,o=Ss(e,t,n);if(e=n(o),e===null)return t;if(e.type!==10)if(ju(e,ws)||ju(e,Rr)){if(r=!0,o=Ss(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!==ws&&i!==Rr)return 0}return bo(e,r?0:1,r,o)}function Hu(e,t){let n=0;if(!e)return 0;if(e.type===10)return bo(e,0,oA,n);if(e.type===1&&e.value.charCodeAt(0)===Rr){if(!Wr(e.value,1,$u))return 0;switch(e.value.length){case 2:return Uu(t(++n),n,t);case 3:return e.value.charCodeAt(2)!==Rr?0:(n=Ss(t(++n),n,t),e=t(n),bo(e,0,vi,n));default:return e.value.charCodeAt(2)!==Rr?0:bo(e,3,vi,n)}}else if(e.type===1||ju(e,ws)&&t(n+1).type===1){if(e.type!==1&&(e=t(++n)),e===null||!Wr(e.value,0,$u))return 0;switch(e.value.length){case 1:return Uu(t(++n),n,t);case 2:return e.value.charCodeAt(1)!==Rr?0:(n=Ss(t(++n),n,t),e=t(n),bo(e,0,vi,n));default:return e.value.charCodeAt(1)!==Rr?0:bo(e,2,vi,n)}}else if(e.type===12){let r=e.value.charCodeAt(0),o=r===ws||r===Rr?1:0,i=o;for(;i<e.value.length&&$t(e.value.charCodeAt(i));i++);return i===o||!Wr(e.value,i,$u)?0:i+1===e.value.length?Uu(t(++n),n,t):e.value.charCodeAt(i+1)!==Rr?0:i+2===e.value.length?(n=Ss(t(++n),n,t),e=t(n),bo(e,0,vi,n)):bo(e,i+2,vi,n)}return 0}var ws,Rr,$u,vi,oA,Sb=$(()=>{"use strict";rr();ws=43,Rr=45,$u=110,vi=!0,oA=!1});function Wu(e,t){return e!==null&&e.type===9&&e.value.charCodeAt(0)===t}function aA(e,t){return e.value.charCodeAt(0)===t}function vs(e,t,n){let r=0;for(let o=t;o<e.value.length;o++){let i=e.value.charCodeAt(o);if(i===wb&&n&&r!==0)return vs(e,t+r+1,!1),6;if(!Pn(i)||++r>6)return 0}return r}function hl(e,t,n){if(!e)return 0;for(;Wu(n(t),vb);){if(++e>6)return 0;t++}return t}function Vu(e,t){let n=0;if(e===null||e.type!==1||!Wr(e.value,0,sA)||(e=t(++n),e===null))return 0;if(Wu(e,iA))return e=t(++n),e===null?0:e.type===1?hl(vs(e,0,!0),++n,t):Wu(e,vb)?hl(1,++n,t):0;if(e.type===10){let r=vs(e,1,!0);return r===0?0:(e=t(++n),e===null?n:e.type===12||e.type===10?!aA(e,wb)||!vs(e,1,!1)?0:n+1:hl(r,n,t))}return e.type===12?hl(vs(e,1,!0),++n,t):0}var iA,wb,vb,sA,kb=$(()=>{"use strict";rr();iA=43,wb=45,vb=63,sA=117});function Sr(e,t){return t<e.length?e.charCodeAt(t):0}function Tb(e,t){return Vr(e,0,e.length,t)}function Ib(e,t){for(let n=0;n<t.length;n++)if(Tb(e,t[n]))return!0;return!1}function Fb(e,t){return t!==e.length-2?!1:Sr(e,t)===92&&$t(Sr(e,t+1))}function xl(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 dA(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=Qu.get(e.type);break}o++}while(e=t(o));return o}function ir(e,t){return function(n,r,o){return n===null?0:n.type===2&&Ib(n.value,t)?dA(n,r):e(n,r,o)}}function It(e){return function(t){return t===null||t.type!==e?0:1}}function gA(e){if(e===null||e.type!==1)return 0;let t=e.value.toLowerCase();return Ib(t,wi)||Tb(t,"default")?0:1}function Eb(e){return e===null||e.type!==1||Sr(e.value,0)!==45||Sr(e.value,1)!==45?0:1}function fA(e){return!Eb(e)||e.value==="--"?0:1}function mA(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(Sr(e.value,n)))return 0;return 1}function hA(e){return e===null||e.type!==4||!pi(Sr(e.value,1),Sr(e.value,2),Sr(e.value,3))?0:1}function xA(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=Qu.get(e.type);break}o++}while(e=t(o));return o}function yA(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=Qu.get(e.type);break}o++}while(e=t(o));return o}function Xr(e){return e&&(e=new Set(e)),function(t,n,r){if(t===null||t.type!==12)return 0;let o=Ho(t.value,0);if(e!==null){let i=t.value.indexOf("\\",o),s=i===-1||!Fb(t.value,i)?t.value.substr(o):t.value.substring(o,i);if(e.has(s.toLowerCase())===!1)return 0}return xl(r,t.value,o)?0:1}}function bA(e,t,n){return e===null||e.type!==11||xl(n,e.value,e.value.length-1)?0:1}function Ab(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 SA(e,t,n){if(e===null)return 0;let r=Ho(e.value,0);return!(r===e.value.length)&&!Fb(e.value,r)||xl(n,e.value,r)?0:1}function wA(e,t,n){if(e===null||e.type!==10)return 0;let r=Sr(e.value,0)===43||Sr(e.value,0)===45?1:0;for(;r<e.value.length;r++)if(!$t(Sr(e.value,r)))return 0;return xl(n,e.value,r)?0:1}function TA(e){let{angle:t,decibel:n,frequency:r,flex:o,length:i,resolution:s,semitones:a,time:u}=e||{};return{dimension:ir(Xr(null),Kr),angle:ir(Xr(t),Kr),decibel:ir(Xr(n),Kr),frequency:ir(Xr(r),Kr),flex:ir(Xr(o),Kr),length:ir(Ab(Xr(i)),Kr),resolution:ir(Xr(s),Kr),semitones:ir(Xr(a),Kr),time:ir(Xr(u),Kr)}}function IA(e){let t=new Set;for(let n of CA)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 Pb(e){return{...vA,...kA,...TA(e),"attr-unit":IA(e)}}var Gu,qu,Yu,lA,cA,uA,Ku,Xu,Cb,pA,Kr,Qu,vA,kA,CA,Lb=$(()=>{"use strict";ml();Sb();kb();rr();Gu=["calc(","-moz-calc(","-webkit-calc("],qu=["min(","max(","clamp("],Yu=["round(","mod(","rem("],lA=["sin(","cos(","tan("],cA=["asin(","acos(","atan(","atan2("],uA=["pow(","sqrt(","log(","exp(","sign("],Ku=["hypot("],Xu=["abs("],Cb=[...Gu,...qu,...Yu,...lA,...uA,...Ku,...Xu],pA=[...Gu,...qu,...Yu,...Ku,...Xu],Kr=[...Gu,...qu,...Yu,...cA,...Ku,...Xu],Qu=new Map([[2,22],[21,22],[19,20],[23,24]]);vA={"ident-token":It(1),"function-token":It(2),"at-keyword-token":It(3),"hash-token":It(4),"string-token":It(5),"bad-string-token":It(6),"url-token":It(7),"bad-url-token":It(8),"delim-token":It(9),"number-token":It(10),"percentage-token":It(11),"dimension-token":It(12),"whitespace-token":It(13),"CDO-token":It(14),"CDC-token":It(15),"colon-token":It(16),"semicolon-token":It(17),"comma-token":It(18),"[-token":It(19),"]-token":It(20),"(-token":It(21),")-token":It(22),"{-token":It(23),"}-token":It(24)},kA={string:It(5),ident:It(1),percentage:ir(bA,pA),zero:Ab(),number:ir(SA,Cb),integer:ir(wA,Cb),"custom-ident":gA,"dashed-ident":Eb,"custom-property-name":fA,"hex-color":mA,"id-selector":hA,"an-plus-b":Hu,urange:Vu,"declaration-value":xA,"any-value":yA},CA=["length","angle","time","frequency","resolution","flex","decibel","semitones"]});var yl={};Se(yl,{angle:()=>EA,decibel:()=>BA,flex:()=>MA,frequency:()=>PA,length:()=>FA,resolution:()=>LA,semitones:()=>DA,time:()=>AA});var FA,EA,AA,PA,LA,MA,BA,DA,Mb=$(()=>{"use strict";FA=["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"],EA=["deg","grad","rad","turn"],AA=["s","ms"],PA=["hz","khz"],LA=["dpi","dpcm","dppx","x"],MA=["fr"],BA=["db"],DA=["st"]});function Bb(e,t,n){return Object.assign(Vo("SyntaxError",e),{input:t,offset:n,rawMessage:e,message:e+`
11
11
  `+t+`
12
- --`+new Array((n||t.length)+1).join("-")+"^"})}var Tb=$(()=>{"use strict";Xa()});var kA,CA,TA,IA,FA,Ib,dl,Fb=$(()=>{"use strict";Tb();kA=9,CA=10,TA=12,IA=13,FA=32,Ib=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&&Ib[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!==IA&&n!==CA&&n!==TA&&n!==FA&&n!==kA)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 Cb(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||Ib[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 Bb(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 DA(e){let t=null,n=!1;switch(e.charCode()){case Nb: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=Bb(e):e.charCode()===gl?(e.pos++,t={min:0,max:0}):t={min:1,max:0};break;case ml:t=Bb(e);break;default:return null}return{type:"Multiplier",comma:n,min:t.min,max:t.max,term:null}}function Gr(e,t){let n=DA(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 RA(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 zA(e){let t=null,n=null,r=1;return e.eat(bs),e.charCode()===Ab&&(e.peek(),r=-1),r==-1&&e.charCode()===Lb?e.peek():(t=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(t+=e.scanWord())),e.skipWs(),e.eat(Yu),e.skipWs(),e.charCode()===Lb?e.peek():(r=1,e.charCode()===Ab&&(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 NA(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()===Rb&&e.nextCharCode()===zb&&(e.pos+=2,t+="()"),e.charCodeAt(e.findWsEnd(e.pos))===bs&&(e.skipWs(),n=zA(e)),e.eat(Wu),Gr(e,{type:"Type",name:t,opts:n})}function OA(e){let t=e.scanWord();return e.charCode()===Rb?(e.pos++,{type:"Function",name:t}):Gr(e,{type:"Keyword",name:t})}function _A(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)=>Mb[o]-Mb[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,zb):UA(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:_A(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()===Db&&(e.pos++,t.disallowEmpty=!0),t}function UA(e){let t=e.charCode();switch(t){case hi:break;case bs:return Gr(e,$A(e));case Ku:return e.nextCharCode()===fl?RA(e):NA(e);case Pb:return{type:"Combinator",value:e.substringToPos(e.pos+(e.nextCharCode()===Pb?2:1))};case Eb:return e.pos++,e.eat(Eb),{type:"Combinator",value:"&&"};case Yu:return e.pos++,{type:"Comma"};case fl:return Gr(e,{type:"String",value:e.scanString()});case MA:case EA:case AA:case LA:case PA:return{type:"Spaces",value:e.scanSpaces()};case BA:return t=e.nextCharCode(),e.isNameCharCode(t)?(e.pos++,{type:"AtKeyword",name:e.scanWord()}):Hu(e);case Nb:case qu:case gl:case Gu:case Db:break;case ml:if(t=e.nextCharCode(),t<48||t>57)return Hu(e);break;default:return e.isNameCharCode(t)?OA(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 EA,AA,PA,LA,MA,Db,Gu,Eb,fl,Rb,zb,Nb,qu,Yu,Ab,Ku,Wu,gl,BA,bs,hi,ml,Pb,Vu,Lb,Mb,Xu=$(()=>{"use strict";Fb();EA=9,AA=10,PA=12,LA=13,MA=32,Db=33,Gu=35,Eb=38,fl=39,Rb=40,zb=41,Nb=42,qu=43,Yu=44,Ab=45,Ku=60,Wu=62,gl=63,BA=64,bs=91,hi=93,ml=123,Pb=124,Vu=125,Lb=8734,Mb={" ":1,"&&":2,"||":3,"|":4}});function Ob(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=Ob(t.enter),i=Ob(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,_b=$(()=>{"use strict";ws=function(){}});var Ju=$(()=>{"use strict";Au();Xu();_b()});function WA(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"?WA(e):t.generate(e,HA)}var HA,Ub=$(()=>{"use strict";nr();HA={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 Hb(e){return e.length>2&&e.charCodeAt(e.length-2)===VA&&e.charCodeAt(e.length-1)===GA}function jb(e){return e.type==="Keyword"||e.type==="AtKeyword"||e.type==="Function"||e.type==="Type"&&Hb(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(jb(s)&&(o===null&&i>0&&jb(t[i-1])&&(o=Object.create(null),r=xn({type:"Enum",map:o},ut,r)),o!==null)){let a=(Hb(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 qA(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 qA(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,VA,GA,ep=$(()=>{"use strict";Xu();ut={type:"Match"},yt={type:"Mismatch"},xl={type:"DisallowEmpty"},VA=40,GA=41});function ZA(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 eP(e){return e.type!==9?!1:e.value!=="?"}function qb(e){return e===null?!0:e.type===18||e.type===2||e.type===21||e.type===19||e.type===23||eP(e)}function Yb(e){return e===null?!0:e.type===22||e.type===20||e.type===24||e.type===9&&e.value==="/"}function tP(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 P=C+O;return P<e.length?e[P]:null}function i(O,P){return{nextState:O,matchStack:R,syntaxStack:p,thenStack:f,tokenIndex:C,prev:P}}function s(O){f={nextState:O,matchStack:R,syntaxStack:p,prev:f}}function a(O){d=i(O,d)}function u(){R={type:KA,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:Kb,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:YA,syntax:null,token:null,prev:null};for(r();k===null&&++w<Gb;)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=Vb;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=XA;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 M=t.syntax.terms;if(t.index===M.length){if(t.mask===0||t.syntax.all){t=yt;break}t=ut;break}if(t.mask===(1<<M.length)-1){t=ut;break}for(;t.index<M.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=M[t.index++];break}}break}case"AddMatchOnce":t={type:"MatchOnceBuffer",syntax:t.syntax,index:0,mask:t.mask};break;case"Enum":if(F!==null){let M=F.value.toLowerCase();if(M.indexOf("\\")!==-1&&(M=M.replace(/\\[09].*$/,"")),Wb.call(t.map,M)){t=t.map[M];break}}t=yt;break;case"Generic":{let M=p!==null?p.opts:null,g=C+Math.floor(t.fn(F,o,M));if(!isNaN(g)&&g>C){for(;C<g;)u();t=ut}else t=yt;break}case"Type":case"Property":{let M=t.type==="Type"?"types":"properties",g=Wb.call(n,M)?n[M][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 M=t.name;if(F!==null){let g=F.value;if(g.indexOf("\\")!==-1&&(g=g.replace(/\\[09].*$/,"")),tp(g,M)){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?qb(R.token)?t=yt:(u(),t=Yb(F)?yt:ut):t=qb(R.token)||Yb(F)?ut:yt;break;case"String":let O="",P=C;for(;P<e.length&&O.length<t.value.length;P++)O+=e[P].value;if(tp(O,t.value)){for(;C<P;)u();t=ut}else t=yt;break;default:throw new Error("Unknown node type: "+t.type)}switch(JA+=w,k){case null:console.warn("[csstree-match] BREAK after "+Gb+" iterations"),k=QA,R=null;break;case Vb: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=tP(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=ZA(o).prev;o!==null;){switch(o.type){case np:i.match.push(i={syntax:o.syntax,match:[]}),s.push(i);break;case Kb: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 Wb,YA,KA,np,Kb,Vb,XA,QA,Gb,JA,Xb=$(()=>{"use strict";ep();({hasOwnProperty:Wb}=Object.prototype),YA=0,KA=1,np=2,Kb=3,Vb="Match",XA="Mismatch",QA="Maximum iteration number exceeded (please fill an issue on https://github.com/csstree/csstree/issues)",Gb=15e3,JA=0});var ip={};xe(ip,{getTrace:()=>Qb,isKeyword:()=>oP,isProperty:()=>rP,isType:()=>nP});function Qb(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 nP(e,t){return op(this,e,n=>n.type==="Type"&&n.name===t)}function rP(e,t){return op(this,e,n=>n.type==="Property"&&n.name===t)}function oP(e){return op(this,e,t=>t.type==="Keyword")}function op(e,t,n){let r=Qb.call(e,t);return r===null?!1:r.some(n)}var Jb=$(()=>{"use strict"});function Zb(e){return"node"in e?e.node:Zb(e.match[0])}function e0(e){return"node"in e?e.node:e0(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=Zb(a),c=e0(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 t0=$(()=>{"use strict";ps()});function ap(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e&&e>=0}function n0(e){return!!e&&ap(e.offset)&&ap(e.line)&&ap(e.column)}function iP(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(!n0(r.loc.start))i+=".start";else if(!n0(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 r0(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<"+(r0(o,t)||"any")+">");else throw new Error("Wrong value `"+o+"` in `"+t+"` structure definition")}return n.join(" | ")}function sP(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]=r0(s,e+"."+i)}return{docs:o,check:iP(e,r)}}function o0(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]=sP(n,r);else throw new Error("Missed `structure` field in `"+n+"` node type definition")}}return t}var Cs,i0=$(()=>{"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 aP(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 lP(e){for(let t=0;t<e.length;t++)if(e[t].value.toLowerCase()==="var(")return!0;return!1}function cP(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 lP(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 lb(i.reason,t.syntax,n,i),i.iterations):br(i.match,null,i.iterations))}var Ts,s0=$(()=>{"use strict";cb();al();ll();vb();kb();Ju();Ub();ep();Xb();Jb();t0();i0();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||o0(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(wb(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=cP(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:aP(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 uP(e,t){let n=Object.create(null);for(let r of Object.keys(e))t.includes(r)&&(n[r]=e[r]);return n}function up(e,t,n){let r={...e};for(let[o,i]of Object.entries(t))r[o]={...r[o],...n?uP(i,n):i};return r}function 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 a0=$(()=>{"use strict"});function l0(e){let t=ky(e),n=ib(e),r=Qy(e),{fromPlainObject:o,toPlainObject:i}=Zy(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 l0(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 c0,u0=$(()=>{"use strict";nr();Cy();Jy();eb();sb();s0();a0();c0=e=>l0(Is({},e))});var p0,d0=$(()=>{"use strict";p0={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:()=>gP,name:()=>dP,parse:()=>dp,structure:()=>fP});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,pP),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 gP(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,pP,dP,fP,gp=$(()=>{"use strict";nr();Lr=43,Gn=45,yl=110,Oo=!0,pP=!1;dP="AnPlusB",fP={a:[String,null],b:[String,null]}});var hp={};xe(hp,{generate:()=>bP,name:()=>hP,parse:()=>mp,structure:()=>yP,walkContext:()=>xP});function f0(){return this.Raw(this.consumeUntilLeftCurlyBracketOrSemicolon,!0)}function mP(){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),f0):o=f0.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(mP.call(this));break}return{type:"Atrule",loc:this.getLocation(t,this.tokenStart),name:n,prelude:o,block:i}}function bP(e){this.token(3,"@"+e.name),e.prelude!==null&&this.node(e.prelude),e.block?this.node(e.block):this.token(17,";")}var hP,xP,yP,xp=$(()=>{"use strict";hP="Atrule",xP="atrule",yP={name:String,prelude:["AtrulePrelude","Raw",null],block:["Block",null]}});var bp={};xe(bp,{generate:()=>kP,name:()=>SP,parse:()=>yp,structure:()=>vP,walkContext:()=>wP});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 kP(e){this.children(e)}var SP,wP,vP,Sp=$(()=>{"use strict";SP="AtrulePrelude",wP="atrulePrelude",vP={children:[[]]}});var kp={};xe(kp,{generate:()=>LP,name:()=>AP,parse:()=>vp,structure:()=>PP});function FP(){this.eof&&this.error("Unexpected end of input");let e=this.tokenStart,t=!1;return this.isDelim(g0)?(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 EP(){let e=this.tokenStart,t=this.charCodeAt(e);return t!==Sl&&t!==IP&&t!==TP&&t!==CP&&t!==g0&&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=FP.call(this),this.skipSC(),this.tokenType!==20&&(this.tokenType!==1&&(n=EP.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 LP(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 CP,g0,Sl,TP,wp,IP,AP,PP,Cp=$(()=>{"use strict";CP=36,g0=42,Sl=61,TP=94,wp=124,IP=126;AP="AttributeSelector",PP={name:"Identifier",matcher:[String,null],value:["String","Identifier",null],flags:[String,null]}});var Ip={};xe(Ip,{generate:()=>NP,name:()=>DP,parse:()=>Tp,structure:()=>zP,walkContext:()=>RP});function x0(){return this.Raw(null,!0)}function m0(){return this.parseWithFallback(this.Rule,x0)}function h0(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function BP(){if(this.tokenType===17)return h0.call(this,this.tokenIndex);let e=this.parseWithFallback(this.Declaration,h0);return this.tokenType===17&&this.next(),e}function Tp(e){let t=e?BP:m0,n=this.tokenStart,r=this.createList();this.eat(23);e:for(;!this.eof;)switch(this.tokenType){case 24:break e;case 13:case 25:this.next();break;case 3:r.push(this.parseWithFallback(this.Atrule.bind(this,e),x0));break;default:e&&this.isDelim(MP)?r.push(m0.call(this)):r.push(t.call(this))}return this.eof||this.eat(24),{type:"Block",loc:this.getLocation(n,this.tokenStart),children:r}}function NP(e){this.token(23,"{"),this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")}),this.token(24,"}")}var MP,DP,RP,zP,Fp=$(()=>{"use strict";MP=38;DP="Block",RP="block",zP={children:[["Atrule","Rule","Declaration"]]}});var Ap={};xe(Ap,{generate:()=>$P,name:()=>OP,parse:()=>Ep,structure:()=>_P});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 OP,_P,Pp=$(()=>{"use strict";OP="Brackets",_P={children:[[]]}});var Mp={};xe(Mp,{generate:()=>HP,name:()=>UP,parse:()=>Lp,structure:()=>jP});function Lp(){let e=this.tokenStart;return this.eat(15),{type:"CDC",loc:this.getLocation(e,this.tokenStart)}}function HP(){this.token(15,"-->")}var UP,jP,Bp=$(()=>{"use strict";UP="CDC",jP=[]});var Rp={};xe(Rp,{generate:()=>GP,name:()=>WP,parse:()=>Dp,structure:()=>VP});function Dp(){let e=this.tokenStart;return this.eat(14),{type:"CDO",loc:this.getLocation(e,this.tokenStart)}}function GP(){this.token(14,"<!--")}var WP,VP,zp=$(()=>{"use strict";WP="CDO",VP=[]});var Op={};xe(Op,{generate:()=>XP,name:()=>YP,parse:()=>Np,structure:()=>KP});function Np(){return this.eatDelim(qP),{type:"ClassSelector",loc:this.getLocation(this.tokenStart-1,this.tokenEnd),name:this.consume(1)}}function XP(e){this.token(9,"."),this.token(1,e.name)}var qP,YP,KP,_p=$(()=>{"use strict";qP=46,YP="ClassSelector",KP={name:String}});var Up={};xe(Up,{generate:()=>n2,name:()=>e2,parse:()=>$p,structure:()=>t2});function $p(){let e=this.tokenStart,t;switch(this.tokenType){case 13:t=" ";break;case 9:switch(this.charCodeAt(this.tokenStart)){case JP:case QP:case ZP:this.next();break;case y0:this.next(),this.eatIdent("deep"),this.eatDelim(y0);break;default:this.error("Combinator is expected")}t=this.substrToCursor(e);break}return{type:"Combinator",loc:this.getLocation(e,this.tokenStart),name:t}}function n2(e){this.tokenize(e.name)}var QP,y0,JP,ZP,e2,t2,jp=$(()=>{"use strict";QP=43,y0=47,JP=62,ZP=126,e2="Combinator",t2={name:String}});var Wp={};xe(Wp,{generate:()=>a2,name:()=>i2,parse:()=>Hp,structure:()=>s2});function Hp(){let e=this.tokenStart,t=this.tokenEnd;return this.eat(25),t-e+2>=2&&this.charCodeAt(t-2)===r2&&this.charCodeAt(t-1)===o2&&(t-=2),{type:"Comment",loc:this.getLocation(e,this.tokenStart),value:this.substring(e+2,t)}}function a2(e){this.token(25,"/*"+e.value+"*/")}var r2,o2,i2,s2,Vp=$(()=>{"use strict";r2=42,o2=47,i2="Comment",s2={value:String}});var qp={};xe(qp,{generate:()=>d2,name:()=>c2,parse:()=>Gp,structure:()=>u2});function b0(e){return this.lookupTypeNonSC(1)===1&&l2.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(()=>p2[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 d2(e){e.children.forEach(t=>{t.type==="Condition"?(this.token(21,"("),this.node(t),this.token(22,")")):this.node(t)})}var l2,c2,u2,p2,Yp=$(()=>{"use strict";l2=new Set([16,22,0]),c2="Condition",u2={kind:String,children:[["Identifier","Feature","FeatureFunction","FeatureRange","SupportsDeclaration"]]};p2={media:b0,container:b0,supports(){return this.SupportsDeclaration()}}});var Xp={};xe(Xp,{generate:()=>C2,name:()=>w2,parse:()=>Kp,structure:()=>k2,walkContext:()=>v2});function y2(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!0)}function b2(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1)}function S2(){let e=this.tokenIndex,t=this.Value();return t.type!=="Raw"&&this.eof===!1&&this.tokenType!==17&&this.isDelim(w0)===!1&&this.isBalanceEdge(e)===!1&&this.error(),t}function Kp(){let e=this.tokenStart,t=this.tokenIndex,n=T2.call(this),r=sl(n),o=r?this.parseCustomProperty:this.parseValue,i=r?b2:y2,s=!1,a;this.skipSC(),this.eat(16);let u=this.tokenIndex;if(r||this.skipSC(),o?a=this.parseWithFallback(S2,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(w0)&&(s=I2.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 C2(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 T2(){let e=this.tokenStart;if(this.tokenType===9)switch(this.charCodeAt(this.tokenStart)){case h2:case g2:case x2:case f2:case m2:this.next();break;case S0:this.next(),this.isDelim(S0)&&this.next();break}return this.tokenType===4?this.eat(4):this.eat(1),this.substrToCursor(e)}function I2(){this.eat(9),this.skipSC();let e=this.consume(1);return e==="important"?!0:e}var w0,f2,g2,m2,h2,x2,S0,w2,v2,k2,Qp=$(()=>{"use strict";al();w0=33,f2=35,g2=36,m2=38,h2=42,x2=43,S0=47;w2="Declaration",v2="declaration",k2={important:[Boolean,String],property:String,value:["Value","Raw"]}});var ed={};xe(ed,{generate:()=>P2,name:()=>E2,parse:()=>Zp,structure:()=>A2});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(F2)?e.push(this.parseWithFallback(this.Rule,Jp)):e.push(this.parseWithFallback(this.Declaration,Jp))}return{type:"DeclarationList",loc:this.getLocationFromList(e),children:e}}function P2(e){this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")})}var F2,E2,A2,td=$(()=>{"use strict";F2=38;E2="DeclarationList",A2={children:[["Declaration","Atrule","Rule"]]}});var rd={};xe(rd,{generate:()=>B2,name:()=>L2,parse:()=>nd,structure:()=>M2});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 B2(e){this.token(12,e.value+e.unit)}var L2,M2,od=$(()=>{"use strict";L2="Dimension",M2={value:String,unit:String}});var sd={};xe(sd,{generate:()=>N2,name:()=>R2,parse:()=>id,structure:()=>z2});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(D2)&&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 N2(e){this.token(21,"("),this.token(1,e.name),e.value!==null&&(this.token(16,":"),this.node(e.value)),this.token(22,")")}var D2,R2,z2,ad=$(()=>{"use strict";D2=47,R2="Feature",z2={kind:String,name:String,value:["Identifier","Number","Dimension","Ratio","Function",null]}});var cd={};xe(cd,{generate:()=>U2,name:()=>O2,parse:()=>ld,structure:()=>_2});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 U2(e){this.token(2,e.feature+"("),this.node(e.value),this.token(22,")")}var O2,_2,ud=$(()=>{"use strict";O2="FeatureFunction",_2={kind:String,feature:String,value:["Declaration","Selector"]}});var fd={};xe(fd,{generate:()=>G2,name:()=>W2,parse:()=>dd,structure:()=>V2});function pd(){switch(this.skipSC(),this.tokenType){case 10:return this.isDelim(v0,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(v0)&&this.error(),e},()=>this.Ratio());default:this.error("Number, dimension, ratio or identifier is expected")}}function C0(e){if(this.skipSC(),this.isDelim(j2)||this.isDelim(H2)){let t=this.source[this.tokenStart];return this.next(),this.isDelim(k0)?(this.next(),t+"="):t}if(this.isDelim(k0))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=C0.call(this,n.type==="Identifier"),o=pd.call(this),i=null,s=null;return this.lookupNonWSType(0)!==22&&(i=C0.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 G2(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 v0,j2,k0,H2,W2,V2,gd=$(()=>{"use strict";v0=47,j2=60,k0=61,H2=62,W2="FeatureRange",V2={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:()=>X2,name:()=>q2,parse:()=>md,structure:()=>K2,walkContext:()=>Y2});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 X2(e){this.token(2,e.name+"("),this.children(e),this.token(22,")")}var q2,Y2,K2,xd=$(()=>{"use strict";q2="Function",Y2="function",K2={name:String,children:[[]]}});var bd={};xe(bd,{generate:()=>Z2,name:()=>Q2,parse:()=>yd,structure:()=>J2});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 Z2(e){e.function?this.token(2,e.function+"("):this.token(21,"("),this.children(e),this.token(22,")")}var Q2,J2,Sd=$(()=>{"use strict";Q2="GeneralEnclosed",J2={kind:String,function:[String,null],children:[[]]}});var vd={};xe(vd,{generate:()=>rL,name:()=>tL,parse:()=>wd,structure:()=>nL,xxx:()=>eL});function wd(){let e=this.tokenStart;return this.eat(4),{type:"Hash",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e+1)}}function rL(e){this.token(4,"#"+e.value)}var eL,tL,nL,kd=$(()=>{"use strict";eL="XXX",tL="Hash",nL={value:String}});var Td={};xe(Td,{generate:()=>sL,name:()=>oL,parse:()=>Cd,structure:()=>iL});function Cd(){return{type:"Identifier",loc:this.getLocation(this.tokenStart,this.tokenEnd),name:this.consume(1)}}function sL(e){this.token(1,e.name)}var oL,iL,Id=$(()=>{"use strict";oL="Identifier",iL={name:String}});var Ed={};xe(Ed,{generate:()=>cL,name:()=>aL,parse:()=>Fd,structure:()=>lL});function Fd(){let e=this.tokenStart;return this.eat(4),{type:"IdSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e+1)}}function cL(e){this.token(9,"#"+e.name)}var aL,lL,Ad=$(()=>{"use strict";aL="IdSelector",lL={name:String}});var Ld={};xe(Ld,{generate:()=>fL,name:()=>pL,parse:()=>Pd,structure:()=>dL});function Pd(){let e=this.tokenStart,t=this.consume(1);for(;this.isDelim(uL);)this.eat(9),t+="."+this.consume(1);return{type:"Layer",loc:this.getLocation(e,this.tokenStart),name:t}}function fL(e){this.tokenize(e.name)}var uL,pL,dL,Md=$(()=>{"use strict";uL=46,pL="Layer",dL={name:String}});var Dd={};xe(Dd,{generate:()=>hL,name:()=>gL,parse:()=>Bd,structure:()=>mL});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 hL(e){this.children(e,()=>this.token(18,","))}var gL,mL,Rd=$(()=>{"use strict";gL="LayerList",mL={children:[["Layer"]]}});var Nd={};xe(Nd,{generate:()=>bL,name:()=>xL,parse:()=>zd,structure:()=>yL});function zd(){let e=this.tokenStart,t=null,n=null,r=null;if(this.skipSC(),this.tokenType===1&&this.lookupTypeNonSC(1)!==21){let o=this.consume(1),i=o.toLowerCase();switch(i==="not"||i==="only"?(this.skipSC(),t=i,n=this.consume(1)):n=o,this.lookupTypeNonSC(0)){case 1:{this.skipSC(),this.eatIdent("and"),r=this.Condition("media");break}case 23:case 17:case 18:case 0:break;default:this.error("Identifier or parenthesis is expected")}}else switch(this.tokenType){case 1:case 21:case 2:{r=this.Condition("media");break}case 23:case 17:case 0:break;default:this.error("Identifier or parenthesis is expected")}return{type:"MediaQuery",loc:this.getLocation(e,this.tokenStart),modifier:t,mediaType:n,condition:r}}function bL(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 xL,yL,Od=$(()=>{"use strict";xL="MediaQuery",yL={modifier:[String,null],mediaType:[String,null],condition:["Condition",null]}});var $d={};xe($d,{generate:()=>vL,name:()=>SL,parse:()=>_d,structure:()=>wL});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 vL(e){this.children(e,()=>this.token(18,","))}var SL,wL,Ud=$(()=>{"use strict";SL="MediaQueryList",wL={children:[["MediaQuery"]]}});var Hd={};xe(Hd,{generate:()=>IL,name:()=>CL,parse:()=>jd,structure:()=>TL});function jd(){let e=this.tokenStart;return this.eatDelim(kL),{type:"NestingSelector",loc:this.getLocation(e,this.tokenStart)}}function IL(){this.token(9,"&")}var kL,CL,TL,Wd=$(()=>{"use strict";kL=38,CL="NestingSelector",TL={}});var Gd={};xe(Gd,{generate:()=>AL,name:()=>FL,parse:()=>Vd,structure:()=>EL});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 AL(e){this.node(e.nth),e.selector!==null&&(this.token(1,"of"),this.node(e.selector))}var FL,EL,qd=$(()=>{"use strict";FL="Nth",EL={nth:["AnPlusB","Identifier"],selector:["SelectorList",null]}});var Kd={};xe(Kd,{generate:()=>ML,name:()=>PL,parse:()=>Yd,structure:()=>LL});function Yd(){return{type:"Number",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consume(10)}}function ML(e){this.token(10,e.value)}var PL,LL,Xd=$(()=>{"use strict";PL="Number",LL={value:String}});var Jd={};xe(Jd,{generate:()=>RL,name:()=>BL,parse:()=>Qd,structure:()=>DL});function Qd(){let e=this.tokenStart;return this.next(),{type:"Operator",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function RL(e){this.tokenize(e.value)}var BL,DL,Zd=$(()=>{"use strict";BL="Operator",DL={value:String}});var tf={};xe(tf,{generate:()=>OL,name:()=>zL,parse:()=>ef,structure:()=>NL});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 OL(e){this.token(21,"("),this.children(e),this.token(22,")")}var zL,NL,nf=$(()=>{"use strict";zL="Parentheses",NL={children:[[]]}});var of={};xe(of,{generate:()=>UL,name:()=>_L,parse:()=>rf,structure:()=>$L});function rf(){return{type:"Percentage",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consumeNumber(11)}}function UL(e){this.token(11,e.value+"%")}var _L,$L,sf=$(()=>{"use strict";_L="Percentage",$L={value:String}});var lf={};xe(lf,{generate:()=>VL,name:()=>jL,parse:()=>af,structure:()=>WL,walkContext:()=>HL});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 VL(e){this.token(16,":"),e.children===null?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"))}var jL,HL,WL,cf=$(()=>{"use strict";jL="PseudoClassSelector",HL="function",WL={name:String,children:[["Raw"],null]}});var pf={};xe(pf,{generate:()=>KL,name:()=>GL,parse:()=>uf,structure:()=>YL,walkContext:()=>qL});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 KL(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 GL,qL,YL,df=$(()=>{"use strict";GL="PseudoElementSelector",qL="function",YL={name:String,children:[["Raw"],null]}});var gf={};xe(gf,{generate:()=>JL,name:()=>XL,parse:()=>ff,structure:()=>QL});function I0(){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=I0.call(this),n=null;return this.skipSC(),this.isDelim(T0)&&(this.eatDelim(T0),n=I0.call(this)),{type:"Ratio",loc:this.getLocation(e,this.tokenStart),left:t,right:n}}function JL(e){this.node(e.left),this.token(9,"/"),e.right?this.node(e.right):this.node(10,1)}var T0,XL,QL,mf=$(()=>{"use strict";T0=47;XL="Ratio",QL={left:["Number","Function"],right:["Number","Function",null]}});var xf={};xe(xf,{generate:()=>nM,name:()=>eM,parse:()=>hf,structure:()=>tM});function ZL(){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=ZL.call(this):r=this.tokenStart,{type:"Raw",loc:this.getLocation(n,r),value:this.substring(n,r)}}function nM(e){this.tokenize(e.value)}var eM,tM,yf=$(()=>{"use strict";eM="Raw",tM={value:String}});var Sf={};xe(Sf,{generate:()=>aM,name:()=>oM,parse:()=>bf,structure:()=>sM,walkContext:()=>iM});function F0(){return this.Raw(this.consumeUntilLeftCurlyBracket,!0)}function rM(){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(rM,F0):n=F0.call(this,e),r=this.Block(!0),{type:"Rule",loc:this.getLocation(t,this.tokenStart),prelude:n,block:r}}function aM(e){this.node(e.prelude),this.node(e.block)}var oM,iM,sM,wf=$(()=>{"use strict";oM="Rule",iM="rule",sM={prelude:["SelectorList","Raw"],block:["Block"]}});var kf={};xe(kf,{generate:()=>uM,name:()=>lM,parse:()=>vf,structure:()=>cM});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 uM(e){e.root&&(this.token(21,"("),this.node(e.root),this.token(22,")")),e.limit&&(this.token(1,"to"),this.token(21,"("),this.node(e.limit),this.token(22,")"))}var lM,cM,Cf=$(()=>{"use strict";lM="Scope",cM={root:["SelectorList","Raw",null],limit:["SelectorList","Raw",null]}});var If={};xe(If,{generate:()=>fM,name:()=>pM,parse:()=>Tf,structure:()=>dM});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 fM(e){this.children(e)}var pM,dM,Ff=$(()=>{"use strict";pM="Selector",dM={children:[["TypeSelector","IdSelector","ClassSelector","AttributeSelector","PseudoClassSelector","PseudoElementSelector","Combinator"]]}});var Af={};xe(Af,{generate:()=>xM,name:()=>gM,parse:()=>Ef,structure:()=>hM,walkContext:()=>mM});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 xM(e){this.children(e,()=>this.token(18,","))}var gM,mM,hM,Pf=$(()=>{"use strict";gM="SelectorList",mM="selector",hM={children:[["Selector","Raw"]]}});function wl(e){let t=e.length,n=e.charCodeAt(0),r=n===E0||n===A0?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 P0(e,t){let n=t?"'":'"',r=t?A0:E0,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,E0,A0,vl=$(()=>{"use strict";nr();Lf=92,E0=34,A0=39});var Bf={};xe(Bf,{generate:()=>SM,name:()=>yM,parse:()=>Mf,structure:()=>bM});function Mf(){return{type:"String",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:wl(this.consume(5))}}function SM(e){this.token(5,P0(e.value))}var yM,bM,Df=$(()=>{"use strict";vl();yM="String",bM={value:String}});var zf={};xe(zf,{generate:()=>TM,name:()=>vM,parse:()=>Rf,structure:()=>CM,walkContext:()=>kM});function M0(){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)!==wM){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,M0);break;default:n=this.parseWithFallback(this.Rule,M0)}t.push(n)}return{type:"StyleSheet",loc:this.getLocation(e,this.tokenStart),children:t}}function TM(e){this.children(e)}var wM,vM,kM,CM,Nf=$(()=>{"use strict";wM=33;vM="StyleSheet",kM="stylesheet",CM={children:[["Comment","CDO","CDC","Atrule","Rule","Raw"]]}});var _f={};xe(_f,{generate:()=>EM,name:()=>IM,parse:()=>Of,structure:()=>FM});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 EM(e){this.token(21,"("),this.node(e.declaration),this.token(22,")")}var IM,FM,$f=$(()=>{"use strict";IM="SupportsDeclaration",FM={declaration:"Declaration"}});var Hf={};xe(Hf,{generate:()=>MM,name:()=>PM,parse:()=>jf,structure:()=>LM});function Uf(){this.tokenType!==1&&this.isDelim(AM)===!1&&this.error("Identifier or asterisk is expected"),this.next()}function jf(){let e=this.tokenStart;return this.isDelim(B0)?(this.next(),Uf.call(this)):(Uf.call(this),this.isDelim(B0)&&(this.next(),Uf.call(this))),{type:"TypeSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function MM(e){this.tokenize(e.name)}var AM,B0,PM,LM,Wf=$(()=>{"use strict";AM=42,B0=124;PM="TypeSelector",LM={name:String}});var qf={};xe(qf,{generate:()=>NM,name:()=>RM,parse:()=>Gf,structure:()=>zM});function Fs(e,t){let n=0;for(let r=this.tokenStart+e;r<this.tokenEnd;r++){let o=this.charCodeAt(r);if(o===R0&&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 BM(e){this.charCodeAt(this.tokenStart)!==e&&this.error((e===D0?"Plus sign":"Hyphen minus")+" is expected")}function DM(){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){BM.call(this,R0),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(D0),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"),DM.call(this),{type:"UnicodeRange",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function NM(e){this.tokenize(e.value)}var D0,R0,Vf,RM,zM,Yf=$(()=>{"use strict";nr();D0=43,R0=45,Vf=63;RM="UnicodeRange",zM={value:String}});function N0(e){let t=e.length,n=4,r=e.charCodeAt(t-1)===z0?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 O0(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===OM||o===Kf||o===_M||o===$M||o===UM||o===z0?(t+="\\"+e.charAt(r),n=!1):(n&&Pn(o)&&(t+=" "),t+=e.charAt(r),n=!1)}return"url("+t+")"}var OM,Kf,_M,$M,UM,z0,Xf=$(()=>{"use strict";nr();OM=32,Kf=92,_M=34,$M=39,UM=40,z0=41});var Jf={};xe(Jf,{generate:()=>WM,name:()=>jM,parse:()=>Qf,structure:()=>HM});function Qf(){let e=this.tokenStart,t;switch(this.tokenType){case 7:t=N0(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 WM(e){this.token(7,O0(e.value))}var jM,HM,Zf=$(()=>{"use strict";Xf();vl();jM="Url",HM={value:String}});var tg={};xe(tg,{generate:()=>qM,name:()=>VM,parse:()=>eg,structure:()=>GM});function eg(){let e=this.tokenStart,t=this.readSequence(this.scope.Value);return{type:"Value",loc:this.getLocation(e,this.tokenStart),children:t}}function qM(e){this.children(e)}var VM,GM,ng=$(()=>{"use strict";VM="Value",GM={children:[[]]}});var og={};xe(og,{generate:()=>QM,name:()=>KM,parse:()=>rg,structure:()=>XM});function rg(){return this.eat(13),YM}function QM(e){this.token(13,e.value)}var YM,KM,XM,ig=$(()=>{"use strict";YM=Object.freeze({type:"WhiteSpace",loc:null,value:" "}),KM="WhiteSpace",XM={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,U0=$(()=>{"use strict";ll();d0();sg();$0={generic:!0,cssWideKeywords:gi,...p0,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,nB)&&this.cmpChar(this.tokenStart+1,j0)?this.UnicodeRange():this.Identifier();case 9:{let t=this.charCodeAt(this.tokenStart);if(t===tB||t===ZM||t===j0||t===eB)return this.Operator();t===JM&&this.error("Hex or identifier is expected",this.tokenStart+1);break}}}var JM,ZM,j0,eB,tB,nB,ag=$(()=>{"use strict";JM=35,ZM=42,j0=43,eB=45,tB=47,nB=117});var H0,W0=$(()=>{"use strict";ag();H0={getNode:As}});function pB(e,t){t.last!==null&&t.last.type!=="Combinator"&&e!==null&&e.type!=="Combinator"&&t.push({type:"Combinator",loc:null,name:" "})}function dB(){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)===V0&&this.error("Identifier is expected",this.tokenStart+1);break;case 9:{switch(this.charCodeAt(this.tokenStart)){case sB:case lB:case uB:case aB:return this.Combinator();case V0:return this.ClassSelector();case iB:case cB:return this.TypeSelector();case rB:return this.IdSelector();case oB:return this.NestingSelector()}break}}}var rB,oB,iB,sB,aB,V0,lB,cB,uB,G0,q0=$(()=>{"use strict";rB=35,oB=38,iB=42,sB=43,aB=47,V0=46,lB=62,cB=124,uB=126;G0={onWhiteSpace:pB,getNode:dB}});function Y0(){return this.createSingleNodeList(this.Raw(null,!1))}var K0=$(()=>{"use strict"});function X0(){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 Q0=$(()=>{"use strict"});function J0(e){return e!==null&&e.type==="Operator"&&(e.value[e.value.length-1]==="-"||e.value[e.value.length-1]==="+")}var Z0,eS=$(()=>{"use strict";ag();K0();Q0();Z0={getNode:As,onWhiteSpace(e,t){J0(e)&&(e.value=" "+e.value),J0(t.last)&&(t.last.value+=" ")},expression:Y0,var:X0}});var lg={};xe(lg,{AtrulePrelude:()=>H0,Selector:()=>G0,Value:()=>Z0});var tS=$(()=>{"use strict";W0();q0();eS()});var fB,nS,rS=$(()=>{"use strict";fB=new Set(["none","and","not","or"]),nS={parse:{prelude(){let e=this.createList();if(this.tokenType===1){let t=this.substring(this.tokenStart,this.tokenEnd);fB.has(t.toLowerCase())||e.push(this.Identifier())}return e.push(this.Condition("container")),e},block(e=!1){return this.Block(e)}}}});var oS,iS=$(()=>{"use strict";oS={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 sS,aS,lS=$(()=>{"use strict";sS={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}},aS={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,sS)),this.skipSC(),this.tokenType===2&&this.cmpStr(this.tokenStart,this.tokenEnd,"supports(")&&e.push(this.Function(null,sS)),(this.lookupNonWSType(0)===1||this.lookupNonWSType(0)===21)&&e.push(this.MediaQueryList()),e},block:null}}});var cS,uS=$(()=>{"use strict";cS={parse:{prelude(){return this.createSingleNodeList(this.LayerList())},block(){return this.Block(!1)}}}});var pS,dS=$(()=>{"use strict";pS={parse:{prelude(){return this.createSingleNodeList(this.MediaQueryList())},block(e=!1){return this.Block(e)}}}});var fS,gS=$(()=>{"use strict";fS={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}}});var mS,hS=$(()=>{"use strict";mS={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}}});var xS,yS=$(()=>{"use strict";xS={parse:{prelude(){return this.createSingleNodeList(this.Scope())},block(e=!1){return this.Block(e)}}}});var bS,SS=$(()=>{"use strict";bS={parse:{prelude:null,block(e=!1){return this.Block(e)}}}});var wS,vS=$(()=>{"use strict";wS={parse:{prelude(){return this.createSingleNodeList(this.Condition("supports"))},block(e=!1){return this.Block(e)}}}});var kS,CS=$(()=>{"use strict";rS();iS();lS();uS();dS();gS();hS();yS();SS();vS();kS={container:nS,"font-face":oS,import:aS,layer:cS,media:pS,nest:fS,page:mS,scope:xS,"starting-style":bS,supports:wS}});function TS(){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 IS=$(()=>{"use strict"});var _o,ug,gB,mB,Cl,FS,ES=$(()=>{"use strict";IS();_o={parse(){return this.createSingleNodeList(this.SelectorList())}},ug={parse(){return this.createSingleNodeList(this.Selector())}},gB={parse(){return this.createSingleNodeList(this.Identifier())}},mB={parse:TS},Cl={parse(){return this.createSingleNodeList(this.Nth())}},FS={dir:gB,has:_o,lang:mB,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 AS=$(()=>{"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 PS,LS=$(()=>{"use strict";tS();CS();ES();AS();PS={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:kS,pseudo:FS,node:pg}});var MS,BS=$(()=>{"use strict";sg();MS={node:Es}});var DS,RS=$(()=>{"use strict";u0();U0();LS();BS();DS=c0({...$0,...PS,...MS})});var zS=$(()=>{"use strict"});var NS=$(()=>{"use strict"});var rq,OS,oq,iq,sq,_S,aq,lq,cq,uq,pq,dq,$S=$(()=>{"use strict";RS();zS();Ju();al();NS();vl();Xf();({tokenize:rq,parse:OS,generate:oq,lexer:iq,createLexer:sq,walk:_S,find:aq,findLast:lq,findAll:cq,toPlainObject:uq,fromPlainObject:pq,fork:dq}=DS)});function bB(e){return e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function jS(e){try{let t=OS(e.trim(),{context:"value"}),n=[];return _S(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 SB(e,t){let n=bB(e);if(!yB.has(n))return t;let r=jS(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 US(e,t){let n=t.trim();if(!n)return"";let r=SB(e,n);return jS(r).map(i=>i==="0"?"0px":i).join(" ")}function HS(e,t,n){let r=US(e,t),o=US(e,n);return r!==""&&o!==""&&r===o}var yB,WS=$(()=>{"use strict";$S();yB=new Set(["padding","margin","border-radius","borderradius","inset","border-width","borderwidth"])});function wB(e){let t=e.toLowerCase();return t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t}function vB(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 VS(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=vB(n[0]);if(i)return i}let r=t.match(/#([0-9a-fA-F]{3,8})/);if(r)return wB(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=VS(r),d=VS(o);return!!(f===d||n&&HS(n,r,o))}var dg=$(()=>{"use strict";WS()});function FB(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 GS(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 EB(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 AB(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&&FB(n)||GS(r)||GS(o)||n&&EB(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<YS:a<qS}return r.includes("%")||o.includes("%")?a<1:!1}function PB(e){let t=`${e.description||""} ${e.title||""} ${e.suggestedFix||""}`.toLowerCase();if(IB.some(s=>t.includes(s))||!CB.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 LB(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 MB(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)<KS}function BB(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(!TB.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]))>kB)}function DB(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(MB(e))return{dismissed:!0,dismissReason:`Auto-dismissed: text dimension variance (<${KS}px) - font rendering difference, not actionable`,dismissedBy:"post-ai-validation"};if(AB(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")?YS:qS}px)`,dismissedBy:"post-ai-validation"}}return DB(e)?{dismissed:!0,dismissReason:"Auto-dismissed: no measurable values to compare",dismissedBy:"post-ai-validation"}:PB(e)?{dismissed:!0,dismissReason:"Auto-dismissed: no fix needed",dismissedBy:"post-ai-validation"}:BB(e)?{dismissed:!0,dismissReason:"Auto-dismissed: HUG sizing - CSS auto-sizes content without explicit dimensions",dismissedBy:"post-ai-validation"}:LB(e)?{dismissed:!0,dismissReason:"Auto-dismissed: SVG container fill - child elements use their own fills",dismissedBy:"post-ai-validation"}:{dismissed:!1}}var qS,YS,KS,kB,CB,TB,IB,XS=$(()=>{"use strict";dg();qS=.5,YS=2,KS=2,kB=5,CB=["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"],TB=["hug","auto (hug)","should be hug","fixed pixel values are being rendered","fixed values are being rendered"],IB=["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 QS=$(()=>{"use strict"});var JS=$(()=>{"use strict"});var ZS=$(()=>{"use strict"});var fg=$(()=>{"use strict";dg();XS();QS();JS();ZS()});var HB,WB,Aq,gg=$(()=>{"use strict";HB=["flex","inline-flex"],WB=["grid","inline-grid"],Aq=[...HB,...WB]});var tw=$(()=>{"use strict";fg();gg()});var nw=$(()=>{"use strict"});var Ls=$(()=>{"use strict";ay();fg();gg();tw();nw()});function GB(e){let{aiPrompt:t,aiResponse:n,...r}=e;return r}function qn(e){try{let t=e.map(GB),n=JSON.stringify(t,qB);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,YB);return Array.isArray(t)?t:[]}catch(e){return y.error("[SessionStorage] Failed to load review history:",e),[]}}function rw(){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 ow(){try{sessionStorage.removeItem(mg),y.debug("[SessionStorage] Review history cleared")}catch(e){y.error("[SessionStorage] Failed to clear review history:",e)}}function qB(e,t){return t instanceof Date?{__type:"Date",value:t.toISOString()}:t}function YB(e,t){return t&&t.__type==="Date"?new Date(t.value):t}var mg,xg=$(()=>{"use strict";De();mg="uicopilot_review_history"});import KB,{createContext as XB,useContext as QB,useReducer as JB,useMemo as iw,useRef as ZB,useEffect as eD}from"react";function tD(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 ow(),{...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]=JB(tD,sD),r=ZB(t);eD(()=>{r.current=t},[t]);let o=iw(()=>({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=iw(()=>({...t,...o}),[t,o]);return KB.createElement(sw.Provider,{value:i},e)}function se(){let e=QB(sw);if(!e)throw new Error("useReviewStore must be used within a ReviewProvider");return e}var nD,rD,yg,oD,iD,sD,sw,Sg=$(()=>{"use strict";Ls();xg();De();nD=()=>{if(typeof localStorage>"u")return 3;try{let e=localStorage.getItem("uicopilot_review_all_concurrency");if(e)return Math.max(1,Math.min(5,parseInt(e,10)))}catch{}return 3},rD=()=>{if(typeof localStorage>"u")return null;try{let e=localStorage.getItem("uicopilot_role_override");if(e==="admin"||e==="beta")return e}catch{}return null},yg={enableFixGeneration:!1,enableFixApply:!1,enableAutoMap:!1,enableReviewBadges:!1,showCosts:!1,enableParallelReview:!1,enableModelSelection:!1},oD=()=>{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},iD=()=>{if(typeof localStorage>"u")return"beta";try{let e=localStorage.getItem("uicopilot_user_role");if(e==="admin"||e==="beta")return e}catch{}return"beta"},sD={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:iD(),roleOverride:rD(),featureFlags:oD(),reviewAllConcurrency:nD(),hoveredIssueId:null},sw=XB(null)});import Ms,{useMemo as aD}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(lD,null),e))))}function aw(e){let t=Se(),n=Ze(),r=rt(),o=se(),i=aD(()=>({...t,...n,...r,...o}),[t,n,r,o]);return e?e(i):i}function lD(){return wg=aw(),null}var wg,mt,lw=$(()=>{"use strict";ou();su();lu();Sg();wg=null,mt=Object.assign(aw,{getState:()=>{if(!wg)throw new Error("Store not initialized. Make sure StoreProvider is mounted.");return wg}})});var we=$(()=>{"use strict";lw();ou();su();lu();Sg()});function q(){return(process.env.STORYBOOK_UICOPILOT_URL||cD).replace(/\/$/,"")}var cD,cw,Ue=$(()=>{"use strict";cD="https://app.uicopilot.dev",cw=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 ZD,useCallback as Cg}from"react";import{addons as Tg}from"storybook/manager-api";async function eR(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(`${Iw}/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 tR(e,t,n){try{sessionStorage.setItem(`${Fl}${e}`,JSON.stringify({figmaNodeId:t,imageUrl:n,timestamp:Date.now()}))}catch{}}function nR(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 rR(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 vw,kw,Cw,Tw,Ci,Iw,ir,Fg,Ig,Fl,Fw,Uo,Ns=$(()=>{"use strict";we();Eg();De();Ue();pt();vw="storyArgsUpdated",kw="storyRendered",Cw="forceRemount",Tw=null,Ci=()=>Tw,Iw=q(),ir=new Map,Fg=null,Ig=new Map;Fl="uicopilot-figma-image-";Fw=(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=ZD(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=rR(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 P=k?.figmaNodeId??null;if(P!==Fg){y.debug("[useReviewScreenshots] Figma mapping changed, invalidating Figma image only for story:",w);let I=ir.get(w);I&&(I.figmaImageUrl=null),Fg=P,u.current=null}let M=k?.figmaNodeId;if(M&&!ir.get(w)?.figmaImageUrl){let I=nR(w,M);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(M){y.debug("[useReviewScreenshots] Found Figma node ID from mapping:",M);let L=null;try{y.debug("[useReviewScreenshots] Fetching Figma image (with caching)...");let D=await eR(m,M,d);L=D.imageUrl||null;let N=D.cached?"(cached)":"(fresh)";y.debug(`[useReviewScreenshots] Figma image fetched ${N}:`,L?"success":"not found")}catch(D){y.warn("[useReviewScreenshots] Failed to fetch Figma image:",D)}if(L)if(L.includes(".azureedge.net")||L.includes(".blob.core.windows.net")||L.includes(".blob.vercel-storage.com")){y.debug("[useReviewScreenshots] Using cached CDN URL directly (fast)"),I=L,C(L);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=L})}else try{y.debug("[useReviewScreenshots] Converting Figma S3 URL to data URL via proxy...");let N=`${Iw}/api/proxy/image?url=${encodeURIComponent(L)}`,S=await ie(N);if(S.ok){let j=await S.blob(),G=new FileReader,B=await new Promise((Z,oe)=>{G.onloadend=()=>Z(G.result),G.onerror=oe,G.readAsDataURL(j)});I=B,C(B),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=B})}else I=L,C(L),y.debug("[useReviewScreenshots] Figma thumbnail loaded (external URL)")}catch(N){y.warn("[useReviewScreenshots] Failed to convert to data URL, using external URL:",N),I=L,C(L)}else y.warn("[useReviewScreenshots] No thumbnail found for node:",M),C(null);I&&M&&tR(w,M,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 L=await El({storyId:w,sessionToken:d||void 0,...v&&{figmaWidth:v.width,figmaHeight:v.height}});L?(A=L,F(L),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,P=M=>{Tw=M.args,y.debug("[useReviewScreenshots] Args updated for story:",M.storyId,"args:",M.args),O&&clearTimeout(O),O=setTimeout(()=>{y.debug("[useReviewScreenshots] Story args changed, refreshing screenshot"),p()},500)};return R.on(vw,P),()=>{R.off(vw,P),O&&clearTimeout(O)}},[p]),zs(()=>{let R=Tg.getChannel(),O=!1,P=null,M=()=>{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..."),P&&clearTimeout(P),P=setTimeout(()=>{O=!1,y.debug("[useReviewScreenshots] Refreshing Storybook screenshot after HMR (preserving Figma)"),f()},500))};return R.on(Cw,M),R.on(kw,g),()=>{R.off(Cw,M),R.off(kw,g),P&&clearTimeout(P)}},[f]),zs(()=>{let R=Tg.getChannel(),O=async P=>{if(!P?.snapshot?.html){y.debug("[useReviewScreenshots] DOM mutated but no snapshot available");return}y.debug("[useReviewScreenshots] DOM mutated, capturing snapshot screenshot"),i(!0);try{let M=mt.getState().currentStoryId,g=await fetch("/__uicopilot/screenshot-snapshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...P.snapshot,storyId:M})});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(M){y.error("[useReviewScreenshots] Snapshot screenshot error:",M)}finally{i(!1)}};return R.on("UICOPILOT/STORY_DOM_MUTATED",O),()=>{R.off("UICOPILOT/STORY_DOM_MUTATED",O)}},[]);let z=Cg((R,O,P)=>{y.debug("[useReviewScreenshots] setFigmaImageDirect called - bypassing load"),Fw(R,O,P),C(P),r(!1),u.current=R},[C]);return{isLoadingScreenshots:e,isLoadingFigma:n,isLoadingStorybook:o,screenshotError:s,refreshScreenshots:p,refreshStorybookOnly:f,setFigmaImageDirect:z}}});function iR(){return!q().startsWith("http://localhost")}function sR(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 Ew(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=sR(o,t,n);return r.set(o,i),i})}async function aR(){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=Ew(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=Ew(p,o,r),u.replaceWith(f)}}catch{}})}})).toDataURL("image/png")}function lR(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 cR(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(`${oR}/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 uR(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 pR(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=uR(a),y.debug("[Screenshot] Parsed args from URL:",s))}if(s&&Object.keys(s).length>0){let a=lR(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 dR(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||fR();if(t){let n=Ag.get(t);if(n)return y.debug("[Screenshot] Reusing in-flight capture for",t),n;let r=Aw(t,e).finally(()=>{Ag.delete(t)});return Ag.set(t,r),r}return Aw(void 0,e)}async function Aw(e,t){try{if(e){let n=await dR(e);if(n)return n}if(!iR()){let n=pR(t?.storyId);return await cR(n,{...t,selector:"#storybook-root > *"})}return y.info("[Screenshot] Using client-side capture (html2canvas fallback)"),await aR()}catch(n){throw y.error("Error capturing screenshot:",n),new Error(`Failed to capture screenshot: ${n instanceof Error?n.message:"Unknown error"}`)}}function fR(){return(new URLSearchParams(window.location.search).get("path")||"").replace("/story/","").replace("/docs/","")||void 0}var oR,Ag,Eg=$(()=>{"use strict";Ue();Ns();De();pt();oR=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 Pw(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:Pw(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 gR(e){let t=[],n=new Set,r=Lw.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(Lw.includes(e.tagName.toLowerCase())){let i=`${e.tagName.toLowerCase()}.${e.className}`;n.has(i)||t.unshift(e)}return t}function mR(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 hR(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 xR(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=hR(r,2),i=o.map(xR).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=gR(r);s=a.map(mR),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 Lw,Mw=$(()=>{"use strict";De();_s();Al();Lw=["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 bR(e,t,n){if(!(e==="0px"||t==="none"))return`${e} ${t} ${n}`}function SR(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e),r={},o=vn(n.backgroundColor);Dn("backgroundColor",o)||(r.backgroundColor=o);let i=bR(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=yR.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 Bw(e){let t=1;for(let n of e.children)t+=Bw(n);return t}function Dw(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=SR(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:Bw(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=Dw(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 yR,Rw=$(()=>{"use strict";De();_s();Al();yR=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});var Dg=$(()=>{"use strict";_s();Al();Mw();Rw()});var av=Jn((nX,sv)=>{"use strict";sv.exports={compareTwoStrings:iv,findBestMatch:VR};function iv(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 VR(e,t){if(!GR(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=iv(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 GR(e,t){return!(typeof e!="string"||!Array.isArray(t)||!t.length||t.find(function(n){return typeof n!="string"}))}});var JC=Jn((eie,QC)=>{"use strict";var qC=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,_4=/\n/g,$4=/^\s*/,U4=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,j4=/^:\s*/,H4=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,W4=/^[;\s]*/,V4=/^\s+|\s+$/g,G4=`
14
- `,YC="/",KC="*",Qo="",q4="comment",Y4="declaration";function K4(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(_4);w&&(n+=w.length);var k=m.lastIndexOf(G4);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($4)}function l(m){var w;for(m=m||[];w=p();)w!==!1&&m.push(w);return m}function p(){var m=i();if(!(YC!=e.charAt(0)||KC!=e.charAt(1))){for(var w=2;Qo!=e.charAt(w)&&(KC!=e.charAt(w)||YC!=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:q4,comment:k})}}function f(){var m=i(),w=u(U4);if(w){if(p(),!u(j4))return a("property missing ':'");var k=u(H4),F=m({type:Y4,property:XC(w[0].replace(qC,Qo)),value:k?XC(k[0].replace(qC,Qo)):Qo});return u(W4),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 XC(e){return e?e.replace(V4,Qo):Qo}QC.exports=K4});var ZC=Jn(ia=>{"use strict";var X4=ia&&ia.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ia,"__esModule",{value:!0});ia.default=J4;var Q4=X4(JC());function J4(e,t){let n=null;if(!e||typeof e!="string")return n;let r=(0,Q4.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 t1=Jn(pc=>{"use strict";Object.defineProperty(pc,"__esModule",{value:!0});pc.camelCase=void 0;var Z4=/^--[a-zA-Z0-9_-]+$/,eU=/-([a-z])/g,tU=/^[^-]+$/,nU=/^-(webkit|moz|ms|o|khtml)-/,rU=/^-(ms)-/,oU=function(e){return!e||tU.test(e)||Z4.test(e)},iU=function(e,t){return t.toUpperCase()},e1=function(e,t){return"".concat(t,"-")},sU=function(e,t){return t===void 0&&(t={}),oU(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(rU,e1):e=e.replace(nU,e1),e.replace(eU,iU))};pc.camelCase=sU});var r1=Jn((xh,n1)=>{"use strict";var aU=xh&&xh.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},lU=aU(ZC()),cU=t1();function hh(e,t){var n={};return!e||typeof e!="string"||(0,lU.default)(e,function(r,o){r&&o&&(n[(0,cU.camelCase)(r,t)]=o)}),n}hh.default=hh;n1.exports=hh});var PT=Jn((Aue,AT)=>{"use strict";var Dc=Object.prototype.hasOwnProperty,ET=Object.prototype.toString,vT=Object.defineProperty,kT=Object.getOwnPropertyDescriptor,CT=function(t){return typeof Array.isArray=="function"?Array.isArray(t):ET.call(t)==="[object Array]"},TT=function(t){if(!t||ET.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)},IT=function(t,n){vT&&n.name==="__proto__"?vT(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},FT=function(t,n){if(n==="__proto__")if(Dc.call(t,n)){if(kT)return kT(t,n).value}else return;return t[n]};AT.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=FT(a,n),o=FT(t,n),a!==o&&(l&&o&&(TT(o)||(i=CT(o)))?(i?(i=!1,s=r&&CT(r)?r:[]):s=r&&TT(r)?r:{},IT(a,{name:n,newValue:e(l,s,o)})):typeof o<"u"&&IT(a,{name:n,newValue:o}));return a}});import Ea from"react";import{addons as Kc,types as jx,experimental_getStatusStore as hF}from"storybook/manager-api";import{AddonPanel as E8}from"storybook/internal/components";import Bt,{useState as qW,useEffect as YW}from"react";import{styled as fr}from"storybook/theming";import Qx from"react";import{styled as Pt}from"storybook/theming";var le="#ea580c",Jc="#c2410c",Ma="#ff6b35";var Vx=Pt.div(({theme:e})=>({fontFamily:e.typography.fonts.base,height:"100%",display:"flex",flexDirection:"column",backgroundColor:e.background.content,color:e.color.defaultText})),Gx=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"}})),qx=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}})),Yx=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"})),z8=Pt.div(({theme:e})=>({padding:`${e.layoutMargin*1.6}px`,borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content})),Kx=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})),N8=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})),O8=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%)"}}})),Xx=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}}),_8=Pt.div(({theme:e})=>({padding:"40px 20px",textAlign:"center",color:e.color.mediumdark})),$8=Pt.div(({theme:e})=>({fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,marginBottom:`${e.layoutMargin*.8}px`,color:e.color.defaultText})),U8=Pt.div(({theme:e})=>({fontSize:e.typography.size.s2,color:e.color.mediumdark}));var tu=({header:e,children:t,footer:n})=>Qx.createElement(Vx,null,e,Qx.createElement(Gx,null,t),n);import TF from"react";import{styled as IF}from"storybook/theming";var FF=IF.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})=>TF.createElement(FF,null,e);import Q8 from"react";import{styled as Da}from"storybook/theming";var eV=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})),tV=Da.div({display:"flex",flex:1}),nV=Da(io)(({theme:e,disabled:t})=>({padding:"6px 12px",...t?{color:e.color.mediumlight,cursor:"not-allowed",opacity:.5,"&:hover":{}}:{}})),rV=Da.div({display:"flex",gap:"8px",alignItems:"center"});import pn,{useState as xw,useCallback as yw,useEffect as bw}from"react";import{styled as fo}from"storybook/theming";import Re,{useEffect as uw}from"react";import{styled as at}from"storybook/theming";we();Ue();De();pt();var pw=at.div({position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:1e4}),dw=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})),uD=at.div({display:"flex",alignItems:"center",gap:"12px",padding:"16px 16px 12px"}),pD=at.div({width:"36px",height:"36px",borderRadius:"50%",backgroundColor:le,display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:"14px",fontWeight:700,flexShrink:0}),dD=at.div({display:"flex",flexDirection:"column",gap:"4px"}),fD=at.div(({theme:e})=>({fontSize:"15px",fontWeight:600,color:e.color.defaultText,lineHeight:1.2})),gD=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"}),mD=at.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px 8px",fontSize:"14px",color:e.color.defaultText})),hD=at.span(({theme:e})=>({color:e.textMutedColor,fontSize:"13px"})),xD=at.span(({theme:e})=>({color:e.color.defaultText,fontSize:"15px",fontWeight:600})),yD=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"})),bD=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"})),SD=at.div(({theme:e})=>({padding:"0 16px 14px",fontSize:"12px",color:e.textMutedColor})),wD=at.div(({theme:e})=>({height:"1px",backgroundColor:e.appBorderColor})),vD=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)"}}),kD=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}})),CD=at.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px",borderBottom:`1px solid ${e.appBorderColor}`})),TD=at.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"10px",color:e.color.defaultText,fontSize:"14px",fontWeight:500})),ID=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})),FD=at.div({display:"flex",gap:"8px"}),fw=at(wn)({fontSize:"18px"}),ED=at.div({padding:"20px 16px"}),AD=at.div(({theme:e})=>({padding:"16px",borderRadius:"8px",background:"linear-gradient(135deg, #10B981 0%, #3B82F6 100%)",marginBottom:"16px",color:"#fff"})),PD=at.div({fontSize:"12px",fontWeight:500,opacity:.9,marginBottom:"4px"}),LD=at.div({fontSize:"28px",fontWeight:700}),MD=at.div({fontSize:"11px",opacity:.8,marginTop:"4px"}),BD=at.div(({theme:e})=>({padding:"16px",borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),DD=at.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),RD=at.div({display:"flex",alignItems:"center",gap:"8px"}),zD=at.span(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),ND=at.span(({theme:e})=>({fontSize:"10px",fontWeight:600,padding:"2px 6px",borderRadius:"4px",backgroundColor:le,color:e.color.inverseText})),OD=at.button(({theme:e})=>({background:"none",border:"none",color:le,fontSize:"12px",cursor:"pointer","&:hover":{textDecoration:"underline"}})),_D=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}})),UD=30*1e3,gw=({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<UD;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)}};uw(()=>{l()},[t]),uw(()=>{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(pw,{onClick:e}),Re.createElement(dw,{onClick:z=>z.stopPropagation(),style:{width:"320px"}},Re.createElement(kD,{onClick:e,title:"Close"},"\xD7"),Re.createElement(uD,null,Re.createElement(pD,null,u?.email?u.email[0].toUpperCase():"U"),Re.createElement(dD,null,Re.createElement(fD,null,"UI Review"),Re.createElement(gD,null,(u?.plan||"BETA").toUpperCase()))),Re.createElement(mD,null,Re.createElement(hD,null,"Credits"),Re.createElement(xD,null,m," left")),Re.createElement(yD,null,Re.createElement(bD,{percent:C})),Re.createElement(SD,null,F," used \xB7 ",m," remaining"),Re.createElement(wD,null),Re.createElement(vD,{onClick:d},"Get free credits \u2192")))}return Re.createElement(Re.Fragment,null,Re.createElement(pw,{onClick:e}),Re.createElement(dw,{onClick:m=>m.stopPropagation()},Re.createElement(CD,null,Re.createElement(TD,null,Re.createElement(ID,null,u?.email?u.email[0].toUpperCase():"U"),Re.createElement("span",null,u?.email||"Loading...")),Re.createElement(FD,null,Re.createElement(fw,{onClick:p,title:"Sign out"},"\u2192"),Re.createElement(fw,{onClick:e,title:"Close"},"\xD7"))),Re.createElement(ED,null,c?Re.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Loading..."):t?Re.createElement(Re.Fragment,null,Re.createElement(AD,null,Re.createElement(PD,null,"Credit Balance"),Re.createElement(LD,null,"$",(u?.creditBalance??0).toFixed(2)),Re.createElement(MD,null,(u?.creditBalance??0)<2?"Low balance - consider topping up":"Pay only for what you use")),Re.createElement(BD,null,Re.createElement(DD,null,Re.createElement(RD,null,Re.createElement(zD,null,"Current Plan"),Re.createElement(ND,null,u?.plan||"Free")),Re.createElement(OD,{onClick:f},"View detail >")),Re.createElement(_D,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 mw}from"storybook/theming";Ue();we();pt();De();var jD=mw.div({display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"}),HD=mw.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark})),WD={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}},hw=()=>{let{userRole:e,roleOverride:t,setRoleOverride:n,setFeatureFlags:r}=se(),{sessionToken:o}=Se();return e!=="admin"?null:wi.createElement(jD,null,wi.createElement(HD,null,"View as:"),wi.createElement(qx,{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=WD[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(Xx,{variant:"warning"},"Previewing as ",t))};we();Ue();pt();var VD=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"}})),GD=fo.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.secondary,fontWeight:e.typography.weight.bold,paddingRight:"8px",opacity:.8})),qD=fo.div({position:"relative"}),YD=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`}})),Sw=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)"}})),KD=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)"}}}),XD=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}})),QD=30*1e3,kg=({onOpenSettings:e})=>{let[t,n]=xw(!1),[r,o]=xw(!1),{usageData:i,usageLastFetched:s,setUsageData:a,sessionToken:u}=Se(),{userRole:c,roleOverride:l,featureFlags:p}=se(),f=l??c;bw(()=>{(async()=>{if(!(!u||s&&Date.now()-s<QD&&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]),bw(()=>{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=yw(()=>{n(!0)},[]),m=yw(()=>{n(!1)},[]),w=i?.creditBalance??0,k=w<2&&!r;return pn.createElement(VD,null,e&&pn.createElement(vi,null,pn.createElement(XD,{onClick:e,title:"Settings"},pn.createElement("span",{style:{fontSize:"14px"}},"\u2699"),"Settings")),u&&c==="admin"&&f==="admin"&&pn.createElement(vi,null,pn.createElement(hw,null)),pn.createElement(vi,null,pn.createElement(GD,null,"v","0.5.7")),u&&p.showCosts&&pn.createElement(vi,null,pn.createElement(Sw,{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(KD,null):i?`$${w.toFixed(2)}`:"...")),u&&!p.showCosts&&i&&pn.createElement(vi,null,pn.createElement(Sw,{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(qD,null,pn.createElement(YD,{title:"Account & Usage",onClick:d},i?.email?i.email[0].toUpperCase():"?"),t&&pn.createElement(gw,{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 ww,useEffect as JD}from"react";var go=q();y.debug("[useAuth] Module loaded, APP_URL:",go);var Bs=()=>{let e=ww(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=ww(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 L=await(await fetch(`${go}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:b})})).json();L.status==="authorized"&&L.session_token?(y.debug("[useAuth] \u2705 OAuth poll successful! Got token."),C.current&&(clearInterval(C.current),C.current=null),localStorage.setItem("uicopilot_session_token",L.session_token),c(L.session_token)):L.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]),P=ki(()=>{e.current&&(clearInterval(e.current),e.current=null),f(null),d(null),m(null),w(null)},[f,d,m,w]),M=ki(x=>{l(x),localStorage.setItem("uicopilot_api_key",x)},[l]),g=ki(()=>{F(),e.current&&(clearInterval(e.current),e.current=null)},[F]);return JD(()=>()=>{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:P,saveApiKey:M,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),zw=BigInt(32);function wR(e,t=!1){return t?{h:Number(e&Ll),l:Number(e>>zw&Ll)}:{h:Number(e>>zw&Ll)|0,l:Number(e&Ll)|0}}function Nw(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}=wR(e[i],t);[r[i],o[i]]=[s,a]}return[r,o]}var Ow=(e,t,n)=>e<<n|t>>>32-n,_w=(e,t,n)=>t<<n|e>>>32-n,$w=(e,t,n)=>t<<n-32|e>>>64-n,Uw=(e,t,n)=>e<<n-32|t>>>64-n;function vR(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=vR(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 jw(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 Hw(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 kR=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function CR(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function TR(e){for(let t=0;t<e.length;t++)e[t]=CR(e[t]);return e}var Og=kR?e=>e:TR;function Ww(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 Vw=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var IR=BigInt(0),Us=BigInt(1),FR=BigInt(2),ER=BigInt(7),AR=BigInt(256),PR=BigInt(113),Yw=[],Kw=[],Xw=[];for(let e=0,t=Us,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Yw.push(2*(5*r+n)),Kw.push((e+1)*(e+2)/2%64);let o=IR;for(let i=0;i<7;i++)t=(t<<Us^(t>>ER)*PR)%AR,t&FR&&(o^=Us<<(Us<<BigInt(i))-Us);Xw.push(o)}var Qw=Nw(Xw,!0),LR=Qw[0],MR=Qw[1],Gw=(e,t,n)=>n>32?$w(e,t,n):Ow(e,t,n),qw=(e,t,n)=>n>32?Uw(e,t,n):_w(e,t,n);function BR(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=Gw(c,l,1)^n[a],f=qw(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=Kw[s],u=Gw(o,i,a),c=qw(o,i,a),l=Yw[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]^=LR[r],e[1]^=MR[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=Hw(this.state)}clone(){return this._cloneInto()}keccak(){Og(this.state32),BR(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(jw(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}},DR=(e,t,n,r={})=>Ww(()=>new _g(t,e,n),r);var Jw=DR(6,72,64,Vw(10));var RR=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,$g=Math.ceil,ar=Math.floor,Rn="[BigNumber Error] ",Zw=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 ev(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,L,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}L=String(g)}else{if(!RR.test(L=String(g)))return r(D,L,v);D.s=L.charCodeAt(0)==45?(L=L.slice(1),-1):1}(T=L.indexOf("."))>-1&&(L=L.replace(".","")),(I=L.search(/e/i))>0?(T<0&&(T=I),T+=+L.slice(I+1),L=L.substring(0,I)):T<0&&(T=L.length)}else{if(Rt(x,2,k.length,"Base"),x==10&&F)return D=new C(g),P(D,s+D.e+1,a);if(L=String(g),v=typeof g=="number"){if(g*0!=0)return r(D,L,v,x);if(D.s=1/g<0?(L=L.slice(1),-1):1,C.DEBUG&&L.replace(/^0\.0*|\./,"").length>15)throw Error(Zw+g)}else D.s=L.charCodeAt(0)===45?(L=L.slice(1),-1):1;for(b=k.slice(0,x),T=I=0,A=L.length;I<A;I++)if(b.indexOf(E=L.charAt(I))<0){if(E=="."){if(I>T){T=A;continue}}else if(!h&&(L==L.toUpperCase()&&(L=L.toLowerCase())||L==L.toLowerCase()&&(L=L.toUpperCase()))){h=!0,I=-1,T=0;continue}return r(D,String(g),v,x)}v=!1,L=n(L,x,10,D.s),(T=L.indexOf("."))>-1?L=L.replace(".",""):T=L.length}for(I=0;L.charCodeAt(I)===48;I++);for(A=L.length;L.charCodeAt(--A)===48;);if(L=L.slice(I,++A)){if(A-=I,v&&C.DEBUG&&A>15&&(g>Ug||g!==ar(g)))throw Error(Zw+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(+L.slice(0,I)),A-=je;I<A;)D.c.push(+L.slice(I,I+=je));I=je-(L=L.slice(I)).length}else I-=A;for(;I--;L+="0");D.c.push(+L)}}else D.c=[D.e=0]}C.clone=ev,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,L=[],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]):(L.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):(L.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&&(L[A++]=v%1e14);for(I=L[--A],b%=je,I&&b&&(v=jg[je-b],L[A]=ar(I/v)*v);L[A]===0;L.pop(),A--);if(A<0)L=[T=0];else{for(T=-1;L[0]===0;L.splice(0,1),T-=je);for(A=1,v=L[0];v>=10;v/=10,A++);A<je&&(T-=je-A)}return D.e=T,D.c=L,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,L=0,D=b.length;L<D;){for(A=v.length;A--;v[A]*=E);for(v[0]+=T.indexOf(b.charAt(L++)),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,L,D,N,S,j,G,B=b.indexOf("."),J=s,Z=a;for(B>=0&&(D=m,m=0,b=b.replace(".",""),G=new C(E),S=G.pow(b.length-B),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)),L=D=j.length;j[--D]==0;j.pop());if(!j[0])return v.charAt(0);if(B<0?--L:(S.c=j,S.e=L,S.s=T,S=t(S,G,J,Z,h),j=S.c,N=S.r,L=S.e),A=L+J+1,B=j[A],D=h/2,N=N||A<0||j[A+1]!=null,N=Z<4?(B!=null||N)&&(Z==0||Z==(S.s<0?3:2)):B>D||B==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||(++L,j=[1].concat(j));for(D=j.length;!j[--D];);for(B=0,b="";B<=D;b+=v.charAt(j[B++]));b=Yr(b,L,v.charAt(0))}return b}})(),t=(function(){function g(E,h,T){var I,v,A,L,D=0,N=E.length,S=h%mo,j=h/mo|0;for(E=E.slice();N--;)A=E[N]%mo,L=E[N]/mo|0,I=j*A+L*S,v=S*A+I%mo*mo+D,D=(v/T|0)+(I/mo|0)+j*L,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,L,D,N,S,j,G,B,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(B=new C(Be),J=B.c=[],L=E.e-h.e,Be=T+L+1,v||(v=Sr,L=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)&&L--,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++);P(B,T+(B.e=D+L*je-1)+1,I,N)}else B.e=L,B.r=+N;return B}})();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=P(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 L,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 L=(j=j.toLowerCase())=="x"?16:j=="b"?2:8,!A||A==L?S:N}),A&&(L=A,D=D.replace(x,"$1").replace(b,"0.$1")),I!=D))return new C(D,L);if(C.DEBUG)throw Error(Rn+"Not a"+(A?" base "+A:"")+" number: "+I);T.s=null}T.c=T.e=null}})();function P(g,x,b,E){var h,T,I,v,A,L,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[L=0],D=ar(A/S[h-I-1]%10);else if(L=$g((T+1)/je),L>=N.length)if(E){for(;N.length<=L;N.push(0));A=D=0,h=1,T%=je,I=T-je+1}else break e;else{for(A=v=N[L],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[L+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[L-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=L,v=1,L--):(N.length=L+1,v=S[je-T],N[L]=I>0?ar(A/S[h-I]%S[I])*v:0),E)for(;;)if(L==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[L]+=v,N[L]!=Sr)break;N[L--]=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 M(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),P(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,L,D,N=this;if(g=new C(g),g.c&&!g.isInteger())throw Error(Rn+"Exponent not an integer: "+M(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(+M(N),v?g.s*(2-Bl(g)):+M(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),L=Bl(g)):(h=Math.abs(+M(g)),L=h%2),D=new C(i);;){if(L){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;L=h%2}else if(g=g.times(b),P(g,g.e+1,1),g.e>14)L=Bl(g);else{if(h=+M(g),h===0)break;L=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?P(D,m,a,I):D)},o.integerValue=function(g){var x=new C(this);return g==null?g=a:Rt(g,0,8),P(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,L=g.e/je,D=I.c,N=g.c;if(!A||!L){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),L=lr(L),D=D.slice(),v=A-L){for((T=v<0)?(v=-v,h=D):(L=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),--L);return D[0]?O(g,D,L):(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,L,D,N,S,j,G,B,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(B=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;)L=oe[--I]%J,D=oe[I]/J|0,v=j*L+D*S,L=S*L+v%J*J+G[T]+b,b=(L/B|0)+(v/J|0)+j*D,G[T--]=L%B;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),P(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,L=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(+M(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+L,v<3&&(v=0);;)if(h=b,b=D.times(h.plus(t(T,h,L,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&&(P(h,h.e+s+2,0),h.times(h).eq(T))){b=h;break}L+=4,v+=4,E=1}else{(!+x||!+x.slice(1)&&x.charAt(0)=="5")&&(P(b,b.e+s+2,1),g=!b.times(b).eq(T));break}}return P(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,L=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+=L+j.substr(T,v);A>0&&(D+=L+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,L,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: ")+M(v));if(!G)return new C(j);for(x=new C(i),L=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:L: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,L=A.plus(D.times(h=L)),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(L)),b=b.plus(h.times(E)),A.s=L.s=j.s,T=T*2,N=t(L,E,T,a).minus(j).abs().comparedTo(t(A,b,T,a).minus(j).abs())<1?[L,E]:[A,b],p=I,N},o.toNumber=function(){return+M(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=P(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 M(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 zR=ev(),tv=zR;var NR=24,js=32,OR=()=>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=OR(),Hg=(e=4,t=Wg)=>{let n="";for(;n.length<e;)n=n+Math.floor(t()*36).toString(36);return n};function _R(e){let t=new tv(0);for(let n of e.values())t=t.multipliedBy(256).plus(n);return t}var rv=(e="")=>{let t=new TextEncoder;return _R(Jw(t.encode(e))).toString(36).slice(1)},nv=Array.from({length:26},(e,t)=>String.fromCharCode(t+97)),$R=e=>nv[Math.floor(e()*nv.length)],UR=({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 rv(r).substring(0,js)},jR=e=>()=>e++,HR=476782367,ov=({random:e=Wg,counter:t=jR(Math.floor(e()*HR)),length:n=NR,fingerprint:r=UR({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+rv(c).substring(1,n)}`}},ho=WR(ov);function WR(e){let t;return()=>(t||(t=e()),t())}var qR=La(av());Ls();De();var Rl=/\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*-\s*(.+)/g;function YR(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=YR(r[s]),u=Rl.exec(a);if(u){let[,c,l,,p]=u,f=KR(l),d=XR(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 KR(e){let t=e.toLowerCase().trim();return t.includes("critical")||t.includes("high")?"critical":t.includes("major")||t.includes("medium")?"major":"minor"}function XR(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,lv=0,QR=3e4;async function JR(){let e=Date.now();if(Hs&&e-lv<QR)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||{},lv=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 JR())[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 ZR(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):ZR(e.type,t)}De();function ez(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 tz(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 nz(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 rz(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=>!nz(i)),n=[],r=[];for(let i of t){let s=ez(i),a=tz(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(rz(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 oz(e){return e.criticalCount>0||e.score<70?"status-value:error":e.majorCount>0||e.score<90?"status-value:warning":"status-value:success"}function iz(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 sz(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 uv(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 pv(e){if(Fi())try{zl.getChannel().emit(Ii.REVIEW_ERROR,{storyId:e})}catch{}}function cv(e){try{typeof e.unset=="function"?e.unset():typeof e.set=="function"&&e.set([])}catch{}}function dv(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:oz(i),typeId:Kg,storyId:o,title:sz(i),description:iz(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||cv(e),setInterval(()=>{let o=Fi();o!==r&&(r=o,o||cv(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:P,setFullPrompt:M,setFullResponse:g,setFigmaImageUrl:x,storybookImageUrl:b,setStorybookImageUrl:E,setFigmaDimensions:h,setMultiModelResults:T,updateMultiModelStreamingMessages:I,setModelCompleted:v,setActiveModelId:A,resetReview:L,addReview:D,setReviewDetailTab:N,includeTextComparison:S,usePromptCache:j,setApplyFixesResult:G,featureFlags:B}=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),P(lt)},[O,P]),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&&B.enableReviewBadges&&uv(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),M(""),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,Hx=l.length>1,Bo={},Zi={},L8={};if(!oo)throw new Error("Response body is not readable");let Wx=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&&(M(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(Hx&&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}]
12
+ --`+new Array((n||t.length)+1).join("-")+"^"})}var Db=$(()=>{"use strict";rl()});var RA,zA,NA,OA,_A,Rb,bl,zb=$(()=>{"use strict";Db();RA=9,zA=10,NA=12,OA=13,_A=32,Rb=new Uint8Array(128).map((e,t)=>/[a-zA-Z0-9\-]/.test(String.fromCharCode(t))?1:0),bl=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&&Rb[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!==OA&&n!==zA&&n!==NA&&n!==_A&&n!==RA)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 Bb(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||Rb[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 jb(e){let t=null,n=null;return e.eat(vl),e.skipWs(),t=e.scanNumber(e),e.skipWs(),e.charCode()===rp?(e.pos++,e.skipWs(),e.charCode()!==ep&&(n=e.scanNumber(e),e.skipWs())):n=t,e.eat(ep),{min:Number(t),max:n?Number(n):0}}function GA(e){let t=null,n=!1;switch(e.charCode()){case Gb:e.pos++,t={min:0,max:0};break;case np:e.pos++,t={min:1,max:0};break;case wl:e.pos++,t={min:0,max:1};break;case tp:e.pos++,n=!0,e.charCode()===vl?t=jb(e):e.charCode()===wl?(e.pos++,t={min:0,max:0}):t={min:1,max:0};break;case vl:t=jb(e);break;default:return null}return{type:"Multiplier",comma:n,min:t.min,max:t.max,term:null}}function Qr(e,t){let n=GA(e);return n!==null?(n.term=t,e.charCode()===tp&&e.charCodeAt(e.pos-1)===np||e.charCode()===wl&&e.charCodeAt(e.pos-1)===ep?Qr(e,n):n):t}function Ju(e){let t=e.peek();return t===""?null:Qr(e,{type:"Token",value:t})}function qA(e){let t;return e.eat(op),e.eat(Sl),t=e.scanWord(),e.eat(Sl),e.eat(Zu),Qr(e,{type:"Property",name:t})}function YA(e){let t=null,n=null,r=1;return e.eat(ks),e.charCode()===Ob&&(e.peek(),r=-1),r==-1&&e.charCode()===$b?e.peek():(t=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(t+=e.scanWord())),e.skipWs(),e.eat(rp),e.skipWs(),e.charCode()===$b?e.peek():(r=1,e.charCode()===Ob&&(e.peek(),r=-1),n=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(n+=e.scanWord())),e.eat(ki),{type:"Range",min:t,max:n}}function KA(e){let t,n=null;if(e.eat(op),t=e.scanWord(),t==="boolean-expr"){e.eat(ks);let r=kl(e,ki);return e.eat(ki),e.eat(Zu),Qr(e,{type:"Boolean",term:r.terms.length===1?r.terms[0]:r})}return e.charCode()===Wb&&e.nextCharCode()===Vb&&(e.pos+=2,t+="()"),e.charCodeAt(e.findWsEnd(e.pos))===ks&&(e.skipWs(),n=YA(e)),e.eat(Zu),Qr(e,{type:"Type",name:t,opts:n})}function XA(e){let t=e.scanWord();return e.charCode()===Wb?(e.pos++,{type:"Function",name:t}):Qr(e,{type:"Keyword",name:t})}function QA(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)=>Ub[o]-Ub[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 kl(e,t=-1){let n=Object.create(null),r=[],o=null,i=e.pos,s=!1;for(;e.charCode()!==t;){let a=s?kl(e,Vb):ZA(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:QA(r,n)||" ",disallowEmpty:!1,explicit:!1}}function JA(e){let t;return e.eat(ks),t=kl(e,ki),e.eat(ki),t.explicit=!0,e.charCode()===Hb&&(e.pos++,t.disallowEmpty=!0),t}function ZA(e){let t=e.charCode();switch(t){case ki:break;case ks:return Qr(e,JA(e));case op:return e.nextCharCode()===Sl?qA(e):KA(e);case _b:return{type:"Combinator",value:e.substringToPos(e.pos+(e.nextCharCode()===_b?2:1))};case Nb:return e.pos++,e.eat(Nb),{type:"Combinator",value:"&&"};case rp:return e.pos++,{type:"Comma"};case Sl:return Qr(e,{type:"String",value:e.scanString()});case WA:case $A:case UA:case HA:case jA:return{type:"Spaces",value:e.scanSpaces()};case VA:return t=e.nextCharCode(),e.isNameCharCode(t)?(e.pos++,{type:"AtKeyword",name:e.scanWord()}):Ju(e);case Gb:case np:case wl:case tp:case Hb:break;case vl:if(t=e.nextCharCode(),t<48||t>57)return Ju(e);break;default:return e.isNameCharCode(t)?XA(e):Ju(e)}}function Cs(e){let t=new bl(e),n=kl(t);return t.pos!==e.length&&t.error("Unexpected input"),n.terms.length===1&&n.terms[0].type==="Group"?n.terms[0]:n}var $A,UA,jA,HA,WA,Hb,tp,Nb,Sl,Wb,Vb,Gb,np,rp,Ob,op,Zu,wl,VA,ks,ki,vl,_b,ep,$b,Ub,ip=$(()=>{"use strict";zb();$A=9,UA=10,jA=12,HA=13,WA=32,Hb=33,tp=35,Nb=38,Sl=39,Wb=40,Vb=41,Gb=42,np=43,rp=44,Ob=45,op=60,Zu=62,wl=63,VA=64,ks=91,ki=93,vl=123,_b=124,ep=125,$b=8734,Ub={" ":1,"&&":2,"||":3,"|":4}});function qb(e){return typeof e=="function"?e:Ts}function sp(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=Ts,i=Ts;if(typeof t=="function"?o=t:t&&(o=qb(t.enter),i=qb(t.leave)),o===Ts&&i===Ts)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");r(e,n)}var Ts,Yb=$(()=>{"use strict";Ts=function(){}});var ap=$(()=>{"use strict";Ou();ip();Yb()});function nP(e){let t=[];return yo(e,(n,r,o)=>t.push({type:n,value:e.slice(r,o),node:null})),t}function Kb(e,t){return typeof e=="string"?nP(e):t.generate(e,tP)}var tP,Xb=$(()=>{"use strict";rr();tP={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 yn(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)===rP&&e.charCodeAt(e.length-1)===oP}function Qb(e){return e.type==="Keyword"||e.type==="AtKeyword"||e.type==="Function"||e.type==="Type"&&Jb(e.name)}function So(e,t=" ",n=!1){return{type:"Group",terms:e,combinator:t,disallowEmpty:!1,explicit:n}}function Is(e,t,n=new Set){if(!n.has(e))switch(n.add(e),e.type){case"If":e.match=Is(e.match,t,n),e.then=Is(e.then,t,n),e.else=Is(e.else,t,n);break;case"Type":return t[e.name]||e}return e}function lp(e,t,n){switch(e){case" ":{let r=ut;for(let o=t.length-1;o>=0;o--){let i=t[o];r=yn(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(Qb(s)&&(o===null&&i>0&&Qb(t[i-1])&&(o=Object.create(null),r=yn({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=yn(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=lp(e,t.filter(function(a){return a!==i}),!1):s=ut,r=yn(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=lp(e,t.filter(function(a){return a!==i}),!0):s=ut,r=yn(i,s,r)}return r}}}function iP(e){let t=ut,n=Ci(e.term);if(e.max===0)n=yn(n,Cl,yt),t=yn(n,null,yt),t.then=yn(ut,ut,t),e.comma&&(t.then.else=yn({type:"Comma",syntax:e},t,yt));else for(let r=e.min||1;r<=e.max;r++)e.comma&&t!==ut&&(t=yn({type:"Comma",syntax:e},t,yt)),t=yn(n,yn(ut,ut,t),yt);if(e.min===0)t=yn(ut,ut,t);else for(let r=0;r<e.min-1;r++)e.comma&&t!==ut&&(t=yn({type:"Comma",syntax:e},t,yt)),t=yn(n,t,yt);return t}function Ci(e){if(typeof e=="function")return{type:"Generic",fn:e};switch(e.type){case"Group":{let t=lp(e.combinator,e.terms.map(Ci),!1);return e.disallowEmpty&&(t=yn(t,Cl,yt)),t}case"Multiplier":return iP(e);case"Boolean":{let t=Ci(e.term),n=Ci(So([So([{type:"Keyword",name:"not"},{type:"Type",name:"!boolean-group"}]),So([{type:"Type",name:"!boolean-group"},So([{type:"Multiplier",comma:!1,min:0,max:0,term:So([{type:"Keyword",name:"and"},{type:"Type",name:"!boolean-group"}])},{type:"Multiplier",comma:!1,min:0,max:0,term:So([{type:"Keyword",name:"or"},{type:"Type",name:"!boolean-group"}])}],"|")])],"|")),r=Ci(So([{type:"Type",name:"!term"},So([{type:"Token",value:"("},{type:"Type",name:"!self"},{type:"Token",value:")"}]),{type:"Type",name:"general-enclosed"}],"|"));return Is(r,{"!term":t,"!self":n}),Is(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 Fs(e,t){return typeof e=="string"&&(e=Cs(e)),{type:"MatchGraph",match:Ci(e),syntax:t||null,source:e}}var ut,yt,Cl,rP,oP,cp=$(()=>{"use strict";ip();ut={type:"Match"},yt={type:"Mismatch"},Cl={type:"DisallowEmpty"},rP=40,oP=41});function pP(e){let t=null,n=null,r=e;for(;r!==null;)n=r.prev,r.prev=t,t=r,r=n;return t}function up(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 dP(e){return e.type!==9?!1:e.value!=="?"}function n0(e){return e===null?!0:e.type===18||e.type===2||e.type===21||e.type===19||e.type===23||dP(e)}function r0(e){return e===null?!0:e.type===22||e.type===20||e.type===24||e.type===9&&e.value==="/"}function gP(e,t,n){function r(){do I++,E=I<e.length?e[I]:null;while(E!==null&&(E.type===13||E.type===25))}function o(_){let P=I+_;return P<e.length?e[P]:null}function i(_,P){return{nextState:_,matchStack:R,syntaxStack:p,thenStack:g,tokenIndex:I,prev:P}}function s(_){g={nextState:_,matchStack:R,syntaxStack:p,prev:g}}function a(_){d=i(_,d)}function u(){R={type:aP,syntax:t.syntax,token:E,prev:R},r(),m=null,I>D&&(D=I)}function c(){p={syntax:t.syntax,opts:t.syntax.opts||p!==null&&p.opts||null,prev:p},R={type:pp,syntax:t.syntax,token:R.token,prev:R}}function l(){R.type===pp?R=R.prev:R={type:o0,syntax:p.syntax,token:R.token,prev:R},p=p.prev}let p=null,g=null,d=null,m=null,C=0,T=null,E=null,I=-1,D=0,R={type:sP,syntax:null,token:null,prev:null};for(r();T===null&&++C<t0;)switch(t.type){case"Match":if(g===null){if(E!==null&&(I!==e.length-1||E.value!=="\\0"&&E.value!=="\\9")){t=yt;break}T=e0;break}if(t=g.nextState,t===Cl)if(g.matchStack===R){t=yt;break}else t=ut;for(;g.syntaxStack!==p;)l();g=g.prev;break;case"Mismatch":if(m!==null&&m!==!1)(d===null||I>d.tokenIndex)&&(d=m,m=!1);else if(d===null){T=lP;break}t=d.nextState,g=d.thenStack,p=d.syntaxStack,R=d.matchStack,I=d.tokenIndex,E=I<e.length?e[I]:null,d=d.prev;break;case"MatchGraph":t=t.match;break;case"If":t.else!==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 z=t.syntax.terms;if(t.index===z.length){if(t.mask===0||t.syntax.all){t=yt;break}t=ut;break}if(t.mask===(1<<z.length)-1){t=ut;break}for(;t.index<z.length;t.index++){let x=1<<t.index;if((t.mask&x)===0){a(t),s({type:"AddMatchOnce",syntax:t.syntax,mask:t.mask|x}),t=z[t.index++];break}}break}case"AddMatchOnce":t={type:"MatchOnceBuffer",syntax:t.syntax,index:0,mask:t.mask};break;case"Enum":if(E!==null){let z=E.value.toLowerCase();if(z.indexOf("\\")!==-1&&(z=z.replace(/\\[09].*$/,"")),Zb.call(t.map,z)){t=t.map[z];break}}t=yt;break;case"Generic":{let z=p!==null?p.opts:null,x=I+Math.floor(t.fn(E,o,z));if(!isNaN(x)&&x>I){for(;I<x;)u();t=ut}else t=yt;break}case"Type":case"Property":{let z=t.type==="Type"?"types":"properties",x=Zb.call(n,z)?n[z][t.name]:null;if(!x||!x.match)throw new Error("Bad syntax reference: "+(t.type==="Type"?"<"+t.name+">":"<'"+t.name+"'>"));if(m!==!1&&E!==null&&t.type==="Type"&&(t.name==="custom-ident"&&E.type===1||t.name==="length"&&E.value==="0")){m===null&&(m=i(t,d)),t=yt;break}c(),t=x.matchRef||x.match;break}case"Keyword":{let z=t.name;if(E!==null){let x=E.value;if(x.indexOf("\\")!==-1&&(x=x.replace(/\\[09].*$/,"")),up(x,z)){u(),t=ut;break}}t=yt;break}case"AtKeyword":case"Function":if(E!==null&&up(E.value,t.name)){u(),t=ut;break}t=yt;break;case"Token":if(E!==null&&E.value===t.value){u(),t=ut;break}t=yt;break;case"Comma":E!==null&&E.type===18?n0(R.token)?t=yt:(u(),t=r0(E)?yt:ut):t=n0(R.token)||r0(E)?ut:yt;break;case"String":let _="",P=I;for(;P<e.length&&_.length<t.value.length;P++)_+=e[P].value;if(up(_,t.value)){for(;I<P;)u();t=ut}else t=yt;break;default:throw new Error("Unknown node type: "+t.type)}switch(uP+=C,T){case null:console.warn("[csstree-match] BREAK after "+t0+" iterations"),T=cP,R=null;break;case e0:for(;p!==null;)l();break;default:R=null}return{tokens:e,reason:T,iterations:C,match:R,longestMatch:D}}function dp(e,t,n){let r=gP(e,t,n||{});if(r.match===null)return r;let o=r.match,i=r.match={syntax:t.syntax||null,match:[]},s=[i];for(o=pP(o).prev;o!==null;){switch(o.type){case pp:i.match.push(i={syntax:o.syntax,match:[]}),s.push(i);break;case o0: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 Zb,sP,aP,pp,o0,e0,lP,cP,t0,uP,i0=$(()=>{"use strict";cp();({hasOwnProperty:Zb}=Object.prototype),sP=0,aP=1,pp=2,o0=3,e0="Match",lP="Mismatch",cP="Maximum iteration number exceeded (please fill an issue on https://github.com/csstree/csstree/issues)",t0=15e3,uP=0});var fp={};Se(fp,{getTrace:()=>s0,isKeyword:()=>hP,isProperty:()=>mP,isType:()=>fP});function s0(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 fP(e,t){return gp(this,e,n=>n.type==="Type"&&n.name===t)}function mP(e,t){return gp(this,e,n=>n.type==="Property"&&n.name===t)}function hP(e){return gp(this,e,t=>t.type==="Keyword")}function gp(e,t,n){let r=s0.call(e,t);return r===null?!1:r.some(n)}var a0=$(()=>{"use strict"});function l0(e){return"node"in e?e.node:l0(e.match[0])}function c0(e){return"node"in e?e.node:c0(e.match[e.match.length-1])}function mp(e,t,n,r,o){function i(a){if(a.syntax!==null&&a.syntax.type===r&&a.syntax.name===o){let u=l0(a),c=c0(a);e.syntax.walk(t,function(l,p,g){if(l===u){let d=new qn;do{if(d.appendData(p.data),p.data===c)break;p=p.next}while(p!==null);s.push({parent:g,nodes:d})}})}Array.isArray(a.match)&&a.match.forEach(i)}let s=[];return n.matched!==null&&i(n.matched),s}var u0=$(()=>{"use strict";ms()});function hp(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e&&e>=0}function p0(e){return!!e&&hp(e.offset)&&hp(e.line)&&hp(e.column)}function xP(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(Es.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(!p0(r.loc.start))i+=".start";else if(!p0(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 qn)}}}else o(r,"Unknown field `"+i+"` for "+e+" node type");s||o(r,"Bad value for `"+e+"."+i+"`")}}for(let i in t)Es.call(t,i)&&Es.call(r,i)===!1&&o(r,"Field `"+e+"."+i+"` is missed")}}function d0(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<"+(d0(o,t)||"any")+">");else throw new Error("Wrong value `"+o+"` in `"+t+"` structure definition")}return n.join(" | ")}function yP(e,t){let n=t.structure,r={type:String,loc:!0},o={type:'"'+e+'"'};for(let i in n){if(Es.call(n,i)===!1)continue;let s=r[i]=Array.isArray(n[i])?n[i].slice():[n[i]];o[i]=d0(s,e+"."+i)}return{docs:o,check:xP(e,r)}}function g0(e){let t={};if(e.node){for(let n in e.node)if(Es.call(e.node,n)){let r=e.node[n];if(r.structure)t[n]=yP(n,r);else throw new Error("Missed `structure` field in `"+n+"` node type definition")}}return t}var Es,f0=$(()=>{"use strict";ms();({hasOwnProperty:Es}=Object.prototype)});function xp(e,t,n){let r={};for(let o in e)e[o].syntax&&(r[o]=n?e[o].syntax:yi(e[o].syntax,{compact:t}));return r}function bP(e,t,n){let r={};for(let[o,i]of Object.entries(e))r[o]={prelude:i.prelude&&(n?i.prelude.syntax:yi(i.prelude.syntax,{compact:t})),descriptors:i.descriptors&&xp(i.descriptors,t,n)};return r}function SP(e){for(let t=0;t<e.length;t++)if(e[t].value.toLowerCase()==="var(")return!0;return!1}function wP(e){let t=e.terms[0];return e.explicit===!1&&e.terms.length===1&&t.type==="Multiplier"&&t.comma===!0}function wr(e,t,n){return{matched:e,iterations:n,error:t,...fp}}function Ti(e,t,n,r){let o=Kb(n,e.syntax),i;return SP(o)?wr(null,new Error("Matching for a tree with var() is not supported")):(r&&(i=dp(o,e.cssWideKeywordsSyntax,e)),(!r||!i.match)&&(i=dp(o,t.match,e),!i.match)?wr(null,new xb(i.reason,t.syntax,n,i),i.iterations):wr(i.match,null,i.iterations))}var As,m0=$(()=>{"use strict";yb();fl();ml();Lb();Mb();ap();Xb();cp();i0();a0();u0();f0();As=class{constructor(t,n,r){if(this.cssWideKeywords=wi,this.syntax=n,this.generic=!1,this.units={...yl},this.atrules=Object.create(null),this.properties=Object.create(null),this.types=Object.create(null),this.structure=r||g0(t),t){if(t.cssWideKeywords&&(this.cssWideKeywords=t.cssWideKeywords),t.units)for(let o of Object.keys(yl))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(Pb(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=Fs(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=Fs(t,i):(typeof t=="string"?Object.defineProperty(s,"syntax",{get(){return Object.defineProperty(s,"syntax",{value:Cs(t)}),s.syntax}}):s.syntax=t,Object.defineProperty(s,"match",{get(){return Object.defineProperty(s,"match",{value:Fs(s.syntax,i)}),s.match}}),n==="Property"&&Object.defineProperty(s,"matchRef",{get(){let a=s.syntax,u=wP(a)?Fs({...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 bi("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&&!Ti(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=dl(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 bi("Unknown at-rule descriptor",n)}checkPropertyName(t){if(!this.getProperty(t))return new bi("Unknown property",t)}matchAtrulePrelude(t,n){let r=this.checkAtrulePrelude(t,n);if(r)return wr(null,r);let o=this.getAtrule(t);return o.prelude?Ti(this,o.prelude,n||"",!1):wr(null,null)}matchAtruleDescriptor(t,n,r){let o=this.checkAtruleDescriptorName(t,n);if(o)return wr(null,o);let i=this.getAtrule(t),s=dl(n);return Ti(this,i.descriptors[s.name]||i.descriptors[s.basename],r,!1)}matchDeclaration(t){return t.type!=="Declaration"?wr(null,new Error("Not a Declaration node")):this.matchProperty(t.property,t.value)}matchProperty(t,n){if(_u(t).custom)return wr(null,new Error("Lexer matching doesn't applicable for custom properties"));let r=this.checkPropertyName(t);return r?wr(null,r):Ti(this,this.getProperty(t),n,!0)}matchType(t,n){let r=this.getType(t);return r?Ti(this,r,n,!1):wr(null,new bi("Unknown type",t))}match(t,n){return typeof t!="string"&&(!t||!t.type)?wr(null,new bi("Bad syntax")):((typeof t=="string"||!t.match)&&(t=this.createDescriptor(t,"Type","anonymous")),Ti(this,t,n,!1))}findValueFragments(t,n,r,o){return mp(this,n,this.matchProperty(t,n),r,o)}findDeclarationValueFragments(t,n,r){return mp(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=dl(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=_u(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&&sp(p.syntax,function(g){if(g.type!=="Type"&&g.type!=="Property")return;let d=g.type==="Type"?u.types:u.properties,m=g.type==="Type"?o:i;hasOwnProperty.call(d,g.name)?n(u,g.name,m,d[g.name])&&(r.push(`${t(c,l===o)} used broken syntax definition ${t(g.name,g.type==="Type")}`),l.set(c,!0)):(r.push(`${t(c,l===o)} used missed syntax definition ${t(g.name,g.type==="Type")}`),l.set(c,!0))},this)}let r=[],o=new Map,i=new Map;for(let u in this.types)n(this,u,o,this.types[u]);for(let u in this.properties)n(this,u,i,this.properties[u]);let s=[...o.keys()].filter(u=>o.get(u)),a=[...i.keys()].filter(u=>i.get(u));return s.length||a.length?{errors:r,types:s,properties:a}:null}dump(t,n){return{generic:this.generic,cssWideKeywords:this.cssWideKeywords,units:this.units,types:xp(this.types,!n,t),properties:xp(this.properties,!n,t),atrules:bP(this.atrules,!n,t)}}toString(){return JSON.stringify(this.dump())}}});function yp(e,t){return typeof t=="string"&&/^\s*\|/.test(t)?typeof e=="string"?e+t:t.replace(/^\s*\|\s*/,""):t||null}function vP(e,t){let n=Object.create(null);for(let r of Object.keys(e))t.includes(r)&&(n[r]=e[r]);return n}function bp(e,t,n){let r={...e};for(let[o,i]of Object.entries(t))r[o]={...r[o],...n?vP(i,n):i};return r}function Ps(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?yp(u.prelude,s.prelude):u.prelude||null;for(let[c,l]of Object.entries(s.descriptors||{}))u.descriptors[c]=l?yp(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]=yp(n[r][i],s);break;case"parseContext":n[r]={...e[r],...o};break;case"scope":case"features":n[r]=bp(e[r],o);break;case"atrule":case"pseudo":n[r]=bp(e[r],o,["parse"]);break;case"node":n[r]=bp(e[r],o,["name","structure","parse","generate","walkContext"]);break}return n}var h0=$(()=>{"use strict"});function x0(e){let t=My(e),n=fb(e),r=sb(e),{fromPlainObject:o,toPlainObject:i}=lb(n),s={lexer:null,createLexer:a=>new As(a,s,s.lexer.structure),tokenize:yo,parse:t,generate:r,walk:n,find:n.find,findLast:n.findLast,findAll:n.findAll,fromPlainObject:o,toPlainObject:i,fork(a){let u=Ps({},e);return x0(typeof a=="function"?a(u):Ps(u,a))}};return s.lexer=new As({generic:e.generic,cssWideKeywords:e.cssWideKeywords,units:e.units,types:e.types,atrules:e.atrules,properties:e.properties,node:e.node},s),s}var y0,b0=$(()=>{"use strict";rr();By();ab();cb();mb();m0();h0();y0=e=>x0(Ps({},e))});var S0,w0=$(()=>{"use strict";S0={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 vp={};Se(vp,{generate:()=>IP,name:()=>CP,parse:()=>wp,structure:()=>TP});function Il(e,t){let n=this.tokenStart+e,r=this.charCodeAt(n);for((r===zr||r===Yn)&&(t&&this.error("Number sign is not allowed"),n++);n<this.tokenEnd;n++)$t(this.charCodeAt(n))||this.error("Integer is expected",n)}function Ii(e){return Il.call(this,0,e)}function wo(e,t){if(!this.cmpChar(this.tokenStart+e,t)){let n="";switch(t){case Tl:n="N is expected";break;case Yn:n="HyphenMinus is expected";break}this.error(n,this.tokenStart+e)}}function Sp(){let e=0,t=0,n=this.tokenType;for(;n===13||n===25;)n=this.lookupType(++e);if(n!==10)if(this.isDelim(zr,e)||this.isDelim(Yn,e)){t=this.isDelim(zr,e)?zr:Yn;do n=this.lookupType(++e);while(n===13||n===25);n!==10&&(this.skip(e),Ii.call(this,qo))}else return null;return e>0&&this.skip(e),t===0&&(n=this.charCodeAt(this.tokenStart),n!==zr&&n!==Yn&&this.error("Number sign is expected")),Ii.call(this,t!==0),t===Yn?"-"+this.consume(10):this.consume(10)}function wp(){let e=this.tokenStart,t=null,n=null;if(this.tokenType===10)Ii.call(this,kP),n=this.consume(10);else if(this.tokenType===1&&this.cmpChar(this.tokenStart,Yn))switch(t="-1",wo.call(this,1,Tl),this.tokenEnd-this.tokenStart){case 2:this.next(),n=Sp.call(this);break;case 3:wo.call(this,2,Yn),this.next(),this.skipSC(),Ii.call(this,qo),n="-"+this.consume(10);break;default:wo.call(this,2,Yn),Il.call(this,3,qo),this.next(),n=this.substrToCursor(e+2)}else if(this.tokenType===1||this.isDelim(zr)&&this.lookupType(1)===1){let r=0;switch(t="1",this.isDelim(zr)&&(r=1,this.next()),wo.call(this,0,Tl),this.tokenEnd-this.tokenStart){case 1:this.next(),n=Sp.call(this);break;case 2:wo.call(this,1,Yn),this.next(),this.skipSC(),Ii.call(this,qo),n="-"+this.consume(10);break;default:wo.call(this,1,Yn),Il.call(this,2,qo),this.next(),n=this.substrToCursor(e+r+1)}}else if(this.tokenType===12){let r=this.charCodeAt(this.tokenStart),o=r===zr||r===Yn,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),wo.call(this,i-this.tokenStart,Tl),t=this.substring(e,i),i+1===this.tokenEnd?(this.next(),n=Sp.call(this)):(wo.call(this,i-this.tokenStart+1,Yn),i+2===this.tokenEnd?(this.next(),this.skipSC(),Ii.call(this,qo),n="-"+this.consume(10)):(Il.call(this,i-this.tokenStart+2,qo),this.next(),n=this.substrToCursor(i+1)))}else this.error();return t!==null&&t.charCodeAt(0)===zr&&(t=t.substr(1)),n!==null&&n.charCodeAt(0)===zr&&(n=n.substr(1)),{type:"AnPlusB",loc:this.getLocation(e,this.tokenStart),a:t,b:n}}function IP(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 zr,Yn,Tl,qo,kP,CP,TP,kp=$(()=>{"use strict";rr();zr=43,Yn=45,Tl=110,qo=!0,kP=!1;CP="AnPlusB",TP={a:[String,null],b:[String,null]}});var Tp={};Se(Tp,{generate:()=>LP,name:()=>EP,parse:()=>Cp,structure:()=>PP,walkContext:()=>AP});function v0(){return this.Raw(this.consumeUntilLeftCurlyBracketOrSemicolon,!0)}function FP(){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 Cp(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),v0):o=v0.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(FP.call(this));break}return{type:"Atrule",loc:this.getLocation(t,this.tokenStart),name:n,prelude:o,block:i}}function LP(e){this.token(3,"@"+e.name),e.prelude!==null&&this.node(e.prelude),e.block?this.node(e.block):this.token(17,";")}var EP,AP,PP,Ip=$(()=>{"use strict";EP="Atrule",AP="atrule",PP={name:String,prelude:["AtrulePrelude","Raw",null],block:["Block",null]}});var Ep={};Se(Ep,{generate:()=>RP,name:()=>MP,parse:()=>Fp,structure:()=>DP,walkContext:()=>BP});function Fp(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 RP(e){this.children(e)}var MP,BP,DP,Ap=$(()=>{"use strict";MP="AtrulePrelude",BP="atrulePrelude",DP={children:[[]]}});var Mp={};Se(Mp,{generate:()=>HP,name:()=>UP,parse:()=>Lp,structure:()=>jP});function _P(){this.eof&&this.error("Unexpected end of input");let e=this.tokenStart,t=!1;return this.isDelim(k0)?(t=!0,this.next()):this.isDelim(Pp)||this.eat(1),this.isDelim(Pp)?this.charCodeAt(this.tokenStart+1)!==Fl?(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 $P(){let e=this.tokenStart,t=this.charCodeAt(e);return t!==Fl&&t!==OP&&t!==NP&&t!==zP&&t!==k0&&t!==Pp&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),t!==Fl&&(this.isDelim(Fl)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(e)}function Lp(){let e=this.tokenStart,t,n=null,r=null,o=null;return this.eat(19),this.skipSC(),t=_P.call(this),this.skipSC(),this.tokenType!==20&&(this.tokenType!==1&&(n=$P.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 HP(e){this.token(9,"["),this.node(e.name),e.matcher!==null&&(this.tokenize(e.matcher),this.node(e.value)),e.flags!==null&&this.token(1,e.flags),this.token(9,"]")}var zP,k0,Fl,NP,Pp,OP,UP,jP,Bp=$(()=>{"use strict";zP=36,k0=42,Fl=61,NP=94,Pp=124,OP=126;UP="AttributeSelector",jP={name:"Identifier",matcher:[String,null],value:["String","Identifier",null],flags:[String,null]}});var Rp={};Se(Rp,{generate:()=>KP,name:()=>GP,parse:()=>Dp,structure:()=>YP,walkContext:()=>qP});function I0(){return this.Raw(null,!0)}function C0(){return this.parseWithFallback(this.Rule,I0)}function T0(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function VP(){if(this.tokenType===17)return T0.call(this,this.tokenIndex);let e=this.parseWithFallback(this.Declaration,T0);return this.tokenType===17&&this.next(),e}function Dp(e){let t=e?VP:C0,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),I0));break;default:e&&this.isDelim(WP)?r.push(C0.call(this)):r.push(t.call(this))}return this.eof||this.eat(24),{type:"Block",loc:this.getLocation(n,this.tokenStart),children:r}}function KP(e){this.token(23,"{"),this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")}),this.token(24,"}")}var WP,GP,qP,YP,zp=$(()=>{"use strict";WP=38;GP="Block",qP="block",YP={children:[["Atrule","Rule","Declaration"]]}});var Op={};Se(Op,{generate:()=>JP,name:()=>XP,parse:()=>Np,structure:()=>QP});function Np(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 JP(e){this.token(9,"["),this.children(e),this.token(9,"]")}var XP,QP,_p=$(()=>{"use strict";XP="Brackets",QP={children:[[]]}});var Up={};Se(Up,{generate:()=>t2,name:()=>ZP,parse:()=>$p,structure:()=>e2});function $p(){let e=this.tokenStart;return this.eat(15),{type:"CDC",loc:this.getLocation(e,this.tokenStart)}}function t2(){this.token(15,"-->")}var ZP,e2,jp=$(()=>{"use strict";ZP="CDC",e2=[]});var Wp={};Se(Wp,{generate:()=>o2,name:()=>n2,parse:()=>Hp,structure:()=>r2});function Hp(){let e=this.tokenStart;return this.eat(14),{type:"CDO",loc:this.getLocation(e,this.tokenStart)}}function o2(){this.token(14,"<!--")}var n2,r2,Vp=$(()=>{"use strict";n2="CDO",r2=[]});var qp={};Se(qp,{generate:()=>l2,name:()=>s2,parse:()=>Gp,structure:()=>a2});function Gp(){return this.eatDelim(i2),{type:"ClassSelector",loc:this.getLocation(this.tokenStart-1,this.tokenEnd),name:this.consume(1)}}function l2(e){this.token(9,"."),this.token(1,e.name)}var i2,s2,a2,Yp=$(()=>{"use strict";i2=46,s2="ClassSelector",a2={name:String}});var Xp={};Se(Xp,{generate:()=>f2,name:()=>d2,parse:()=>Kp,structure:()=>g2});function Kp(){let e=this.tokenStart,t;switch(this.tokenType){case 13:t=" ";break;case 9:switch(this.charCodeAt(this.tokenStart)){case u2:case c2:case p2:this.next();break;case F0:this.next(),this.eatIdent("deep"),this.eatDelim(F0);break;default:this.error("Combinator is expected")}t=this.substrToCursor(e);break}return{type:"Combinator",loc:this.getLocation(e,this.tokenStart),name:t}}function f2(e){this.tokenize(e.name)}var c2,F0,u2,p2,d2,g2,Qp=$(()=>{"use strict";c2=43,F0=47,u2=62,p2=126,d2="Combinator",g2={name:String}});var Zp={};Se(Zp,{generate:()=>b2,name:()=>x2,parse:()=>Jp,structure:()=>y2});function Jp(){let e=this.tokenStart,t=this.tokenEnd;return this.eat(25),t-e+2>=2&&this.charCodeAt(t-2)===m2&&this.charCodeAt(t-1)===h2&&(t-=2),{type:"Comment",loc:this.getLocation(e,this.tokenStart),value:this.substring(e+2,t)}}function b2(e){this.token(25,"/*"+e.value+"*/")}var m2,h2,x2,y2,ed=$(()=>{"use strict";m2=42,h2=47,x2="Comment",y2={value:String}});var nd={};Se(nd,{generate:()=>C2,name:()=>w2,parse:()=>td,structure:()=>v2});function E0(e){return this.lookupTypeNonSC(1)===1&&S2.has(this.lookupTypeNonSC(2))?this.Feature(e):this.FeatureRange(e)}function td(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(()=>k2[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 C2(e){e.children.forEach(t=>{t.type==="Condition"?(this.token(21,"("),this.node(t),this.token(22,")")):this.node(t)})}var S2,w2,v2,k2,rd=$(()=>{"use strict";S2=new Set([16,22,0]),w2="Condition",v2={kind:String,children:[["Identifier","Feature","FeatureFunction","FeatureRange","SupportsDeclaration"]]};k2={media:E0,container:E0,supports(){return this.SupportsDeclaration()}}});var id={};Se(id,{generate:()=>z2,name:()=>B2,parse:()=>od,structure:()=>R2,walkContext:()=>D2});function P2(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!0)}function L2(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1)}function M2(){let e=this.tokenIndex,t=this.Value();return t.type!=="Raw"&&this.eof===!1&&this.tokenType!==17&&this.isDelim(P0)===!1&&this.isBalanceEdge(e)===!1&&this.error(),t}function od(){let e=this.tokenStart,t=this.tokenIndex,n=N2.call(this),r=gl(n),o=r?this.parseCustomProperty:this.parseValue,i=r?L2:P2,s=!1,a;this.skipSC(),this.eat(16);let u=this.tokenIndex;if(r||this.skipSC(),o?a=this.parseWithFallback(M2,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(P0)&&(s=O2.call(this),this.skipSC()),this.eof===!1&&this.tokenType!==17&&this.isBalanceEdge(t)===!1&&this.error(),{type:"Declaration",loc:this.getLocation(e,this.tokenStart),important:s,property:n,value:a}}function z2(e){this.token(1,e.property),this.token(16,":"),this.node(e.value),e.important&&(this.token(9,"!"),this.token(1,e.important===!0?"important":e.important))}function N2(){let e=this.tokenStart;if(this.tokenType===9)switch(this.charCodeAt(this.tokenStart)){case E2:case I2:case A2:case T2:case F2:this.next();break;case A0:this.next(),this.isDelim(A0)&&this.next();break}return this.tokenType===4?this.eat(4):this.eat(1),this.substrToCursor(e)}function O2(){this.eat(9),this.skipSC();let e=this.consume(1);return e==="important"?!0:e}var P0,T2,I2,F2,E2,A2,A0,B2,D2,R2,sd=$(()=>{"use strict";fl();P0=33,T2=35,I2=36,F2=38,E2=42,A2=43,A0=47;B2="Declaration",D2="declaration",R2={important:[Boolean,String],property:String,value:["Value","Raw"]}});var cd={};Se(cd,{generate:()=>j2,name:()=>$2,parse:()=>ld,structure:()=>U2});function ad(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function ld(){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),ad));break;default:this.isDelim(_2)?e.push(this.parseWithFallback(this.Rule,ad)):e.push(this.parseWithFallback(this.Declaration,ad))}return{type:"DeclarationList",loc:this.getLocationFromList(e),children:e}}function j2(e){this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")})}var _2,$2,U2,ud=$(()=>{"use strict";_2=38;$2="DeclarationList",U2={children:[["Declaration","Atrule","Rule"]]}});var dd={};Se(dd,{generate:()=>V2,name:()=>H2,parse:()=>pd,structure:()=>W2});function pd(){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 V2(e){this.token(12,e.value+e.unit)}var H2,W2,gd=$(()=>{"use strict";H2="Dimension",W2={value:String,unit:String}});var md={};Se(md,{generate:()=>K2,name:()=>q2,parse:()=>fd,structure:()=>Y2});function fd(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(G2)&&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 K2(e){this.token(21,"("),this.token(1,e.name),e.value!==null&&(this.token(16,":"),this.node(e.value)),this.token(22,")")}var G2,q2,Y2,hd=$(()=>{"use strict";G2=47,q2="Feature",Y2={kind:String,name:String,value:["Identifier","Number","Dimension","Ratio","Function",null]}});var yd={};Se(yd,{generate:()=>Z2,name:()=>X2,parse:()=>xd,structure:()=>Q2});function J2(e,t){let r=(this.features[e]||{})[t];return typeof r!="function"&&this.error(`Unknown feature ${t}()`),r}function xd(e="unknown"){let t=this.tokenStart,n=this.consumeFunctionName(),r=J2.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 Z2(e){this.token(2,e.feature+"("),this.node(e.value),this.token(22,")")}var X2,Q2,bd=$(()=>{"use strict";X2="FeatureFunction",Q2={kind:String,feature:String,value:["Declaration","Selector"]}});var vd={};Se(vd,{generate:()=>oL,name:()=>nL,parse:()=>wd,structure:()=>rL});function Sd(){switch(this.skipSC(),this.tokenType){case 10:return this.isDelim(L0,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(L0)&&this.error(),e},()=>this.Ratio());default:this.error("Number, dimension, ratio or identifier is expected")}}function B0(e){if(this.skipSC(),this.isDelim(eL)||this.isDelim(tL)){let t=this.source[this.tokenStart];return this.next(),this.isDelim(M0)?(this.next(),t+"="):t}if(this.isDelim(M0))return"=";this.error(`Expected ${e?'":", ':""}"<", ">", "=" or ")"`)}function wd(e="unknown"){let t=this.tokenStart;this.skipSC(),this.eat(21);let n=Sd.call(this),r=B0.call(this,n.type==="Identifier"),o=Sd.call(this),i=null,s=null;return this.lookupNonWSType(0)!==22&&(i=B0.call(this),s=Sd.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 oL(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 L0,eL,M0,tL,nL,rL,kd=$(()=>{"use strict";L0=47,eL=60,M0=61,tL=62,nL="FeatureRange",rL={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 Td={};Se(Td,{generate:()=>lL,name:()=>iL,parse:()=>Cd,structure:()=>aL,walkContext:()=>sL});function Cd(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 lL(e){this.token(2,e.name+"("),this.children(e),this.token(22,")")}var iL,sL,aL,Id=$(()=>{"use strict";iL="Function",sL="function",aL={name:String,children:[[]]}});var Ed={};Se(Ed,{generate:()=>pL,name:()=>cL,parse:()=>Fd,structure:()=>uL});function Fd(e){let t=this.tokenStart,n=null;this.tokenType===2?n=this.consumeFunctionName():this.eat(21);let r=this.parseWithFallback(()=>{let o=this.tokenIndex,i=this.readSequence(this.scope.Value);return this.eof===!1&&this.isBalanceEdge(o)===!1&&this.error(),i},()=>this.createSingleNodeList(this.Raw(null,!1)));return this.eof||this.eat(22),{type:"GeneralEnclosed",loc:this.getLocation(t,this.tokenStart),kind:e,function:n,children:r}}function pL(e){e.function?this.token(2,e.function+"("):this.token(21,"("),this.children(e),this.token(22,")")}var cL,uL,Ad=$(()=>{"use strict";cL="GeneralEnclosed",uL={kind:String,function:[String,null],children:[[]]}});var Ld={};Se(Ld,{generate:()=>mL,name:()=>gL,parse:()=>Pd,structure:()=>fL,xxx:()=>dL});function Pd(){let e=this.tokenStart;return this.eat(4),{type:"Hash",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e+1)}}function mL(e){this.token(4,"#"+e.value)}var dL,gL,fL,Md=$(()=>{"use strict";dL="XXX",gL="Hash",fL={value:String}});var Dd={};Se(Dd,{generate:()=>yL,name:()=>hL,parse:()=>Bd,structure:()=>xL});function Bd(){return{type:"Identifier",loc:this.getLocation(this.tokenStart,this.tokenEnd),name:this.consume(1)}}function yL(e){this.token(1,e.name)}var hL,xL,Rd=$(()=>{"use strict";hL="Identifier",xL={name:String}});var Nd={};Se(Nd,{generate:()=>wL,name:()=>bL,parse:()=>zd,structure:()=>SL});function zd(){let e=this.tokenStart;return this.eat(4),{type:"IdSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e+1)}}function wL(e){this.token(9,"#"+e.name)}var bL,SL,Od=$(()=>{"use strict";bL="IdSelector",SL={name:String}});var $d={};Se($d,{generate:()=>TL,name:()=>kL,parse:()=>_d,structure:()=>CL});function _d(){let e=this.tokenStart,t=this.consume(1);for(;this.isDelim(vL);)this.eat(9),t+="."+this.consume(1);return{type:"Layer",loc:this.getLocation(e,this.tokenStart),name:t}}function TL(e){this.tokenize(e.name)}var vL,kL,CL,Ud=$(()=>{"use strict";vL=46,kL="Layer",CL={name:String}});var Hd={};Se(Hd,{generate:()=>EL,name:()=>IL,parse:()=>jd,structure:()=>FL});function jd(){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 EL(e){this.children(e,()=>this.token(18,","))}var IL,FL,Wd=$(()=>{"use strict";IL="LayerList",FL={children:[["Layer"]]}});var Gd={};Se(Gd,{generate:()=>LL,name:()=>AL,parse:()=>Vd,structure:()=>PL});function Vd(){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 LL(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 AL,PL,qd=$(()=>{"use strict";AL="MediaQuery",PL={modifier:[String,null],mediaType:[String,null],condition:["Condition",null]}});var Kd={};Se(Kd,{generate:()=>DL,name:()=>ML,parse:()=>Yd,structure:()=>BL});function Yd(){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 DL(e){this.children(e,()=>this.token(18,","))}var ML,BL,Xd=$(()=>{"use strict";ML="MediaQueryList",BL={children:[["MediaQuery"]]}});var Jd={};Se(Jd,{generate:()=>OL,name:()=>zL,parse:()=>Qd,structure:()=>NL});function Qd(){let e=this.tokenStart;return this.eatDelim(RL),{type:"NestingSelector",loc:this.getLocation(e,this.tokenStart)}}function OL(){this.token(9,"&")}var RL,zL,NL,Zd=$(()=>{"use strict";RL=38,zL="NestingSelector",NL={}});var tg={};Se(tg,{generate:()=>UL,name:()=>_L,parse:()=>eg,structure:()=>$L});function eg(){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 UL(e){this.node(e.nth),e.selector!==null&&(this.token(1,"of"),this.node(e.selector))}var _L,$L,ng=$(()=>{"use strict";_L="Nth",$L={nth:["AnPlusB","Identifier"],selector:["SelectorList",null]}});var og={};Se(og,{generate:()=>WL,name:()=>jL,parse:()=>rg,structure:()=>HL});function rg(){return{type:"Number",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consume(10)}}function WL(e){this.token(10,e.value)}var jL,HL,ig=$(()=>{"use strict";jL="Number",HL={value:String}});var ag={};Se(ag,{generate:()=>qL,name:()=>VL,parse:()=>sg,structure:()=>GL});function sg(){let e=this.tokenStart;return this.next(),{type:"Operator",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function qL(e){this.tokenize(e.value)}var VL,GL,lg=$(()=>{"use strict";VL="Operator",GL={value:String}});var ug={};Se(ug,{generate:()=>XL,name:()=>YL,parse:()=>cg,structure:()=>KL});function cg(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 XL(e){this.token(21,"("),this.children(e),this.token(22,")")}var YL,KL,pg=$(()=>{"use strict";YL="Parentheses",KL={children:[[]]}});var gg={};Se(gg,{generate:()=>ZL,name:()=>QL,parse:()=>dg,structure:()=>JL});function dg(){return{type:"Percentage",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consumeNumber(11)}}function ZL(e){this.token(11,e.value+"%")}var QL,JL,fg=$(()=>{"use strict";QL="Percentage",JL={value:String}});var hg={};Se(hg,{generate:()=>rM,name:()=>eM,parse:()=>mg,structure:()=>nM,walkContext:()=>tM});function mg(){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 rM(e){this.token(16,":"),e.children===null?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"))}var eM,tM,nM,xg=$(()=>{"use strict";eM="PseudoClassSelector",tM="function",nM={name:String,children:[["Raw"],null]}});var bg={};Se(bg,{generate:()=>aM,name:()=>oM,parse:()=>yg,structure:()=>sM,walkContext:()=>iM});function yg(){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 aM(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 oM,iM,sM,Sg=$(()=>{"use strict";oM="PseudoElementSelector",iM="function",sM={name:String,children:[["Raw"],null]}});var vg={};Se(vg,{generate:()=>uM,name:()=>lM,parse:()=>wg,structure:()=>cM});function R0(){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 wg(){let e=this.tokenStart,t=R0.call(this),n=null;return this.skipSC(),this.isDelim(D0)&&(this.eatDelim(D0),n=R0.call(this)),{type:"Ratio",loc:this.getLocation(e,this.tokenStart),left:t,right:n}}function uM(e){this.node(e.left),this.token(9,"/"),e.right?this.node(e.right):this.node(10,1)}var D0,lM,cM,kg=$(()=>{"use strict";D0=47;lM="Ratio",cM={left:["Number","Function"],right:["Number","Function",null]}});var Tg={};Se(Tg,{generate:()=>fM,name:()=>dM,parse:()=>Cg,structure:()=>gM});function pM(){return this.tokenIndex>0&&this.lookupType(-1)===13?this.tokenIndex>1?this.getTokenStart(this.tokenIndex-1):this.firstCharOffset:this.tokenStart}function Cg(e,t){let n=this.getTokenStart(this.tokenIndex),r;return this.skipUntilBalanced(this.tokenIndex,e||this.consumeUntilBalanceEnd),t&&this.tokenStart>n?r=pM.call(this):r=this.tokenStart,{type:"Raw",loc:this.getLocation(n,r),value:this.substring(n,r)}}function fM(e){this.tokenize(e.value)}var dM,gM,Ig=$(()=>{"use strict";dM="Raw",gM={value:String}});var Eg={};Se(Eg,{generate:()=>bM,name:()=>hM,parse:()=>Fg,structure:()=>yM,walkContext:()=>xM});function z0(){return this.Raw(this.consumeUntilLeftCurlyBracket,!0)}function mM(){let e=this.SelectorList();return e.type!=="Raw"&&this.eof===!1&&this.tokenType!==23&&this.error(),e}function Fg(){let e=this.tokenIndex,t=this.tokenStart,n,r;return this.parseRulePrelude?n=this.parseWithFallback(mM,z0):n=z0.call(this,e),r=this.Block(!0),{type:"Rule",loc:this.getLocation(t,this.tokenStart),prelude:n,block:r}}function bM(e){this.node(e.prelude),this.node(e.block)}var hM,xM,yM,Ag=$(()=>{"use strict";hM="Rule",xM="rule",yM={prelude:["SelectorList","Raw"],block:["Block"]}});var Lg={};Se(Lg,{generate:()=>vM,name:()=>SM,parse:()=>Pg,structure:()=>wM});function Pg(){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 vM(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 SM,wM,Mg=$(()=>{"use strict";SM="Scope",wM={root:["SelectorList","Raw",null],limit:["SelectorList","Raw",null]}});var Dg={};Se(Dg,{generate:()=>TM,name:()=>kM,parse:()=>Bg,structure:()=>CM});function Bg(){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 TM(e){this.children(e)}var kM,CM,Rg=$(()=>{"use strict";kM="Selector",CM={children:[["TypeSelector","IdSelector","ClassSelector","AttributeSelector","PseudoClassSelector","PseudoElementSelector","Combinator"]]}});var Ng={};Se(Ng,{generate:()=>AM,name:()=>IM,parse:()=>zg,structure:()=>EM,walkContext:()=>FM});function zg(){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 AM(e){this.children(e,()=>this.token(18,","))}var IM,FM,EM,Og=$(()=>{"use strict";IM="SelectorList",FM="selector",EM={children:[["Selector","Raw"]]}});function El(e){let t=e.length,n=e.charCodeAt(0),r=n===N0||n===O0?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===_g){if(s===o){s!==t-1&&(i=e.substr(s+1));break}if(a=e.charCodeAt(++s),An(_g,a)){let u=s-1,c=Gr(e,u);s=c-1,i+=Qa(e.substring(u+1,c))}else a===13&&e.charCodeAt(s+1)===10&&s++}else i+=e[s]}return i}function _0(e,t){let n=t?"'":'"',r=t?O0:N0,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===_g?(o+="\\"+e.charAt(s),i=!1):(i&&(Pn(a)||Dr(a))&&(o+=" "),o+=e.charAt(s),i=!1)}return n+o+n}var _g,N0,O0,Al=$(()=>{"use strict";rr();_g=92,N0=34,O0=39});var Ug={};Se(Ug,{generate:()=>MM,name:()=>PM,parse:()=>$g,structure:()=>LM});function $g(){return{type:"String",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:El(this.consume(5))}}function MM(e){this.token(5,_0(e.value))}var PM,LM,jg=$(()=>{"use strict";Al();PM="String",LM={value:String}});var Wg={};Se(Wg,{generate:()=>NM,name:()=>DM,parse:()=>Hg,structure:()=>zM,walkContext:()=>RM});function U0(){return this.Raw(null,!1)}function Hg(){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)!==BM){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,U0);break;default:n=this.parseWithFallback(this.Rule,U0)}t.push(n)}return{type:"StyleSheet",loc:this.getLocation(e,this.tokenStart),children:t}}function NM(e){this.children(e)}var BM,DM,RM,zM,Vg=$(()=>{"use strict";BM=33;DM="StyleSheet",RM="stylesheet",zM={children:[["Comment","CDO","CDC","Atrule","Rule","Raw"]]}});var qg={};Se(qg,{generate:()=>$M,name:()=>OM,parse:()=>Gg,structure:()=>_M});function Gg(){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 $M(e){this.token(21,"("),this.node(e.declaration),this.token(22,")")}var OM,_M,Yg=$(()=>{"use strict";OM="SupportsDeclaration",_M={declaration:"Declaration"}});var Qg={};Se(Qg,{generate:()=>WM,name:()=>jM,parse:()=>Xg,structure:()=>HM});function Kg(){this.tokenType!==1&&this.isDelim(UM)===!1&&this.error("Identifier or asterisk is expected"),this.next()}function Xg(){let e=this.tokenStart;return this.isDelim(j0)?(this.next(),Kg.call(this)):(Kg.call(this),this.isDelim(j0)&&(this.next(),Kg.call(this))),{type:"TypeSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function WM(e){this.tokenize(e.name)}var UM,j0,jM,HM,Jg=$(()=>{"use strict";UM=42,j0=124;jM="TypeSelector",HM={name:String}});var tf={};Se(tf,{generate:()=>KM,name:()=>qM,parse:()=>ef,structure:()=>YM});function Ls(e,t){let n=0;for(let r=this.tokenStart+e;r<this.tokenEnd;r++){let o=this.charCodeAt(r);if(o===W0&&t&&n!==0)return Ls.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 Pl(e){let t=0;for(;this.isDelim(Zg);)++t>e&&this.error("Too many question marks"),this.next()}function VM(e){this.charCodeAt(this.tokenStart)!==e&&this.error((e===H0?"Plus sign":"Hyphen minus")+" is expected")}function GM(){let e=0;switch(this.tokenType){case 10:if(e=Ls.call(this,1,!0),this.isDelim(Zg)){Pl.call(this,6-e);break}if(this.tokenType===12||this.tokenType===10){VM.call(this,W0),Ls.call(this,1,!1);break}break;case 12:e=Ls.call(this,1,!0),e>0&&Pl.call(this,6-e);break;default:if(this.eatDelim(H0),this.tokenType===1){e=Ls.call(this,0,!0),e>0&&Pl.call(this,6-e);break}if(this.isDelim(Zg)){this.next(),Pl.call(this,5);break}this.error("Hex digit or question mark is expected")}}function ef(){let e=this.tokenStart;return this.eatIdent("u"),GM.call(this),{type:"UnicodeRange",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function KM(e){this.tokenize(e.value)}var H0,W0,Zg,qM,YM,nf=$(()=>{"use strict";rr();H0=43,W0=45,Zg=63;qM="UnicodeRange",YM={value:String}});function G0(e){let t=e.length,n=4,r=e.charCodeAt(t-1)===V0?t-2:t-1,o="";for(;n<r&&Dr(e.charCodeAt(n));)n++;for(;n<r&&Dr(e.charCodeAt(r));)r--;for(let i=n;i<=r;i++){let s=e.charCodeAt(i);if(s===rf){if(i===r){i!==t-1&&(o=e.substr(i+1));break}if(s=e.charCodeAt(++i),An(rf,s)){let a=i-1,u=Gr(e,a);i=u-1,o+=Qa(e.substring(a+1,u))}else s===13&&e.charCodeAt(i+1)===10&&i++}else o+=e[i]}return o}function q0(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===XM||o===rf||o===QM||o===JM||o===ZM||o===V0?(t+="\\"+e.charAt(r),n=!1):(n&&Pn(o)&&(t+=" "),t+=e.charAt(r),n=!1)}return"url("+t+")"}var XM,rf,QM,JM,ZM,V0,of=$(()=>{"use strict";rr();XM=32,rf=92,QM=34,JM=39,ZM=40,V0=41});var af={};Se(af,{generate:()=>nB,name:()=>eB,parse:()=>sf,structure:()=>tB});function sf(){let e=this.tokenStart,t;switch(this.tokenType){case 7:t=G0(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=El(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 nB(e){this.token(7,q0(e.value))}var eB,tB,lf=$(()=>{"use strict";of();Al();eB="Url",tB={value:String}});var uf={};Se(uf,{generate:()=>iB,name:()=>rB,parse:()=>cf,structure:()=>oB});function cf(){let e=this.tokenStart,t=this.readSequence(this.scope.Value);return{type:"Value",loc:this.getLocation(e,this.tokenStart),children:t}}function iB(e){this.children(e)}var rB,oB,pf=$(()=>{"use strict";rB="Value",oB={children:[[]]}});var gf={};Se(gf,{generate:()=>cB,name:()=>aB,parse:()=>df,structure:()=>lB});function df(){return this.eat(13),sB}function cB(e){this.token(13,e.value)}var sB,aB,lB,ff=$(()=>{"use strict";sB=Object.freeze({type:"WhiteSpace",loc:null,value:" "}),aB="WhiteSpace",lB={value:String}});var Ms={};Se(Ms,{AnPlusB:()=>vp,Atrule:()=>Tp,AtrulePrelude:()=>Ep,AttributeSelector:()=>Mp,Block:()=>Rp,Brackets:()=>Op,CDC:()=>Up,CDO:()=>Wp,ClassSelector:()=>qp,Combinator:()=>Xp,Comment:()=>Zp,Condition:()=>nd,Declaration:()=>id,DeclarationList:()=>cd,Dimension:()=>dd,Feature:()=>md,FeatureFunction:()=>yd,FeatureRange:()=>vd,Function:()=>Td,GeneralEnclosed:()=>Ed,Hash:()=>Ld,IdSelector:()=>Nd,Identifier:()=>Dd,Layer:()=>$d,LayerList:()=>Hd,MediaQuery:()=>Gd,MediaQueryList:()=>Kd,NestingSelector:()=>Jd,Nth:()=>tg,Number:()=>og,Operator:()=>ag,Parentheses:()=>ug,Percentage:()=>gg,PseudoClassSelector:()=>hg,PseudoElementSelector:()=>bg,Ratio:()=>vg,Raw:()=>Tg,Rule:()=>Eg,Scope:()=>Lg,Selector:()=>Dg,SelectorList:()=>Ng,String:()=>Ug,StyleSheet:()=>Wg,SupportsDeclaration:()=>qg,TypeSelector:()=>Qg,UnicodeRange:()=>tf,Url:()=>af,Value:()=>uf,WhiteSpace:()=>gf});var mf=$(()=>{"use strict";kp();Ip();Ap();Bp();zp();_p();jp();Vp();Yp();Qp();ed();rd();sd();ud();gd();hd();bd();kd();Id();Ad();Md();Rd();Od();Ud();Wd();qd();Xd();Zd();ng();ig();lg();pg();fg();xg();Sg();kg();Ig();Ag();Mg();Rg();Og();jg();Vg();Yg();Jg();nf();lf();pf();ff()});var K0,X0=$(()=>{"use strict";ml();w0();mf();K0={generic:!0,cssWideKeywords:wi,...S0,node:Ms}});function Bs(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,fB)&&this.cmpChar(this.tokenStart+1,Q0)?this.UnicodeRange():this.Identifier();case 9:{let t=this.charCodeAt(this.tokenStart);if(t===gB||t===pB||t===Q0||t===dB)return this.Operator();t===uB&&this.error("Hex or identifier is expected",this.tokenStart+1);break}}}var uB,pB,Q0,dB,gB,fB,hf=$(()=>{"use strict";uB=35,pB=42,Q0=43,dB=45,gB=47,fB=117});var J0,Z0=$(()=>{"use strict";hf();J0={getNode:Bs}});function kB(e,t){t.last!==null&&t.last.type!=="Combinator"&&e!==null&&e.type!=="Combinator"&&t.push({type:"Combinator",loc:null,name:" "})}function CB(){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)===eS&&this.error("Identifier is expected",this.tokenStart+1);break;case 9:{switch(this.charCodeAt(this.tokenStart)){case yB:case SB:case vB:case bB:return this.Combinator();case eS:return this.ClassSelector();case xB:case wB:return this.TypeSelector();case mB:return this.IdSelector();case hB:return this.NestingSelector()}break}}}var mB,hB,xB,yB,bB,eS,SB,wB,vB,tS,nS=$(()=>{"use strict";mB=35,hB=38,xB=42,yB=43,bB=47,eS=46,SB=62,wB=124,vB=126;tS={onWhiteSpace:kB,getNode:CB}});function rS(){return this.createSingleNodeList(this.Raw(null,!1))}var oS=$(()=>{"use strict"});function iS(){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 sS=$(()=>{"use strict"});function aS(e){return e!==null&&e.type==="Operator"&&(e.value[e.value.length-1]==="-"||e.value[e.value.length-1]==="+")}var lS,cS=$(()=>{"use strict";hf();oS();sS();lS={getNode:Bs,onWhiteSpace(e,t){aS(e)&&(e.value=" "+e.value),aS(t.last)&&(t.last.value+=" ")},expression:rS,var:iS}});var xf={};Se(xf,{AtrulePrelude:()=>J0,Selector:()=>tS,Value:()=>lS});var uS=$(()=>{"use strict";Z0();nS();cS()});var TB,pS,dS=$(()=>{"use strict";TB=new Set(["none","and","not","or"]),pS={parse:{prelude(){let e=this.createList();if(this.tokenType===1){let t=this.substring(this.tokenStart,this.tokenEnd);TB.has(t.toLowerCase())||e.push(this.Identifier())}return e.push(this.Condition("container")),e},block(e=!1){return this.Block(e)}}}});var gS,fS=$(()=>{"use strict";gS={parse:{prelude:null,block(){return this.Block(!0)}}}});function yf(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 mS,hS,xS=$(()=>{"use strict";mS={layer(){this.skipSC();let e=this.createList(),t=yf.call(this,this.Layer);return(t.type!=="Raw"||t.value!=="")&&e.push(t),e},supports(){this.skipSC();let e=this.createList(),t=yf.call(this,this.Declaration,()=>yf.call(this,()=>this.Condition("supports")));return(t.type!=="Raw"||t.value!=="")&&e.push(t),e}},hS={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,mS)),this.skipSC(),this.tokenType===2&&this.cmpStr(this.tokenStart,this.tokenEnd,"supports(")&&e.push(this.Function(null,mS)),(this.lookupNonWSType(0)===1||this.lookupNonWSType(0)===21)&&e.push(this.MediaQueryList()),e},block:null}}});var yS,bS=$(()=>{"use strict";yS={parse:{prelude(){return this.createSingleNodeList(this.LayerList())},block(){return this.Block(!1)}}}});var SS,wS=$(()=>{"use strict";SS={parse:{prelude(){return this.createSingleNodeList(this.MediaQueryList())},block(e=!1){return this.Block(e)}}}});var vS,kS=$(()=>{"use strict";vS={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}}});var CS,TS=$(()=>{"use strict";CS={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}}});var IS,FS=$(()=>{"use strict";IS={parse:{prelude(){return this.createSingleNodeList(this.Scope())},block(e=!1){return this.Block(e)}}}});var ES,AS=$(()=>{"use strict";ES={parse:{prelude:null,block(e=!1){return this.Block(e)}}}});var PS,LS=$(()=>{"use strict";PS={parse:{prelude(){return this.createSingleNodeList(this.Condition("supports"))},block(e=!1){return this.Block(e)}}}});var MS,BS=$(()=>{"use strict";dS();fS();xS();bS();wS();kS();TS();FS();AS();LS();MS={container:pS,"font-face":gS,import:hS,layer:yS,media:SS,nest:vS,page:CS,scope:IS,"starting-style":ES,supports:PS}});function DS(){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 RS=$(()=>{"use strict"});var Yo,bf,IB,FB,Ll,zS,NS=$(()=>{"use strict";RS();Yo={parse(){return this.createSingleNodeList(this.SelectorList())}},bf={parse(){return this.createSingleNodeList(this.Selector())}},IB={parse(){return this.createSingleNodeList(this.Identifier())}},FB={parse:DS},Ll={parse(){return this.createSingleNodeList(this.Nth())}},zS={dir:IB,has:Yo,lang:FB,matches:Yo,is:Yo,"-moz-any":Yo,"-webkit-any":Yo,where:Yo,not:Yo,"nth-child":Ll,"nth-last-child":Ll,"nth-last-of-type":Ll,"nth-of-type":Ll,slotted:bf,host:bf,"host-context":bf}});var Sf={};Se(Sf,{AnPlusB:()=>wp,Atrule:()=>Cp,AtrulePrelude:()=>Fp,AttributeSelector:()=>Lp,Block:()=>Dp,Brackets:()=>Np,CDC:()=>$p,CDO:()=>Hp,ClassSelector:()=>Gp,Combinator:()=>Kp,Comment:()=>Jp,Condition:()=>td,Declaration:()=>od,DeclarationList:()=>ld,Dimension:()=>pd,Feature:()=>fd,FeatureFunction:()=>xd,FeatureRange:()=>wd,Function:()=>Cd,GeneralEnclosed:()=>Fd,Hash:()=>Pd,IdSelector:()=>zd,Identifier:()=>Bd,Layer:()=>_d,LayerList:()=>jd,MediaQuery:()=>Vd,MediaQueryList:()=>Yd,NestingSelector:()=>Qd,Nth:()=>eg,Number:()=>rg,Operator:()=>sg,Parentheses:()=>cg,Percentage:()=>dg,PseudoClassSelector:()=>mg,PseudoElementSelector:()=>yg,Ratio:()=>wg,Raw:()=>Cg,Rule:()=>Fg,Scope:()=>Pg,Selector:()=>Bg,SelectorList:()=>zg,String:()=>$g,StyleSheet:()=>Hg,SupportsDeclaration:()=>Gg,TypeSelector:()=>Xg,UnicodeRange:()=>ef,Url:()=>sf,Value:()=>cf,WhiteSpace:()=>df});var OS=$(()=>{"use strict";kp();Ip();Ap();Bp();zp();_p();jp();Vp();Yp();Qp();ed();rd();sd();ud();gd();hd();bd();kd();Id();Ad();Md();Rd();Od();Ud();Wd();qd();Xd();Zd();ng();ig();lg();pg();fg();xg();Sg();kg();Ig();Ag();Mg();Rg();Og();jg();Vg();Yg();Jg();nf();lf();pf();ff()});var _S,$S=$(()=>{"use strict";uS();BS();NS();OS();_S={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:xf,atrule:MS,pseudo:zS,node:Sf}});var US,jS=$(()=>{"use strict";mf();US={node:Ms}});var HS,WS=$(()=>{"use strict";b0();X0();$S();jS();HS=y0({...K0,..._S,...US})});var VS=$(()=>{"use strict"});var GS=$(()=>{"use strict"});var Bq,qS,Dq,Rq,zq,YS,Nq,Oq,_q,$q,Uq,jq,KS=$(()=>{"use strict";WS();VS();ap();fl();GS();Al();of();({tokenize:Bq,parse:qS,generate:Dq,lexer:Rq,createLexer:zq,walk:YS,find:Nq,findLast:Oq,findAll:_q,toPlainObject:$q,fromPlainObject:Uq,fork:jq}=HS)});function LB(e){return e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function QS(e){try{let t=qS(e.trim(),{context:"value"}),n=[];return YS(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 MB(e,t){let n=LB(e);if(!PB.has(n))return t;let r=QS(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 XS(e,t){let n=t.trim();if(!n)return"";let r=MB(e,n);return QS(r).map(i=>i==="0"?"0px":i).join(" ")}function JS(e,t,n){let r=XS(e,t),o=XS(e,n);return r!==""&&o!==""&&r===o}var PB,ZS=$(()=>{"use strict";KS();PB=new Set(["padding","margin","border-radius","borderradius","inset","border-width","borderwidth"])});function BB(e){let t=e.toLowerCase();return t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t}function DB(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 ew(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=DB(n[0]);if(i)return i}let r=t.match(/#([0-9a-fA-F]{3,8})/);if(r)return BB(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 Ko(e,t,n){if(!e||!t)return!1;let r=String(e),o=String(t),i=r.toLowerCase(),s=o.toLowerCase(),a=i.includes("none"),u=s.includes("none");if(a!==u)return!1;let c=/\b(fill|stroke)\s*:/i,l=c.test(r),p=c.test(o);if(l!==p)return!1;let g=ew(r),d=ew(o);return!!(g===d||n&&JS(n,r,o))}var wf=$(()=>{"use strict";ZS()});function _B(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 tw(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 $B(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 UB(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&&_B(n)||tw(r)||tw(o)||n&&$B(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<rw:a<nw}return r.includes("%")||o.includes("%")?a<1:!1}function jB(e){let t=`${e.description||""} ${e.title||""} ${e.suggestedFix||""}`.toLowerCase();if(OB.some(s=>t.includes(s))||!zB.some(s=>t.includes(s)))return!1;let o=e.expected||e.suggestedValue,i=e.actual||e.currentValue;return!(o&&i&&!Ko(o,i,e.property))}function HB(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 WB(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)<ow}function VB(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(!NB.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]))>RB)}function GB(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 Ds(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(Ko(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(WB(e))return{dismissed:!0,dismissReason:`Auto-dismissed: text dimension variance (<${ow}px) - font rendering difference, not actionable`,dismissedBy:"post-ai-validation"};if(UB(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")?rw:nw}px)`,dismissedBy:"post-ai-validation"}}return GB(e)?{dismissed:!0,dismissReason:"Auto-dismissed: no measurable values to compare",dismissedBy:"post-ai-validation"}:jB(e)?{dismissed:!0,dismissReason:"Auto-dismissed: no fix needed",dismissedBy:"post-ai-validation"}:VB(e)?{dismissed:!0,dismissReason:"Auto-dismissed: HUG sizing - CSS auto-sizes content without explicit dimensions",dismissedBy:"post-ai-validation"}:HB(e)?{dismissed:!0,dismissReason:"Auto-dismissed: SVG container fill - child elements use their own fills",dismissedBy:"post-ai-validation"}:{dismissed:!1}}var nw,rw,ow,RB,zB,NB,OB,iw=$(()=>{"use strict";wf();nw=.5,rw=2,ow=2,RB=5,zB=["values match","values already match","already correct","correctly implemented","implementation is correct","css matches","matches figma","identical","same value","no difference","none - ","no changes needed","no fix needed"],NB=["hug","auto (hug)","should be hug","fixed pixel values are being rendered","fixed values are being rendered"],OB=["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 Fi(e,t,n){let r=100-n*1-t*3-e*10;return Math.max(0,Math.min(100,r))}var sw=$(()=>{"use strict"});var aw=$(()=>{"use strict"});var lw=$(()=>{"use strict"});var vf=$(()=>{"use strict";wf();iw();sw();aw();lw()});var tD,nD,iY,kf=$(()=>{"use strict";tD=["flex","inline-flex"],nD=["grid","inline-grid"],iY=[...tD,...nD]});var uw=$(()=>{"use strict";vf();kf()});var pw=$(()=>{"use strict"});var Rs=$(()=>{"use strict";hy();vf();kf();uw();pw()});function oD(e){let{aiPrompt:t,aiResponse:n,...r}=e;return r}function Kn(e){try{let t=e.map(oD),n=JSON.stringify(t,iD);sessionStorage.setItem(Cf,n)}catch(t){y.error("[SessionStorage] Failed to save review history:",t)}}function Tf(){try{let e=sessionStorage.getItem(Cf);if(!e)return[];let t=JSON.parse(e,sD);return Array.isArray(t)?t:[]}catch(e){return y.error("[SessionStorage] Failed to load review history:",e),[]}}function dw(){try{let e=Tf();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&&(Kn(n),y.debug("[SessionStorage] Stripped aiPrompt/aiResponse from existing review history"))}catch(e){y.error("[SessionStorage] Failed to strip sensitive fields:",e)}}function gw(){try{sessionStorage.removeItem(Cf),y.debug("[SessionStorage] Review history cleared")}catch(e){y.error("[SessionStorage] Failed to clear review history:",e)}}function iD(e,t){return t instanceof Date?{__type:"Date",value:t.toISOString()}:t}function sD(e,t){return t&&t.__type==="Date"?new Date(t.value):t}var Cf,If=$(()=>{"use strict";Ne();Cf="uicopilot_review_history"});import aD,{createContext as lD,useContext as cD,useReducer as uD,useMemo as fw,useRef as pD,useEffect as dD}from"react";function Ml(e){let t=e.length>mw?e.slice(e.length-mw):e,n=Math.max(0,t.length-gD);return n===0?t:t.map((r,o)=>{if(o>=n)return r;let i=r.storybookImageData?.startsWith("data:"),s=r.figmaImageData?.startsWith("data:");return!i&&!s?r:{...r,storybookImageData:i?void 0:r.storybookImageData,figmaImageData:s?void 0:r.figmaImageData}})}function fD(e,t){switch(t.type){case"SET_STATE":return{...e,...t.payload};case"ADD_STREAMING_MESSAGE":return{...e,streamingMessages:[...e.streamingMessages,t.payload]};case"UPDATE_STREAMING_MESSAGE":return{...e,streamingMessages:e.streamingMessages.map((n,r)=>r===t.payload.index?{...n,content:t.payload.content}:n)};case"CLEAR_STREAMING_MESSAGES":return{...e,streamingMessages:[]};case"TOGGLE_MODEL":{let n=e.selectedModels.includes(t.payload);return n&&e.selectedModels.length===1?e:{...e,selectedModels:n?e.selectedModels.filter(r=>r!==t.payload):[...e.selectedModels,t.payload]}}case"SET_REVIEW_RESULTS":{if(!t.payload)return{...e,reviewResults:null,currentReviewId:null};let n=e.userRole==="admin",r={id:t.payload.id,componentId:t.payload.componentId,storyId:t.payload.storyId,modelId:t.payload.modelId,complianceScore:t.payload.complianceScore,issuesCount:t.payload.issuesCount,issues:t.payload.issues,createdAt:t.payload.createdAt,visualSimilarity:t.payload.visualSimilarity,storybookImageData:e.storybookImageUrl||void 0,figmaImageData:e.figmaImageUrl||void 0,aiPrompt:n&&e.fullPrompt||void 0,aiResponse:n&&e.fullResponse||void 0,costUsd:t.payload.costUsd,inputTokens:t.payload.inputTokens,outputTokens:t.payload.outputTokens},o=e.reviewHistory.findIndex(s=>s.id===t.payload.id),i;return o>=0?i=e.reviewHistory.map((s,a)=>a===o?r:s):i=[...e.reviewHistory,r],i=Ml(i),Kn(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=Ml([...e.reviewHistory,...r]);return Kn(o),{...e,reviewHistory:o}}case"ADD_REVIEW":{let n=Ml([...e.reviewHistory,t.payload]);return Kn(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 Kn(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 Kn(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 Kn(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 Kn(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 Kn(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 Kn(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=Fi(i,s,a);return y.debug(`[recalculateScore] Active: ${o.length}, score: ${u}`),{...r,complianceScore:u,issuesCount:o.length}});return Kn(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 Kn(n),{...e,reviewHistory:n}}case"CLEAR_ALL_REVIEWS":return gw(),{...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 Ef({children:e}){let[t,n]=uD(fD,bD),r=pD(t);dD(()=>{r.current=t},[t]);let o=fw(()=>({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=fw(()=>({...t,...o}),[t,o]);return aD.createElement(hw.Provider,{value:i},e)}function ce(){let e=cD(hw);if(!e)throw new Error("useReviewStore must be used within a ReviewProvider");return e}var mw,gD,mD,hD,Ff,xD,yD,bD,hw,Af=$(()=>{"use strict";Rs();If();Ne();mw=20,gD=5;mD=()=>{if(typeof localStorage>"u")return 3;try{let e=localStorage.getItem("uicopilot_review_all_concurrency");if(e)return Math.max(1,Math.min(5,parseInt(e,10)))}catch{}return 3},hD=()=>{if(typeof localStorage>"u")return null;try{let e=localStorage.getItem("uicopilot_role_override");if(e==="admin"||e==="beta")return e}catch{}return null},Ff={enableFixGeneration:!1,enableFixApply:!1,enableAutoMap:!1,enableReviewBadges:!1,showCosts:!1,enableParallelReview:!1,enableModelSelection:!1},xD=()=>{if(typeof localStorage>"u")return Ff;try{let e=localStorage.getItem("uicopilot_feature_flags");if(!e)return Ff;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 Ff},yD=()=>{if(typeof localStorage>"u")return"beta";try{let e=localStorage.getItem("uicopilot_user_role");if(e==="admin"||e==="beta")return e}catch{}return"beta"},bD={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:Ml(Tf()),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:yD(),roleOverride:hD(),featureFlags:xD(),reviewAllConcurrency:mD(),hoveredIssueId:null},hw=lD(null)});import zs,{useMemo as SD}from"react";function Lf({children:e}){return zs.createElement(du,null,zs.createElement(fu,null,zs.createElement(hu,null,zs.createElement(Ef,null,zs.createElement(wD,null),e))))}function xw(e){let t=we(),n=Je(),r=nt(),o=ce(),i=SD(()=>({...t,...n,...r,...o}),[t,n,r,o]);return e?e(i):i}function wD(){return Pf=xw(),null}var Pf,dt,yw=$(()=>{"use strict";gu();mu();xu();Af();Pf=null,dt=Object.assign(xw,{getState:()=>{if(!Pf)throw new Error("Store not initialized. Make sure StoreProvider is mounted.");return Pf}})});var ke=$(()=>{"use strict";yw();gu();mu();xu();Af()});function G(){return(process.env.STORYBOOK_UICOPILOT_URL||vD).replace(/\/$/,"")}var vD,bw,je=$(()=>{"use strict";vD="https://app.uiparity.com";bw=3.6});async function ne(e,t,n=3e4){let r=new AbortController,o=setTimeout(()=>r.abort(),n);try{return await fetch(e,{...t,signal:r.signal})}catch(i){throw i instanceof DOMException&&i.name==="AbortError"?new Error(`Request timed out after ${n}ms: ${e}`):i}finally{clearTimeout(o)}}var lt=$(()=>{"use strict"});import{useEffect as Xo,useState as Dl,useRef as Dw,useCallback as Rf}from"react";import{addons as zf}from"storybook/manager-api";async function TR(e,t,n){let r=`${e}:${t}`,o=Nf.get(r);if(o)return y.debug("[useReviewScreenshots] Reusing in-flight Figma image fetch for",r),o;let i=(async()=>{let s=await ne(`${_w}/api/figma/image?projectId=${e}&nodeId=${t}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`}});return s.ok?s.json():{imageUrl:null}})().finally(()=>{Nf.delete(r)});return Nf.set(r,i),i}function IR(e,t,n){try{sessionStorage.setItem(`${Rl}${e}`,JSON.stringify({figmaNodeId:t,imageUrl:n,timestamp:Date.now()}))}catch{}}function FR(e,t){try{let n=sessionStorage.getItem(`${Rl}${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(`${Rl}${e}`)}catch{}return null}function ER(e){try{let t=sessionStorage.getItem(`${Rl}${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 Rw,zw,Nw,Ow,Li,_w,sr,Of,Nf,Rl,$w,Qo,Us=$(()=>{"use strict";ke();_f();Ne();je();lt();Rw="storyArgsUpdated",zw="storyRendered",Nw="forceRemount",Ow=null,Li=()=>Ow,_w=G(),sr=new Map,Of=null,Nf=new Map;Rl="uicopilot-figma-image-";$w=(e,t,n)=>{Of=t;let r=sr.get(e);r?r.figmaImageUrl=n:sr.set(e,{storybookImageUrl:null,figmaImageUrl:n}),y.debug("[useReviewScreenshots] Pre-set Figma image for mapping:",{storyId:e,figmaNodeId:t,imageUrl:n.substring(0,50)+"..."})},Qo=()=>{let[e,t]=Dl(!1),[n,r]=Dl(!1),[o,i]=Dl(!1),[s,a]=Dl(null),u=Dw(null),{screenshotRefreshKey:c,triggerScreenshotRefresh:l}=ce(),p=Rf(()=>{let P=dt.getState().currentStoryId;P&&(y.debug("[useReviewScreenshots] Refreshing screenshots for story:",P),sr.delete(P),u.current=null,i(!0),l())},[l]),g=Rf(()=>{let P=dt.getState().currentStoryId;if(P){y.debug("[useReviewScreenshots] Refreshing Storybook screenshot only for story:",P);let z=sr.get(P);z&&(z.storybookImageUrl=null),u.current=null,i(!0),l()}},[l]),{sessionToken:d}=we(),{selectedProjectId:m}=Je(),{currentStoryId:C,currentMapping:T,loadingMapping:E}=nt(),{setStorybookImageUrl:I,setFigmaImageUrl:D}=ce(),R=Dw(null);Xo(()=>{C&&R.current&&R.current!==C&&(y.debug("[useReviewScreenshots] Story switched, clearing images"),I(""),D("")),R.current=C},[C,I,D]),Xo(()=>{!C||E||T||D("")},[C,T,E,D]),Xo(()=>{if(!C)return;let P=ER(C);P&&(y.debug("[useReviewScreenshots] Quick-restored Figma image for:",C),D(P))},[C,D]),Xo(()=>{let P=!1;return(async()=>{if(!d||!m||!C){y.debug("[useReviewScreenshots] Missing required context, skipping auto-load");return}u.current&&u.current!==C&&(y.debug("[useReviewScreenshots] Story changed, clearing stale screenshots"),I(""),D(""));let x=dt.getState();if(u.current===C&&x.storybookImageUrl&&x.figmaImageUrl){y.debug("[useReviewScreenshots] Screenshots already loaded for this story, skipping capture");return}let w=T?.figmaNodeId??null;if(w!==Of){y.debug("[useReviewScreenshots] Figma mapping changed, invalidating Figma image only for story:",C);let L=sr.get(C);L&&(L.figmaImageUrl=null),Of=w,u.current=null}let v=T?.figmaNodeId;if(v&&!sr.get(C)?.figmaImageUrl){let L=FR(C,v);if(L){y.debug("[useReviewScreenshots] Hydrated Figma image from sessionStorage for story:",C),D(L);let B=sr.get(C);B?B.figmaImageUrl=L:sr.set(C,{storybookImageUrl:null,figmaImageUrl:L})}}let k=sr.get(C),f=k&&k.storybookImageUrl&&k.figmaImageUrl,F=k&&k.storybookImageUrl&&!k.figmaImageUrl,S=k&&!k.storybookImageUrl&&k.figmaImageUrl;if(f){y.debug("[useReviewScreenshots] Using fully cached screenshots for story:",C),I(k.storybookImageUrl),D(k.figmaImageUrl),u.current=C;return}let b=F&&T?.figmaNodeId;b&&(y.debug("[useReviewScreenshots] Using cached Storybook, fetching new Figma for story:",C),I(k.storybookImageUrl));let A=S;if(A&&(y.debug("[useReviewScreenshots] Using cached Figma, recapturing Storybook for story:",C),D(k.figmaImageUrl)),u.current===C&&T?.figmaNodeId){y.debug("[useReviewScreenshots] Screenshots already loaded for this story, skipping");return}try{if(a(null),b?r(!0):(A||(t(!0),r(!0)),i(!0)),u.current=C,P)return;let L=A?k.figmaImageUrl:null,B;if(A)y.debug("[useReviewScreenshots] Figma cached (storybookOnlyRefresh), skipping fetch"),r(!1);else if(v){y.debug("[useReviewScreenshots] Found Figma node ID from mapping:",v);let h=null;try{y.debug("[useReviewScreenshots] Fetching Figma image (with caching)...");let j=await TR(m,v,d);h=j.imageUrl||null;let H=j.cached?"(cached)":"(fresh)";y.debug(`[useReviewScreenshots] Figma image fetched ${H}:`,h?"success":"not found")}catch(j){y.warn("[useReviewScreenshots] Failed to fetch Figma image:",j)}if(h)if(h.includes(".azureedge.net")||h.includes(".blob.core.windows.net")||h.includes(".blob.vercel-storage.com")){y.debug("[useReviewScreenshots] Using cached CDN URL directly (fast)"),L=h,D(h);let H=new Image;H.crossOrigin="anonymous",await new Promise(M=>{H.onload=()=>{B={width:H.naturalWidth,height:H.naturalHeight},y.debug("[useReviewScreenshots] Figma dimensions:",B),M()},H.onerror=()=>M(),H.src=h})}else try{y.debug("[useReviewScreenshots] Converting Figma S3 URL to data URL via proxy...");let H=`${_w}/api/proxy/image?url=${encodeURIComponent(h)}`,M=await ne(H);if(M.ok){let X=await M.blob(),Z=new FileReader,me=await new Promise((oe,Ye)=>{Z.onloadend=()=>oe(Z.result),Z.onerror=Ye,Z.readAsDataURL(X)});L=me,D(me),y.debug("[useReviewScreenshots] Figma thumbnail converted to data URL");let xe=new Image;await new Promise(oe=>{xe.onload=()=>{B={width:xe.naturalWidth,height:xe.naturalHeight},y.debug("[useReviewScreenshots] Figma dimensions:",B),oe()},xe.onerror=()=>oe(),xe.src=me})}else L=h,D(h),y.debug("[useReviewScreenshots] Figma thumbnail loaded (external URL)")}catch(H){y.warn("[useReviewScreenshots] Failed to convert to data URL, using external URL:",H),L=h,D(h)}else y.warn("[useReviewScreenshots] No thumbnail found for node:",v),D(null);L&&v&&IR(C,v,L),r(!1)}else y.debug("[useReviewScreenshots] No Figma mapping exists for this component"),D(null),r(!1);let N=k?.storybookImageUrl||null;if(N)y.debug("[useReviewScreenshots] Using cached Storybook screenshot"),i(!1);else{y.debug("[useReviewScreenshots] Capturing Storybook screenshot for story:",C);let h=await zl({storyId:C,sessionToken:d||void 0,...B&&{figmaWidth:B.width,figmaHeight:B.height}});h&&!P?(N=h,I(h),y.debug("[useReviewScreenshots] Storybook screenshot captured at dimensions:",B||"natural")):y.warn("[useReviewScreenshots] Failed to capture Storybook screenshot"),i(!1)}sr.set(C,{storybookImageUrl:N,figmaImageUrl:L}),y.debug("[useReviewScreenshots] Screenshots cached for story:",C)}catch(L){y.error("[useReviewScreenshots] Error loading screenshots:",L),a(L instanceof Error?L.message:"Failed to load screenshots"),u.current=null,r(!1),i(!1)}finally{t(!1)}})(),()=>{P=!0}},[d,m,C,T?.figmaNodeId,c]),Xo(()=>{let P=zf.getChannel(),z=null,x=w=>{Ow=w.args,y.debug("[useReviewScreenshots] Args updated for story:",w.storyId,"args:",w.args),z&&clearTimeout(z),z=setTimeout(()=>{y.debug("[useReviewScreenshots] Story args changed, refreshing screenshot"),p()},500)};return P.on(Rw,x),()=>{P.off(Rw,x),z&&clearTimeout(z)}},[p]),Xo(()=>{let P=zf.getChannel(),z=!1,x=null,w=()=>{y.debug("[useReviewScreenshots] FORCE_REMOUNT detected, showing Storybook loader"),z=!0,i(!0)},v=()=>{z&&(y.debug("[useReviewScreenshots] STORY_RENDERED after remount, waiting for styles to settle..."),x&&clearTimeout(x),x=setTimeout(()=>{z=!1,y.debug("[useReviewScreenshots] Refreshing Storybook screenshot after HMR (preserving Figma)"),g()},500))};return P.on(Nw,w),P.on(zw,v),()=>{P.off(Nw,w),P.off(zw,v),x&&clearTimeout(x)}},[g]),Xo(()=>{let P=zf.getChannel(),z=async x=>{if(!x?.snapshot?.html){y.debug("[useReviewScreenshots] DOM mutated but no snapshot available");return}y.debug("[useReviewScreenshots] DOM mutated, capturing snapshot screenshot"),i(!0);try{let w=dt.getState().currentStoryId,v=await fetch("/__uicopilot/screenshot-snapshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...x.snapshot,storyId:w})});if(v.ok){let k=await v.json();if(k.screenshot){I(k.screenshot);let f=dt.getState().currentStoryId;if(f){let F=sr.get(f);F?F.storybookImageUrl=k.screenshot:sr.set(f,{storybookImageUrl:k.screenshot,figmaImageUrl:null})}}}else y.error("[useReviewScreenshots] Snapshot screenshot failed:",await v.text())}catch(w){y.error("[useReviewScreenshots] Snapshot screenshot error:",w)}finally{i(!1)}};return P.on("UICOPILOT/STORY_DOM_MUTATED",z),()=>{P.off("UICOPILOT/STORY_DOM_MUTATED",z)}},[]);let _=Rf((P,z,x)=>{y.debug("[useReviewScreenshots] setFigmaImageDirect called - bypassing load"),$w(P,z,x),D(x),r(!1),u.current=P},[D]);return{isLoadingScreenshots:e,isLoadingFigma:n,isLoadingStorybook:o,screenshotError:s,refreshScreenshots:p,refreshStorybookOnly:g,setFigmaImageDirect:_}}});function PR(){return!G().startsWith("http://localhost")}function LR(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 Uw(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=LR(o,t,n);return r.set(o,i),i})}async function MR(){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=Uw(c,o,r))});let a=Array.from(o.styleSheets);s.querySelectorAll('link[rel="stylesheet"]').forEach(u=>{let c=u.href,l=a.find(p=>p.href===c);if(l)try{let p="";for(let g of Array.from(l.cssRules))p+=g.cssText+`
13
+ `;if(/(?:color|oklch|oklab|lab|lch)\(/.test(p)){let g=s.createElement("style");g.textContent=Uw(p,o,r),u.replaceWith(g)}}catch{}})}})).toDataURL("image/png")}function BR(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 DR(e,t){y.debug("[Screenshot] Using server-side Chrome capture for:",e);let n={"Content-Type":"application/json"};t?.sessionToken&&(n.Authorization=`Bearer ${t.sessionToken}`);let r=await ne(`${AR}/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 RR(e){let t={};if(!e)return t;let n=e.split(";");for(let r of n){let o=r.indexOf(":");if(o===-1)continue;let i=r.slice(0,o),s=r.slice(o+1);typeof s=="string"&&(s==="!true"?s=!0:s==="!false"?s=!1:!isNaN(Number(s))&&s!==""?s=Number(s):s=decodeURIComponent(s.replace(/\+/g," "))),t[i]=s}return t}function zR(e){let t=new URLSearchParams(window.location.search),n=e;if(n||(n=(t.get("path")||"").replace("/story/","").replace("/docs/",""),y.debug("[Screenshot] Warning: Using story ID from URL (fallback):",n)),!n)throw new Error("Could not determine current story ID. Please select a story first.");let r=window.location.origin,o=Date.now(),i=`${r}/iframe.html?viewMode=story&id=${n}&globals=&_cb=${o}`,s=Li();if(!s||Object.keys(s).length===0){let a=t.get("args");a&&(s=RR(a),y.debug("[Screenshot] Parsed args from URL:",s))}if(s&&Object.keys(s).length>0){let a=BR(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 NR(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 zl(e){let t=e?.storyId||OR();if(t){let n=$f.get(t);if(n)return y.debug("[Screenshot] Reusing in-flight capture for",t),n;let r=jw(t,e).finally(()=>{$f.delete(t)});return $f.set(t,r),r}return jw(void 0,e)}async function jw(e,t){try{if(e){let n=await NR(e);if(n)return n}if(!PR()){let n=zR(t?.storyId);return await DR(n,{...t,selector:"#storybook-root > *"})}return y.info("[Screenshot] Using client-side capture (html2canvas fallback)"),await MR()}catch(n){throw y.error("Error capturing screenshot:",n),new Error(`Failed to capture screenshot: ${n instanceof Error?n.message:"Unknown error"}`)}}function OR(){return(new URLSearchParams(window.location.search).get("path")||"").replace("/story/","").replace("/docs/","")||void 0}var AR,$f,_f=$(()=>{"use strict";je();Us();Ne();lt();AR=G();$f=new Map});function Cn(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 js(e){return e.split(",").map(n=>n.trim().replace(/['"]/g,""))[0]||e}function Hw(e){let t=e.ownerDocument,r=(t.defaultView||window).getComputedStyle(e);if("fonts"in t){let T=r.fontSize||"16px",E=r.fontWeight||"400";if(r.fontFamily.includes("Roboto")){let I=t.fonts.check(`${E} ${T} Roboto`);if(y.debug("[computedStyles] Roboto check:",{cssFamily:r.fontFamily,robotoLoaded:I,fontWeight:E,fontSize:T,isIframe:t!==document,fontStatus:Array.from(t.fonts).map(D=>({family:D.family,status:D.status}))}),I)return"Roboto"}}let o="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",s=t.createElement("canvas").getContext("2d");if(!s)return"unknown";let a=r.fontSize,u=r.fontWeight,c=r.fontStyle,l=r.fontFamily.split(",").map(T=>T.trim().replace(/['"]/g,"")),p=["Arial","Helvetica","Helvetica Neue","Times New Roman","Georgia","Courier New","Verdana","Tahoma","Trebuchet MS","sans-serif","serif","monospace"],g=[...new Set([...l,...p])];s.font=`${c} ${u} ${a} monospace`;let d=s.measureText(o).width,m="unknown",C=new Map;for(let T of g){s.font=`${c} ${u} ${a} "${T}", monospace`;let E=s.measureText(o).width;if(C.set(T,E),E!==d){s.font=`${c} ${u} ${a} "${T}"`;let I=s.measureText(o).width;s.font=`${c} ${u} ${a} ${r.fontFamily}`;let D=s.measureText(o).width;if(Math.abs(I-D)<.1){m=T;break}}}return y.debug("[computedStyles] Font detection:",{declared:r.fontFamily,detected:m,declaredFonts:l,fontWidths:Array.from(C.entries()),isIframe:t!==document}),m}var Hs=$(()=>{"use strict";Ne()});function Mi(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 Uf(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:Cn(n.color),backgroundColor:Cn(n.backgroundColor),borderColor:Cn(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:Hw(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 jf(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 Nl=$(()=>{"use strict";Ne();Hs()});function _R(e){let t=[],n=new Set,r=Ww.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(Ww.includes(e.tagName.toLowerCase())){let i=`${e.tagName.toLowerCase()}.${e.className}`;n.has(i)||t.unshift(e)}return t}function $R(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:Mi(r,i),tagName:r,className:i,styles:{fontSize:n.fontSize,fontFamily:js(n.fontFamily),fontWeight:n.fontWeight,lineHeight:n.lineHeight,letterSpacing:n.letterSpacing,color:Cn(n.color),textAlign:n.textAlign,textTransform:n.textTransform}}}function UR(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 jR(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e),r=e.tagName.toLowerCase(),o=e.className,i=typeof o=="string"?o:o?.baseVal||"",s=n.borderWidth!=="0px",a=n.backgroundColor!=="transparent"&&n.backgroundColor!=="rgba(0, 0, 0, 0)",u=n.borderRadius!=="0px",c=n.gap!=="normal"&&n.gap!=="0px";if(!s&&!a&&!u&&!c)return null;let l=n.borderWidth,p=n.borderStyle,g=Cn(n.borderColor),d=s?`${l} ${p} ${g}`:"none";return{selector:Mi(r,i),className:i,border:d,borderRadius:n.borderRadius,backgroundColor:Cn(n.backgroundColor),gap:n.gap}}function Ws(){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=UR(r,2),i=o.map(jR).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=_R(r);s=a.map($R),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:Uf(r),declared:jf(r,t),markup:r.outerHTML,textElementStyles:s,nestedElementStyles:i}}catch(e){return y.error("Error extracting computed styles:",e),null}}var Ww,Vw=$(()=>{"use strict";Ne();Hs();Nl();Ww=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});function Hf(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 WR(e,t,n){if(!(e==="0px"||t==="none"))return`${e} ${t} ${n}`}function VR(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e),r={},o=Cn(n.backgroundColor);Dn("backgroundColor",o)||(r.backgroundColor=o);let i=WR(n.borderWidth,n.borderStyle,Cn(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 T=0;T<e.attributes.length;T++){let E=e.attributes[T];if(["class","style","id","xmlns","xmlns:xlink"].includes(E.name))continue;let I=E.name.replace(/-([a-z])/g,(R,_)=>_.toUpperCase()),D=E.value.startsWith("rgb")?Cn(E.value):E.value;I==="d"&&D.length>100?r[I]=D.substring(0,100)+"...":r[I]=D}let d=n.getPropertyValue("fill"),m=n.getPropertyValue("stroke");if(d&&d!=="none"&&(r.fill=d.startsWith("rgb")?Cn(d):d),m&&m!=="none"&&(r.stroke=m.startsWith("rgb")?Cn(m):m),["circle","ellipse","rect","path","line","polyline","polygon"].includes(s)){let T=e.getBoundingClientRect();T.width>0&&(r.width=`${Math.round(T.width*100)/100}px`),T.height>0&&(r.height=`${Math.round(T.height*100)/100}px`)}}let c=e.textContent&&e.textContent.trim().length>0,l=HR.includes(e.tagName.toLowerCase());(c||l)&&(r.fontSize=n.fontSize,r.fontFamily=js(n.fontFamily),r.fontWeight=n.fontWeight,r.lineHeight=n.lineHeight,r.color=Cn(n.color),Dn("letterSpacing",n.letterSpacing)||(r.letterSpacing=n.letterSpacing),Dn("textAlign",n.textAlign)||(r.textAlign=n.textAlign)),r.display=n.display;let p=Hf(n.paddingTop,n.paddingRight,n.paddingBottom,n.paddingLeft);Dn("padding",p)||(r.padding=p);let g=Hf(n.marginTop,n.marginRight,n.marginBottom,n.marginLeft);return Dn("margin",g)||(r.margin=g),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 Gw(e){let t=1;for(let n of e.children)t+=Gw(n);return t}function qw(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 C of Array.from(o.childNodes))if(C.nodeType===Node.TEXT_NODE){let T=C.textContent?.trim();if(T){p=T.length>50?T.substring(0,50)+"...":T;break}}let g=s;c?g=`${s}#${c}`:u&&(g=Mi(s,u));let d=VR(o),m=[];if(i<t){let C=Array.from(o.children);for(let T of C){let E=T.tagName.toLowerCase();if(["script","style","link","meta","br","hr","noscript"].includes(E))continue;let D=(T.ownerDocument.defaultView||window).getComputedStyle(T);D.display==="none"||D.visibility==="hidden"||m.push(n(T,i+1))}}return{selector:g,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:Gw(r)}),r}function Wf(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=qw(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 HR,Yw=$(()=>{"use strict";Ne();Hs();Nl();HR=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});var Vf=$(()=>{"use strict";Hs();Nl();Vw();Yw()});var Sv=er((HX,bv)=>{"use strict";bv.exports={compareTwoStrings:yv,findBestMatch:hz};function yv(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 hz(e,t){if(!xz(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=yv(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 xz(e,t){return!(typeof e!="string"||!Array.isArray(t)||!t.length||t.find(function(n){return typeof n!="string"}))}});var u1=er((Kie,c1)=>{"use strict";var i1=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,mU=/\n/g,hU=/^\s*/,xU=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,yU=/^:\s*/,bU=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,SU=/^[;\s]*/,wU=/^\s+|\s+$/g,vU=`
14
+ `,s1="/",a1="*",oi="",kU="comment",CU="declaration";function TU(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 C=m.match(mU);C&&(n+=C.length);var T=m.lastIndexOf(vU);r=~T?m.length-T:r+m.length}function i(){var m={line:n,column:r};return function(C){return C.position=new s(m),c(),C}}function s(m){this.start=m,this.end={line:n,column:r},this.source=t.source}s.prototype.content=e;function a(m){var C=new Error(t.source+":"+n+":"+r+": "+m);if(C.reason=m,C.filename=t.source,C.line=n,C.column=r,C.source=e,!t.silent)throw C}function u(m){var C=m.exec(e);if(C){var T=C[0];return o(T),e=e.slice(T.length),C}}function c(){u(hU)}function l(m){var C;for(m=m||[];C=p();)C!==!1&&m.push(C);return m}function p(){var m=i();if(!(s1!=e.charAt(0)||a1!=e.charAt(1))){for(var C=2;oi!=e.charAt(C)&&(a1!=e.charAt(C)||s1!=e.charAt(C+1));)++C;if(C+=2,oi===e.charAt(C-1))return a("End of comment missing");var T=e.slice(2,C-2);return r+=2,o(T),e=e.slice(C),r+=2,m({type:kU,comment:T})}}function g(){var m=i(),C=u(xU);if(C){if(p(),!u(yU))return a("property missing ':'");var T=u(bU),E=m({type:CU,property:l1(C[0].replace(i1,oi)),value:T?l1(T[0].replace(i1,oi)):oi});return u(SU),E}}function d(){var m=[];l(m);for(var C;C=g();)C!==!1&&(m.push(C),l(m));return m}return c(),d()}function l1(e){return e?e.replace(wU,oi):oi}c1.exports=TU});var p1=er(da=>{"use strict";var IU=da&&da.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(da,"__esModule",{value:!0});da.default=EU;var FU=IU(u1());function EU(e,t){let n=null;if(!e||typeof e!="string")return n;let r=(0,FU.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 g1=er(bc=>{"use strict";Object.defineProperty(bc,"__esModule",{value:!0});bc.camelCase=void 0;var AU=/^--[a-zA-Z0-9_-]+$/,PU=/-([a-z])/g,LU=/^[^-]+$/,MU=/^-(webkit|moz|ms|o|khtml)-/,BU=/^-(ms)-/,DU=function(e){return!e||LU.test(e)||AU.test(e)},RU=function(e,t){return t.toUpperCase()},d1=function(e,t){return"".concat(t,"-")},zU=function(e,t){return t===void 0&&(t={}),DU(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(BU,d1):e=e.replace(MU,d1),e.replace(PU,RU))};bc.camelCase=zU});var m1=er((Ih,f1)=>{"use strict";var NU=Ih&&Ih.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},OU=NU(p1()),_U=g1();function Th(e,t){var n={};return!e||typeof e!="string"||(0,OU.default)(e,function(r,o){r&&o&&(n[(0,_U.camelCase)(r,t)]=o)}),n}Th.default=Th;f1.exports=Th});var jT=er((Cpe,UT)=>{"use strict";var jc=Object.prototype.hasOwnProperty,$T=Object.prototype.toString,DT=Object.defineProperty,RT=Object.getOwnPropertyDescriptor,zT=function(t){return typeof Array.isArray=="function"?Array.isArray(t):$T.call(t)==="[object Array]"},NT=function(t){if(!t||$T.call(t)!=="[object Object]")return!1;var n=jc.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&jc.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var o;for(o in t);return typeof o>"u"||jc.call(t,o)},OT=function(t,n){DT&&n.name==="__proto__"?DT(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},_T=function(t,n){if(n==="__proto__")if(jc.call(t,n)){if(RT)return RT(t,n).value}else return;return t[n]};UT.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=_T(a,n),o=_T(t,n),a!==o&&(l&&o&&(NT(o)||(i=zT(o)))?(i?(i=!1,s=r&&zT(r)?r:[]):s=r&&NT(r)?r:{},OT(a,{name:n,newValue:e(l,s,o)})):typeof o<"u"&&OT(a,{name:n,newValue:o}));return a}});import Ra from"react";import{addons as ou,types as Qx,experimental_getStatusStore as EF}from"storybook/manager-api";import{AddonPanel as oV}from"storybook/internal/components";import Bt,{useState as kW,useEffect as CW}from"react";import{styled as mr}from"storybook/theming";import sy from"react";import{styled as Lt}from"storybook/theming";var ae="#ea580c",au="#c2410c",_a="#ff6b35";var ey=Lt.div(({theme:e})=>({fontFamily:e.typography.fonts.base,height:"100%",display:"flex",flexDirection:"column",backgroundColor:e.background.content,color:e.color.defaultText})),ty=Lt.div({flex:1,overflow:"auto",padding:"6px 20px 20px"}),go=Lt.div({marginBottom:"20px"}),fo=Lt.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})),as=Lt.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`}})),mn=Lt.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"}})),ny=Lt(mn)(({theme:e})=>({width:"auto",padding:`${e.layoutMargin*.6}px 28px ${e.layoutMargin*.6}px ${e.layoutMargin}px`,fontSize:e.typography.size.s1})),$a=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"}}),vn=Lt.button(({theme:e})=>({...$a(e),backgroundColor:e.color.secondary,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),qt=Lt.button(({theme:e})=>({...$a(e),backgroundColor:ae,color:e.color.inverseText,boxShadow:`0 2px 4px ${ae}4d`,"&:hover:not(:disabled)":{backgroundColor:au,transform:"translateY(-1px)",boxShadow:`0 4px 8px ${ae}66`}})),Br=Lt.button(({theme:e})=>({...$a(e),backgroundColor:"transparent",border:`1px solid ${e.appBorderColor}`,color:e.color.defaultText,"&:hover:not(:disabled)":{backgroundColor:e.background.hoverable}})),ry=Lt.button(({theme:e})=>({...$a(e),backgroundColor:e.color.negative,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),kn=Lt.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"}})),lu=Lt.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"}})),mo=Lt.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}})),ho=Lt(as)(({theme:e})=>({paddingLeft:`${e.layoutMargin*3}px`,backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:`${e.layoutMargin}px center`,backgroundSize:"14px"})),dV=Lt.div(({theme:e})=>({padding:`${e.layoutMargin*1.6}px`,borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content})),oy=Lt.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})),gV=Lt.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})),cu=Lt.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})),fV=Lt.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%)"}}})),iy=Lt.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}}),mV=Lt.div(({theme:e})=>({padding:"40px 20px",textAlign:"center",color:e.color.mediumdark})),hV=Lt.div(({theme:e})=>({fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,marginBottom:`${e.layoutMargin*.8}px`,color:e.color.defaultText})),xV=Lt.div(({theme:e})=>({fontSize:e.typography.size.s2,color:e.color.mediumdark}));var uu=({header:e,children:t,footer:n})=>sy.createElement(ey,null,e,sy.createElement(ty,null,t),n);import NF from"react";import{styled as OF}from"storybook/theming";var _F=OF.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})),pu=({toolbar:e})=>NF.createElement(_F,null,e);import FV from"react";import{styled as Ua}from"storybook/theming";var PV=Ua.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})),LV=Ua.div({display:"flex",flex:1}),MV=Ua(mo)(({theme:e,disabled:t})=>({padding:"6px 12px",...t?{color:e.color.mediumlight,cursor:"not-allowed",opacity:.5,"&:hover":{}}:{}})),BV=Ua.div({display:"flex",gap:"8px",alignItems:"center"});import Jt,{useState as Bf,useCallback as Pw,useEffect as Lw}from"react";import{styled as Jr}from"storybook/theming";import Oe,{useEffect as Sw}from"react";import{styled as at}from"storybook/theming";ke();je();Ne();lt();var ww=at.div({position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:1e4}),vw=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})),kD=at.div({display:"flex",alignItems:"center",gap:"12px",padding:"16px 16px 12px"}),CD=at.div({width:"36px",height:"36px",borderRadius:"50%",backgroundColor:ae,display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:"14px",fontWeight:700,flexShrink:0}),TD=at.div({display:"flex",flexDirection:"column",gap:"4px"}),ID=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"}),ED=at.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px 8px",fontSize:"14px",color:e.color.defaultText})),AD=at.span(({theme:e})=>({color:e.textMutedColor,fontSize:"13px"})),PD=at.span(({theme:e})=>({color:e.color.defaultText,fontSize:"15px",fontWeight:600})),LD=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"})),MD=at.div(({percent:e})=>({height:"100%",width:`${Math.min(100,Math.max(0,e))}%`,background:`linear-gradient(90deg, #f59e0b 0%, ${ae} 100%)`,transition:"width 0.3s ease"})),BD=at.div(({theme:e})=>({padding:"0 16px 14px",fontSize:"12px",color:e.textMutedColor})),DD=at.div(({theme:e})=>({height:"1px",backgroundColor:e.appBorderColor})),RD=at.button({width:"100%",padding:"14px 16px",background:"transparent",border:"none",color:ae,fontSize:"14px",fontWeight:500,textAlign:"left",cursor:"pointer",display:"flex",alignItems:"center",gap:"6px","&:hover":{backgroundColor:"rgba(0, 0, 0, 0.03)"}}),zD=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}})),ND=at.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px",borderBottom:`1px solid ${e.appBorderColor}`})),OD=at.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"10px",color:e.color.defaultText,fontSize:"14px",fontWeight:500})),_D=at.div(({theme:e})=>({width:"32px",height:"32px",borderRadius:"50%",backgroundColor:ae,display:"flex",alignItems:"center",justifyContent:"center",color:e.color.inverseText,fontSize:"14px",fontWeight:600})),$D=at.div({display:"flex",gap:"8px"}),kw=at(kn)({fontSize:"18px"}),UD=at.div({padding:"20px 16px"}),jD=at.div(({theme:e})=>({padding:"16px",borderRadius:"8px",background:"linear-gradient(135deg, #10B981 0%, #3B82F6 100%)",marginBottom:"16px",color:"#fff"})),HD=at.div({fontSize:"12px",fontWeight:500,opacity:.9,marginBottom:"4px"}),WD=at.div({fontSize:"28px",fontWeight:700}),VD=at.div({fontSize:"11px",opacity:.8,marginTop:"4px"}),GD=at.div(({theme:e})=>({padding:"16px",borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),qD=at.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),YD=at.div({display:"flex",alignItems:"center",gap:"8px"}),KD=at.span(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),XD=at.span(({theme:e})=>({fontSize:"10px",fontWeight:600,padding:"2px 6px",borderRadius:"4px",backgroundColor:ae,color:e.color.inverseText})),QD=at.button(({theme:e})=>({background:"none",border:"none",color:ae,fontSize:"12px",cursor:"pointer","&:hover":{textDecoration:"underline"}})),JD=at.div(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),ZD=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"?ae:e.background.hoverable,color:t==="primary"?e.color.inverseText:e.color.defaultText,"&:hover":{opacity:.9}})),eR=30*1e3,Cw=({onClose:e})=>{let{sessionToken:t,resetAuth:n,usageData:r,usageLastFetched:o,setUsageData:i}=we(),{featureFlags:s}=ce(),a=s.showCosts,u=r,c=!r&&t,l=async(m=!1)=>{if(!t)return;let C=o&&Date.now()-o<eR;if(!(!m&&C&&r))try{let T=G(),E=await ne(`${T}/api/addon/account`,{headers:{Authorization:`Bearer ${t}`}});if(E.ok){let I=await E.json();i(I)}}catch(T){y.error("Failed to fetch usage:",T)}};Sw(()=>{l()},[t]),Sw(()=>{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()},g=()=>{let m=G();window.open(`${m}/pricing`,"_blank")},d=()=>{let m=G();window.open(`${m}/pricing#add-credits`,"_blank")};if(t&&!a&&!c){let m=Math.floor(u?.creditBalance??0),T=Math.max(m,10),E=Math.max(0,T-m),I=T>0?m/T*100:0;return Oe.createElement(Oe.Fragment,null,Oe.createElement(ww,{onClick:e}),Oe.createElement(vw,{onClick:D=>D.stopPropagation(),style:{width:"320px"}},Oe.createElement(zD,{onClick:e,title:"Close"},"\xD7"),Oe.createElement(kD,null,Oe.createElement(CD,null,u?.email?u.email[0].toUpperCase():"U"),Oe.createElement(TD,null,Oe.createElement(ID,null,"UI Review"),Oe.createElement(FD,null,(u?.plan||"BETA").toUpperCase()))),Oe.createElement(ED,null,Oe.createElement(AD,null,"Credits"),Oe.createElement(PD,null,m," left")),Oe.createElement(LD,null,Oe.createElement(MD,{percent:I})),Oe.createElement(BD,null,E," used \xB7 ",m," remaining"),Oe.createElement(DD,null),Oe.createElement(RD,{onClick:d},"Get free credits \u2192")))}return Oe.createElement(Oe.Fragment,null,Oe.createElement(ww,{onClick:e}),Oe.createElement(vw,{onClick:m=>m.stopPropagation()},Oe.createElement(ND,null,Oe.createElement(OD,null,Oe.createElement(_D,null,u?.email?u.email[0].toUpperCase():"U"),Oe.createElement("span",null,u?.email||"Loading...")),Oe.createElement($D,null,Oe.createElement(kw,{onClick:p,title:"Sign out"},"\u2192"),Oe.createElement(kw,{onClick:e,title:"Close"},"\xD7"))),Oe.createElement(UD,null,c?Oe.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Loading..."):t?Oe.createElement(Oe.Fragment,null,Oe.createElement(jD,null,Oe.createElement(HD,null,"Credit Balance"),Oe.createElement(WD,null,"$",(u?.creditBalance??0).toFixed(2)),Oe.createElement(VD,null,(u?.creditBalance??0)<2?"Low balance - consider topping up":"Pay only for what you use")),Oe.createElement(GD,null,Oe.createElement(qD,null,Oe.createElement(YD,null,Oe.createElement(KD,null,"Current Plan"),Oe.createElement(XD,null,u?.plan||"Free")),Oe.createElement(QD,{onClick:g},"View detail >")),Oe.createElement(JD,null,"~$0.02-0.05 per review depending on complexity"),Oe.createElement(ZD,{onClick:d,style:{marginTop:"16px"}},"Add Credits"))):Oe.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Please sign in to view usage"))))};ke();import Ei from"react";import{styled as Tw}from"storybook/theming";je();ke();lt();Ne();var tR=Tw.div({display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"}),nR=Tw.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark})),rR={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}},Iw=()=>{let{userRole:e,roleOverride:t,setRoleOverride:n,setFeatureFlags:r}=ce(),{sessionToken:o}=we();return e!=="admin"?null:Ei.createElement(tR,null,Ei.createElement(nR,null,"View as:"),Ei.createElement(ny,{value:t??e,onChange:a=>{let u=a.target.value;if(u===e)n(null),o&&ne(`${G()}/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=rR[u];r(c);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(c))}catch{}}},style:{width:"auto",minWidth:"100px"}},Ei.createElement("option",{value:"admin"},"Admin"),Ei.createElement("option",{value:"beta"},"Beta Tester")),t&&Ei.createElement(iy,{variant:"warning"},"Previewing as ",t))};je();ke();lt();import mt,{useState as Ns,useCallback as Mf}from"react";import{styled as vr}from"storybook/theming";var oR="0.5.7",iR=[{value:"bug",label:"\u{1F41E} Bug \u2014 something broke"},{value:"ux",label:"\u{1F9ED} UX \u2014 confusing or slow"},{value:"feature",label:"\u2728 Feature \u2014 missing something"},{value:"praise",label:"\u{1F49A} Praise \u2014 works great"},{value:"other",label:"\u{1F4AC} Other"}],sR=vr.div({position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center"}),aR=vr.div(({theme:e})=>({backgroundColor:e.background.content,borderRadius:"12px",width:"460px",maxWidth:"94%",maxHeight:"90vh",overflow:"auto",boxShadow:"0 16px 48px rgba(0, 0, 0, 0.25)"})),lR=vr.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px 12px",borderBottom:`1px solid ${e.appBorderColor}`})),cR=vr.h3(({theme:e})=>({margin:0,fontSize:"15px",fontWeight:600,color:e.color.defaultText,display:"flex",alignItems:"center",gap:"8px"})),uR=vr.button(({theme:e})=>({background:"transparent",border:"none",fontSize:"20px",color:e.color.mediumdark,cursor:"pointer",padding:"0 6px",lineHeight:1,"&:hover":{color:e.color.defaultText}})),pR=vr.div({padding:"16px 20px",display:"flex",flexDirection:"column",gap:"14px"}),dR=vr.textarea(({theme:e})=>({width:"100%",minHeight:"110px",padding:"8px 10px",borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.defaultText,backgroundColor:e.background.app,resize:"vertical",boxSizing:"border-box","&:focus":{outline:"none",borderColor:ae}})),Fw=vr.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 20px 16px",borderTop:`1px solid ${e.appBorderColor}`,gap:"8px"})),Ew=vr.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s1,color:e.color.mediumdark,lineHeight:1.4})),gR=vr.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s1,color:e.color.negative})),fR=vr.div(({theme:e})=>({padding:"24px 20px",textAlign:"center",display:"flex",flexDirection:"column",gap:"10px","& h4":{margin:0,fontSize:"15px",fontWeight:600,color:e.color.positive},"& p":{margin:0,fontSize:e.typography.size.s2,color:e.color.mediumdark}}));function Aw({isOpen:e,onClose:t}){let{sessionToken:n,isConnected:r}=we(),{selectedProjectId:o}=Je(),{currentStoryId:i}=nt(),[s,a]=Ns("other"),[u,c]=Ns(""),[l,p]=Ns(!1),[g,d]=Ns(!1),[m,C]=Ns(null),T=Mf(()=>{c(""),a("other"),d(!1),C(null),p(!1)},[]),E=Mf(()=>{T(),t()},[T,t]),I=Mf(async D=>{if(D.preventDefault(),!u.trim()){C("Please write a message.");return}if(!r||!n){C("Sign in to send feedback.");return}p(!0),C(null);try{let R=await ne(`${G()}/api/feedback`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({message:u.trim(),severity:s,projectId:o||void 0,storyId:i||void 0,addonVersion:oR})});if(!R.ok){let _=await R.json().catch(()=>({}));throw new Error(_.error||`Request failed (${R.status})`)}d(!0)}catch(R){C(R instanceof Error?R.message:"Something went wrong")}finally{p(!1)}},[u,s,n,r,o,i]);return e?mt.createElement(sR,{onClick:E},mt.createElement(aR,{onClick:D=>D.stopPropagation()},mt.createElement(lR,null,mt.createElement(cR,null,mt.createElement("span",null,"\u{1F4AC}"),"Send feedback"),mt.createElement(uR,{onClick:E,"aria-label":"Close"},"\xD7")),g?mt.createElement(mt.Fragment,null,mt.createElement(fR,null,mt.createElement("h4",null,"Thanks \u2014 got it."),mt.createElement("p",null,"We read every message. If it's a bug, we'll likely follow up by email.")),mt.createElement(Fw,null,mt.createElement("span",null),mt.createElement(vn,{onClick:E},"Close"))):mt.createElement("form",{onSubmit:I},mt.createElement(pR,null,mt.createElement(go,null,mt.createElement(fo,{htmlFor:"feedback-severity"},"Type"),mt.createElement(mn,{id:"feedback-severity",value:s,onChange:D=>a(D.target.value),disabled:l},iR.map(D=>mt.createElement("option",{key:D.value,value:D.value},D.label)))),mt.createElement(go,null,mt.createElement(fo,{htmlFor:"feedback-message"},"What happened?"),mt.createElement(dR,{id:"feedback-message",value:u,onChange:D=>c(D.target.value),placeholder:"Tell us what you were doing, what you expected, and what happened.",disabled:l,autoFocus:!0,maxLength:5e3})),mt.createElement(Ew,null,"We auto-attach your current story and project so we can reproduce it. No screenshots sent."),m&&mt.createElement(gR,null,m)),mt.createElement(Fw,null,mt.createElement(Ew,null,i?`Context: ${i}`:"No story selected"),mt.createElement("div",{style:{display:"flex",gap:"8px"}},mt.createElement(vn,{type:"button",onClick:E,disabled:l},"Cancel"),mt.createElement(qt,{type:"submit",disabled:l||!u.trim()},l?"Sending\u2026":"Send")))))):null}ke();je();lt();var mR=Jr.div({display:"flex",alignItems:"center"}),Ai=Jr.div(({theme:e})=>({display:"flex",alignItems:"center",paddingLeft:"8px",borderLeft:`1px solid ${e.appBorderColor}`,"&:first-of-type":{paddingLeft:0,borderLeft:"none"}})),hR=Jr.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.secondary,fontWeight:e.typography.weight.bold,paddingRight:"8px",opacity:.8})),xR=Jr.div({position:"relative"}),yR=Jr.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`}})),Mw=Jr.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)"}})),bR=Jr.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)"}}}),SR=Jr.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}})),wR=Jr.button({position:"fixed",bottom:"20px",right:"20px",width:"48px",height:"48px",borderRadius:"50%",backgroundColor:ae,color:"white",border:"none",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"22px",cursor:"pointer",boxShadow:`0 4px 14px ${ae}66, 0 2px 4px rgba(0,0,0,0.1)`,transition:"all 0.2s ease",zIndex:9999,"&:hover":{transform:"scale(1.08)",boxShadow:`0 6px 20px ${ae}88, 0 3px 6px rgba(0,0,0,0.15)`},"&:active":{transform:"scale(0.96)"}}),vR=30*1e3,Df=({onOpenSettings:e})=>{let[t,n]=Bf(!1),[r,o]=Bf(!1),[i,s]=Bf(!1),{usageData:a,usageLastFetched:u,setUsageData:c,sessionToken:l}=we(),{userRole:p,roleOverride:g,featureFlags:d}=ce(),m=g??p;Lw(()=>{(async()=>{if(!(!l||u&&Date.now()-u<vR&&a)){s(!0);try{let _=G(),P=await ne(`${_}/api/addon/account`,{headers:{Authorization:`Bearer ${l}`}});if(P.ok){let z=await P.json();c(z)}}catch(_){console.error("Failed to fetch balance:",_)}finally{s(!1)}}})()},[l,u,a,c]),Lw(()=>{let D=()=>{document.visibilityState==="visible"&&t&&n(!1)},R=()=>{t&&n(!1)};return document.addEventListener("visibilitychange",D),window.addEventListener("focus",R),()=>{document.removeEventListener("visibilitychange",D),window.removeEventListener("focus",R)}},[t]);let C=Pw(()=>{n(!0)},[]),T=Pw(()=>{n(!1)},[]),E=a?.creditBalance??0,I=E<2&&!i;return Jt.createElement(mR,null,e&&Jt.createElement(Ai,null,Jt.createElement(SR,{onClick:e,title:"Settings"},Jt.createElement("span",{style:{fontSize:"14px"}},"\u2699"),"Settings")),l&&p==="admin"&&m==="admin"&&Jt.createElement(Ai,null,Jt.createElement(Iw,null)),Jt.createElement(Ai,null,Jt.createElement(hR,null,"v","0.5.9")),l&&d.showCosts&&Jt.createElement(Ai,null,Jt.createElement(Mw,{onClick:C,isLow:I,title:i?"Loading...":a?I?"Low balance - click to top up":"Credit balance - click for details":"Click to load balance"},i?Jt.createElement(bR,null):a?`$${E.toFixed(2)}`:"...")),l&&!d.showCosts&&a&&Jt.createElement(Ai,null,Jt.createElement(Mw,{onClick:C,isLow:Math.floor(E)<=3,title:`${Math.floor(E)} review credits remaining \u2014 click to manage`},"\u26A1 ",Math.floor(E))),Jt.createElement(Ai,null,Jt.createElement(xR,null,Jt.createElement(yR,{title:"Account & Usage",onClick:C},a?.email?a.email[0].toUpperCase():"?"),t&&Jt.createElement(Cw,{onClose:T}))),l&&Jt.createElement(wR,{onClick:()=>o(!0),title:"Send feedback","aria-label":"Send feedback"},"\u{1F4AC}"),Jt.createElement(Aw,{isOpen:r,onClose:()=>o(!1)}))};import Pt from"react";import{styled as pr}from"storybook/theming";import Ft from"react";ke();Ne();je();lt();import{useState as kR,useCallback as Pi,useRef as Bw,useEffect as CR}from"react";var vo=G();y.debug("[useAuth] Module loaded, APP_URL:",vo);var Os=()=>{let e=Bw(null),{sessionToken:t,apiKey:n,authMethod:r,deviceCode:o,userCode:i,verificationUri:s,isConnected:a,authError:u,setSessionToken:c,setApiKey:l,setAuthMethod:p,setDeviceCode:g,setUserCode:d,setVerificationUri:m,setPollingInterval:C,setAuthError:T,resetAuth:E}=we(),I=Bw(null),[D,R]=kR(null),_=Pi(async()=>{try{y.debug("[useAuth] Starting OAuth flow, requesting poll_code...");let k;try{k=await ne(`${vo}/api/addon/auth/oauth-poll`,{method:"POST"})}catch(S){let A=S instanceof Error&&S.message.includes("timed out")?`Cannot reach UI Parity server at ${vo}. Is the dashboard running?`:`Connection failed: ${vo} is not responding.`;T(A),y.error("[useAuth]",A);return}if(!k.ok)throw new Error("Failed to create poll code");let{poll_code:f}=await k.json();y.debug("[useAuth] Got poll_code:",f.substring(0,15)+"..."),R(`${vo}/addon/auth?poll_code=${f}`),y.debug("[useAuth] Starting OAuth poll for token..."),I.current&&clearInterval(I.current);let F=async()=>{try{let b=await(await fetch(`${vo}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:f})})).json();b.status==="authorized"&&b.session_token?(y.debug("[useAuth] \u2705 OAuth poll successful! Got token."),I.current&&(clearInterval(I.current),I.current=null),localStorage.setItem("uicopilot_session_token",b.session_token),c(b.session_token),R(null)):b.status==="expired"&&(y.debug("[useAuth] OAuth poll_code expired"),I.current&&(clearInterval(I.current),I.current=null))}catch(S){y.error("[useAuth] OAuth poll error:",S)}};I.current=setInterval(F,2e3),setTimeout(F,1e3)}catch(k){y.error("[useAuth] OAuth flow error:",k)}},[c]),P=Pi(async()=>{try{let k=await fetch(`${vo}/api/addon/auth/device`,{method:"POST"});if(!k.ok)throw new Error("Failed to start device code flow");let f=await k.json();g(f.device_code),d(f.user_code),m(f.verification_uri),window.open(f.verification_uri,"_blank"),z(f.device_code,f.interval*1e3)}catch(k){throw y.error("[useAuth] Device code flow error:",k),k}},[g,d,m]),z=Pi((k,f)=>{y.debug("[useAuth] Starting polling. Device code:",k,"Interval:",f),e.current&&clearInterval(e.current);let F=async()=>{try{let b=await(await fetch(`${vo}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:k})})).json();b.status==="authorized"?(y.debug("[useAuth] Device code authorization successful!"),e.current&&(clearInterval(e.current),e.current=null),g(null),d(null),m(null),localStorage.setItem("uicopilot_session_token",b.session_token),c(b.session_token),R(null)):(b.status==="expired"||b.status==="denied")&&(y.debug("[useAuth] Device code expired or denied"),e.current&&(clearInterval(e.current),e.current=null),g(null),d(null),m(null))}catch(S){y.error("[useAuth] Polling error:",S)}};e.current=setInterval(F,f),C(f)},[g,d,m,c,C]),x=Pi(()=>{e.current&&(clearInterval(e.current),e.current=null),g(null),d(null),m(null),C(null)},[g,d,m,C]),w=Pi(k=>{l(k),localStorage.setItem("uicopilot_api_key",k)},[l]),v=Pi(()=>{E(),e.current&&(clearInterval(e.current),e.current=null)},[E]);return CR(()=>()=>{e.current&&clearInterval(e.current),I.current&&clearInterval(I.current)},[]),{sessionToken:t,apiKey:n,authMethod:r,deviceCode:o,userCode:i,verificationUri:s,isConnected:a,authError:u,oauthUrl:D,setAuthMethod:p,startOAuth:_,startDeviceCode:P,cancelDeviceCode:x,saveApiKey:w,logout:v}};ke();Ne();je();lt();import{useCallback as Bl}from"react";var _s=G(),Zr=()=>{let{projects:e,selectedProjectId:t,loadingProjects:n,setProjects:r,setSelectedProjectId:o,setLoadingProjects:i,getSelectedProject:s}=Je(),{sessionToken:a}=we(),u=Bl(async()=>{if(!a){y.debug("[useProjects] No session token, skipping fetch");return}try{i(!0),y.debug("[useProjects] Fetching from:",`${_s}/api/projects`);let g=await ne(`${_s}/api/projects`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`}});if(g.ok){let d=await g.json();y.debug("[useProjects] Projects:",d.projects),r(d.projects||[])}else y.error("[useProjects] Failed to fetch projects:",g.status,g.statusText)}catch(g){y.error("[useProjects] Error fetching projects:",g)}finally{i(!1)}},[a,r,i]),c=Bl(async g=>{if(!a)throw new Error("Not authenticated");let d=await ne(`${_s}/api/projects`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(g)});if(!d.ok)throw new Error("Failed to create project");let m=await d.json();return await u(),m.project},[a,u]),l=Bl(async(g,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 ne(`${_s}/api/projects/${g}`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(m)})).ok)throw new Error("Failed to update project");await u()},[a,u]),p=Bl(async g=>{if(!a)throw new Error("Not authenticated");if(!(await ne(`${_s}/api/projects/${g}`,{method:"DELETE",headers:{Authorization:`Bearer ${a}`}})).ok)throw new Error("Failed to delete project");await u(),t===g&&o(null)},[a,t,u,o]);return{projects:e,selectedProjectId:t,selectedProject:s(),loadingProjects:n,setSelectedProjectId:o,fetchProjects:u,createProject:c,updateProject:l,deleteProject:p}};ke();var $s=()=>{let{showComponentBrowser:e,figmaFileUrl:t,currentMapping:n,mappingSource:r,loadingMapping:o,showFigmaQuality:i,setShowComponentBrowser:s,setFigmaFileUrl:a,setCurrentMapping:u,setMappingSource:c,setLoadingMapping:l,setShowFigmaQuality:p}=nt();return{showComponentBrowser:e,figmaFileUrl:t,currentMapping:n,mappingSource:r,loadingMapping:o,showFigmaQuality:i,setShowComponentBrowser:s,setFigmaFileUrl:a,setCurrentMapping:u,setMappingSource:c,setLoadingMapping:l,setShowFigmaQuality:p,openComponentBrowser:()=>s(!0),closeComponentBrowser:()=>s(!1)}};ke();_f();Vf();import{useCallback as Ks,useRef as Vl}from"react";Ne();function Ol(){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 _l=BigInt(4294967295),Kw=BigInt(32);function GR(e,t=!1){return t?{h:Number(e&_l),l:Number(e>>Kw&_l)}:{h:Number(e>>Kw&_l)|0,l:Number(e&_l)|0}}function Xw(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}=GR(e[i],t);[r[i],o[i]]=[s,a]}return[r,o]}var Qw=(e,t,n)=>e<<n|t>>>32-n,Jw=(e,t,n)=>t<<n|e>>>32-n,Zw=(e,t,n)=>t<<n-32|e>>>64-n,ev=(e,t,n)=>e<<n-32|t>>>64-n;function qR(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Gf(e,t=""){if(!Number.isSafeInteger(e)||e<0){let n=t&&`"${t}" `;throw new Error(`${n}expected integer >= 0, got ${e}`)}}function $l(e,t,n=""){let r=qR(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 qf(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 tv(e,t){$l(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 nv(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Yf(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}var YR=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 XR(e){for(let t=0;t<e.length;t++)e[t]=KR(e[t]);return e}var Kf=YR?e=>e:XR;function rv(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 ov=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var QR=BigInt(0),Vs=BigInt(1),JR=BigInt(2),ZR=BigInt(7),ez=BigInt(256),tz=BigInt(113),av=[],lv=[],cv=[];for(let e=0,t=Vs,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],av.push(2*(5*r+n)),lv.push((e+1)*(e+2)/2%64);let o=QR;for(let i=0;i<7;i++)t=(t<<Vs^(t>>ZR)*tz)%ez,t&JR&&(o^=Vs<<(Vs<<BigInt(i))-Vs);cv.push(o)}var uv=Xw(cv,!0),nz=uv[0],rz=uv[1],iv=(e,t,n)=>n>32?Zw(e,t,n):Qw(e,t,n),sv=(e,t,n)=>n>32?ev(e,t,n):Jw(e,t,n);function oz(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=iv(c,l,1)^n[a],g=sv(c,l,1)^n[a+1];for(let d=0;d<50;d+=10)e[s+d]^=p,e[s+d+1]^=g}let o=e[2],i=e[3];for(let s=0;s<24;s++){let a=lv[s],u=iv(o,i,a),c=sv(o,i,a),l=av[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]^=nz[r],e[1]^=rz[r]}Yf(n)}var Xf=class e{constructor(t,n,r,o=!1,i=24){tr(this,"state");tr(this,"pos",0);tr(this,"posOut",0);tr(this,"finished",!1);tr(this,"state32");tr(this,"destroyed",!1);tr(this,"blockLen");tr(this,"suffix");tr(this,"outputLen");tr(this,"enableXOF",!1);tr(this,"rounds");if(this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=i,Gf(r,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=nv(this.state)}clone(){return this._cloneInto()}keccak(){Kf(this.state32),oz(this.state32,this.rounds),Kf(this.state32),this.posOut=0,this.pos=0}update(t){qf(this),$l(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){qf(this,!1),$l(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 Gf(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(tv(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,Yf(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}},iz=(e,t,n,r={})=>rv(()=>new Xf(t,e,n),r);var pv=iz(6,72,64,ov(10));var sz=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Qf=Math.ceil,lr=Math.floor,Rn="[BigNumber Error] ",dv=Rn+"Number primitive has more than 15 significant digits: ",kr=1e14,Ve=14,Jf=9007199254740991,Zf=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],ko=1e7,sn=1e9;function gv(e){var t,n,r,o=I.prototype={constructor:I,toString:null,valueOf:null},i=new I(1),s=20,a=4,u=-7,c=21,l=-1e7,p=1e7,g=!1,d=1,m=0,C={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},T="0123456789abcdefghijklmnopqrstuvwxyz",E=!0;function I(x,w){var v,k,f,F,S,b,A,L,B=this;if(!(B instanceof I))return new I(x,w);if(w==null){if(x&&x._isBigNumber===!0){B.s=x.s,!x.c||x.e>p?B.c=B.e=null:x.e<l?B.c=[B.e=0]:(B.e=x.e,B.c=x.c.slice());return}if((b=typeof x=="number")&&x*0==0){if(B.s=1/x<0?(x=-x,-1):1,x===~~x){for(F=0,S=x;S>=10;S/=10,F++);F>p?B.c=B.e=null:(B.e=F,B.c=[x]);return}L=String(x)}else{if(!sz.test(L=String(x)))return r(B,L,b);B.s=L.charCodeAt(0)==45?(L=L.slice(1),-1):1}(F=L.indexOf("."))>-1&&(L=L.replace(".","")),(S=L.search(/e/i))>0?(F<0&&(F=S),F+=+L.slice(S+1),L=L.substring(0,S)):F<0&&(F=L.length)}else{if(Rt(w,2,T.length,"Base"),w==10&&E)return B=new I(x),P(B,s+B.e+1,a);if(L=String(x),b=typeof x=="number"){if(x*0!=0)return r(B,L,b,w);if(B.s=1/x<0?(L=L.slice(1),-1):1,I.DEBUG&&L.replace(/^0\.0*|\./,"").length>15)throw Error(dv+x)}else B.s=L.charCodeAt(0)===45?(L=L.slice(1),-1):1;for(v=T.slice(0,w),F=S=0,A=L.length;S<A;S++)if(v.indexOf(k=L.charAt(S))<0){if(k=="."){if(S>F){F=A;continue}}else if(!f&&(L==L.toUpperCase()&&(L=L.toLowerCase())||L==L.toLowerCase()&&(L=L.toUpperCase()))){f=!0,S=-1,F=0;continue}return r(B,String(x),b,w)}b=!1,L=n(L,w,10,B.s),(F=L.indexOf("."))>-1?L=L.replace(".",""):F=L.length}for(S=0;L.charCodeAt(S)===48;S++);for(A=L.length;L.charCodeAt(--A)===48;);if(L=L.slice(S,++A)){if(A-=S,b&&I.DEBUG&&A>15&&(x>Jf||x!==lr(x)))throw Error(dv+B.s*x);if((F=F-S-1)>p)B.c=B.e=null;else if(F<l)B.c=[B.e=0];else{if(B.e=F,B.c=[],S=(F+1)%Ve,F<0&&(S+=Ve),S<A){for(S&&B.c.push(+L.slice(0,S)),A-=Ve;S<A;)B.c.push(+L.slice(S,S+=Ve));S=Ve-(L=L.slice(S)).length}else S-=A;for(;S--;L+="0");B.c.push(+L)}}else B.c=[B.e=0]}I.clone=gv,I.ROUND_UP=0,I.ROUND_DOWN=1,I.ROUND_CEIL=2,I.ROUND_FLOOR=3,I.ROUND_HALF_UP=4,I.ROUND_HALF_DOWN=5,I.ROUND_HALF_EVEN=6,I.ROUND_HALF_CEIL=7,I.ROUND_HALF_FLOOR=8,I.EUCLID=9,I.config=I.set=function(x){var w,v;if(x!=null)if(typeof x=="object"){if(x.hasOwnProperty(w="DECIMAL_PLACES")&&(v=x[w],Rt(v,0,sn,w),s=v),x.hasOwnProperty(w="ROUNDING_MODE")&&(v=x[w],Rt(v,0,8,w),a=v),x.hasOwnProperty(w="EXPONENTIAL_AT")&&(v=x[w],v&&v.pop?(Rt(v[0],-sn,0,w),Rt(v[1],0,sn,w),u=v[0],c=v[1]):(Rt(v,-sn,sn,w),u=-(c=v<0?-v:v))),x.hasOwnProperty(w="RANGE"))if(v=x[w],v&&v.pop)Rt(v[0],-sn,-1,w),Rt(v[1],1,sn,w),l=v[0],p=v[1];else if(Rt(v,-sn,sn,w),v)l=-(p=v<0?-v:v);else throw Error(Rn+w+" cannot be zero: "+v);if(x.hasOwnProperty(w="CRYPTO"))if(v=x[w],v===!!v)if(v)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))g=v;else throw g=!v,Error(Rn+"crypto unavailable");else g=v;else throw Error(Rn+w+" not true or false: "+v);if(x.hasOwnProperty(w="MODULO_MODE")&&(v=x[w],Rt(v,0,9,w),d=v),x.hasOwnProperty(w="POW_PRECISION")&&(v=x[w],Rt(v,0,sn,w),m=v),x.hasOwnProperty(w="FORMAT"))if(v=x[w],typeof v=="object")C=v;else throw Error(Rn+w+" not an object: "+v);if(x.hasOwnProperty(w="ALPHABET"))if(v=x[w],typeof v=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(v))E=v.slice(0,10)=="0123456789",T=v;else throw Error(Rn+w+" invalid: "+v)}else throw Error(Rn+"Object expected: "+x);return{DECIMAL_PLACES:s,ROUNDING_MODE:a,EXPONENTIAL_AT:[u,c],RANGE:[l,p],CRYPTO:g,MODULO_MODE:d,POW_PRECISION:m,FORMAT:C,ALPHABET:T}},I.isBigNumber=function(x){if(!x||x._isBigNumber!==!0)return!1;if(!I.DEBUG)return!0;var w,v,k=x.c,f=x.e,F=x.s;e:if({}.toString.call(k)=="[object Array]"){if((F===1||F===-1)&&f>=-sn&&f<=sn&&f===lr(f)){if(k[0]===0){if(f===0&&k.length===1)return!0;break e}if(w=(f+1)%Ve,w<1&&(w+=Ve),String(k[0]).length==w){for(w=0;w<k.length;w++)if(v=k[w],v<0||v>=kr||v!==lr(v))break e;if(v!==0)return!0}}}else if(k===null&&f===null&&(F===null||F===1||F===-1))return!0;throw Error(Rn+"Invalid BigNumber: "+x)},I.maximum=I.max=function(){return R(arguments,-1)},I.minimum=I.min=function(){return R(arguments,1)},I.random=(function(){var x=9007199254740992,w=Math.random()*x&2097151?function(){return lr(Math.random()*x)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(v){var k,f,F,S,b,A=0,L=[],B=new I(i);if(v==null?v=s:Rt(v,0,sn),S=Qf(v/Ve),g)if(crypto.getRandomValues){for(k=crypto.getRandomValues(new Uint32Array(S*=2));A<S;)b=k[A]*131072+(k[A+1]>>>11),b>=9e15?(f=crypto.getRandomValues(new Uint32Array(2)),k[A]=f[0],k[A+1]=f[1]):(L.push(b%1e14),A+=2);A=S/2}else if(crypto.randomBytes){for(k=crypto.randomBytes(S*=7);A<S;)b=(k[A]&31)*281474976710656+k[A+1]*1099511627776+k[A+2]*4294967296+k[A+3]*16777216+(k[A+4]<<16)+(k[A+5]<<8)+k[A+6],b>=9e15?crypto.randomBytes(7).copy(k,A):(L.push(b%1e14),A+=7);A=S/7}else throw g=!1,Error(Rn+"crypto unavailable");if(!g)for(;A<S;)b=w(),b<9e15&&(L[A++]=b%1e14);for(S=L[--A],v%=Ve,S&&v&&(b=Zf[Ve-v],L[A]=lr(S/b)*b);L[A]===0;L.pop(),A--);if(A<0)L=[F=0];else{for(F=-1;L[0]===0;L.splice(0,1),F-=Ve);for(A=1,b=L[0];b>=10;b/=10,A++);A<Ve&&(F-=Ve-A)}return B.e=F,B.c=L,B}})(),I.sum=function(){for(var x=1,w=arguments,v=new I(w[0]);x<w.length;)v=v.plus(w[x++]);return v},n=(function(){var x="0123456789";function w(v,k,f,F){for(var S,b=[0],A,L=0,B=v.length;L<B;){for(A=b.length;A--;b[A]*=k);for(b[0]+=F.indexOf(v.charAt(L++)),S=0;S<b.length;S++)b[S]>f-1&&(b[S+1]==null&&(b[S+1]=0),b[S+1]+=b[S]/f|0,b[S]%=f)}return b.reverse()}return function(v,k,f,F,S){var b,A,L,B,N,h,j,H,M=v.indexOf("."),X=s,Z=a;for(M>=0&&(B=m,m=0,v=v.replace(".",""),H=new I(k),h=H.pow(v.length-M),m=B,H.c=w(eo(ar(h.c),h.e,"0"),10,f,x),H.e=H.c.length),j=w(v,k,f,S?(b=T,x):(b=x,T)),L=B=j.length;j[--B]==0;j.pop());if(!j[0])return b.charAt(0);if(M<0?--L:(h.c=j,h.e=L,h.s=F,h=t(h,H,X,Z,f),j=h.c,N=h.r,L=h.e),A=L+X+1,M=j[A],B=f/2,N=N||A<0||j[A+1]!=null,N=Z<4?(M!=null||N)&&(Z==0||Z==(h.s<0?3:2)):M>B||M==B&&(Z==4||N||Z==6&&j[A-1]&1||Z==(h.s<0?8:7)),A<1||!j[0])v=N?eo(b.charAt(1),-X,b.charAt(0)):b.charAt(0);else{if(j.length=A,N)for(--f;++j[--A]>f;)j[A]=0,A||(++L,j=[1].concat(j));for(B=j.length;!j[--B];);for(M=0,v="";M<=B;v+=b.charAt(j[M++]));v=eo(v,L,b.charAt(0))}return v}})(),t=(function(){function x(k,f,F){var S,b,A,L,B=0,N=k.length,h=f%ko,j=f/ko|0;for(k=k.slice();N--;)A=k[N]%ko,L=k[N]/ko|0,S=j*A+L*h,b=h*A+S%ko*ko+B,B=(b/F|0)+(S/ko|0)+j*L,k[N]=b%F;return B&&(k=[B].concat(k)),k}function w(k,f,F,S){var b,A;if(F!=S)A=F>S?1:-1;else for(b=A=0;b<F;b++)if(k[b]!=f[b]){A=k[b]>f[b]?1:-1;break}return A}function v(k,f,F,S){for(var b=0;F--;)k[F]-=b,b=k[F]<f[F]?1:0,k[F]=b*S+k[F]-f[F];for(;!k[0]&&k.length>1;k.splice(0,1));}return function(k,f,F,S,b){var A,L,B,N,h,j,H,M,X,Z,me,xe,oe,Ye,be,Ce,te,Le=k.s==f.s?1:-1,Ee=k.c,pe=f.c;if(!Ee||!Ee[0]||!pe||!pe[0])return new I(!k.s||!f.s||(Ee?pe&&Ee[0]==pe[0]:!pe)?NaN:Ee&&Ee[0]==0||!pe?Le*0:Le/0);for(M=new I(Le),X=M.c=[],L=k.e-f.e,Le=F+L+1,b||(b=kr,L=cr(k.e/Ve)-cr(f.e/Ve),Le=Le/Ve|0),B=0;pe[B]==(Ee[B]||0);B++);if(pe[B]>(Ee[B]||0)&&L--,Le<0)X.push(1),N=!0;else{for(Ye=Ee.length,Ce=pe.length,B=0,Le+=2,h=lr(b/(pe[0]+1)),h>1&&(pe=x(pe,h,b),Ee=x(Ee,h,b),Ce=pe.length,Ye=Ee.length),oe=Ce,Z=Ee.slice(0,Ce),me=Z.length;me<Ce;Z[me++]=0);te=pe.slice(),te=[0].concat(te),be=pe[0],pe[1]>=b/2&&be++;do{if(h=0,A=w(pe,Z,Ce,me),A<0){if(xe=Z[0],Ce!=me&&(xe=xe*b+(Z[1]||0)),h=lr(xe/be),h>1)for(h>=b&&(h=b-1),j=x(pe,h,b),H=j.length,me=Z.length;w(j,Z,H,me)==1;)h--,v(j,Ce<H?te:pe,H,b),H=j.length,A=1;else h==0&&(A=h=1),j=pe.slice(),H=j.length;if(H<me&&(j=[0].concat(j)),v(Z,j,me,b),me=Z.length,A==-1)for(;w(pe,Z,Ce,me)<1;)h++,v(Z,Ce<me?te:pe,me,b),me=Z.length}else A===0&&(h++,Z=[0]);X[B++]=h,Z[0]?Z[me++]=Ee[oe]||0:(Z=[Ee[oe]],me=1)}while((oe++<Ye||Z[0]!=null)&&Le--);N=Z[0]!=null,X[0]||X.splice(0,1)}if(b==kr){for(B=1,Le=X[0];Le>=10;Le/=10,B++);P(M,F+(M.e=B+L*Ve-1)+1,S,N)}else M.e=L,M.r=+N;return M}})();function D(x,w,v,k){var f,F,S,b,A;if(v==null?v=a:Rt(v,0,8),!x.c)return x.toString();if(f=x.c[0],S=x.e,w==null)A=ar(x.c),A=k==1||k==2&&(S<=u||S>=c)?jl(A,S):eo(A,S,"0");else if(x=P(new I(x),w,v),F=x.e,A=ar(x.c),b=A.length,k==1||k==2&&(w<=F||F<=u)){for(;b<w;A+="0",b++);A=jl(A,F)}else if(w-=S+(k===2&&F>S),A=eo(A,F,"0"),F+1>b){if(--w>0)for(A+=".";w--;A+="0");}else if(w+=F-b,w>0)for(F+1==b&&(A+=".");w--;A+="0");return x.s<0&&f?"-"+A:A}function R(x,w){for(var v,k,f=1,F=new I(x[0]);f<x.length;f++)k=new I(x[f]),(!k.s||(v=Jo(F,k))===w||v===0&&F.s===w)&&(F=k);return F}function _(x,w,v){for(var k=1,f=w.length;!w[--f];w.pop());for(f=w[0];f>=10;f/=10,k++);return(v=k+v*Ve-1)>p?x.c=x.e=null:v<l?x.c=[x.e=0]:(x.e=v,x.c=w),x}r=(function(){var x=/^(-?)0([xbo])(?=\w[\w.]*$)/i,w=/^([^.]+)\.$/,v=/^\.([^.]+)$/,k=/^-?(Infinity|NaN)$/,f=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(F,S,b,A){var L,B=b?S:S.replace(f,"");if(k.test(B))F.s=isNaN(B)?null:B<0?-1:1;else{if(!b&&(B=B.replace(x,function(N,h,j){return L=(j=j.toLowerCase())=="x"?16:j=="b"?2:8,!A||A==L?h:N}),A&&(L=A,B=B.replace(w,"$1").replace(v,"0.$1")),S!=B))return new I(B,L);if(I.DEBUG)throw Error(Rn+"Not a"+(A?" base "+A:"")+" number: "+S);F.s=null}F.c=F.e=null}})();function P(x,w,v,k){var f,F,S,b,A,L,B,N=x.c,h=Zf;if(N){e:{for(f=1,b=N[0];b>=10;b/=10,f++);if(F=w-f,F<0)F+=Ve,S=w,A=N[L=0],B=lr(A/h[f-S-1]%10);else if(L=Qf((F+1)/Ve),L>=N.length)if(k){for(;N.length<=L;N.push(0));A=B=0,f=1,F%=Ve,S=F-Ve+1}else break e;else{for(A=b=N[L],f=1;b>=10;b/=10,f++);F%=Ve,S=F-Ve+f,B=S<0?0:lr(A/h[f-S-1]%10)}if(k=k||w<0||N[L+1]!=null||(S<0?A:A%h[f-S-1]),k=v<4?(B||k)&&(v==0||v==(x.s<0?3:2)):B>5||B==5&&(v==4||k||v==6&&(F>0?S>0?A/h[f-S]:0:N[L-1])%10&1||v==(x.s<0?8:7)),w<1||!N[0])return N.length=0,k?(w-=x.e+1,N[0]=h[(Ve-w%Ve)%Ve],x.e=-w||0):N[0]=x.e=0,x;if(F==0?(N.length=L,b=1,L--):(N.length=L+1,b=h[Ve-F],N[L]=S>0?lr(A/h[f-S]%h[S])*b:0),k)for(;;)if(L==0){for(F=1,S=N[0];S>=10;S/=10,F++);for(S=N[0]+=b,b=1;S>=10;S/=10,b++);F!=b&&(x.e++,N[0]==kr&&(N[0]=1));break}else{if(N[L]+=b,N[L]!=kr)break;N[L--]=0,b=1}for(F=N.length;N[--F]===0;N.pop());}x.e>p?x.c=x.e=null:x.e<l&&(x.c=[x.e=0])}return x}function z(x){var w,v=x.e;return v===null?x.toString():(w=ar(x.c),w=v<=u||v>=c?jl(w,v):eo(w,v,"0"),x.s<0?"-"+w:w)}return o.absoluteValue=o.abs=function(){var x=new I(this);return x.s<0&&(x.s=1),x},o.comparedTo=function(x,w){return Jo(this,new I(x,w))},o.decimalPlaces=o.dp=function(x,w){var v,k,f,F=this;if(x!=null)return Rt(x,0,sn),w==null?w=a:Rt(w,0,8),P(new I(F),x+F.e+1,w);if(!(v=F.c))return null;if(k=((f=v.length-1)-cr(this.e/Ve))*Ve,f=v[f])for(;f%10==0;f/=10,k--);return k<0&&(k=0),k},o.dividedBy=o.div=function(x,w){return t(this,new I(x,w),s,a)},o.dividedToIntegerBy=o.idiv=function(x,w){return t(this,new I(x,w),0,1)},o.exponentiatedBy=o.pow=function(x,w){var v,k,f,F,S,b,A,L,B,N=this;if(x=new I(x),x.c&&!x.isInteger())throw Error(Rn+"Exponent not an integer: "+z(x));if(w!=null&&(w=new I(w)),b=x.e>14,!N.c||!N.c[0]||N.c[0]==1&&!N.e&&N.c.length==1||!x.c||!x.c[0])return B=new I(Math.pow(+z(N),b?x.s*(2-Ul(x)):+z(x))),w?B.mod(w):B;if(A=x.s<0,w){if(w.c?!w.c[0]:!w.s)return new I(NaN);k=!A&&N.isInteger()&&w.isInteger(),k&&(N=N.mod(w))}else{if(x.e>9&&(N.e>0||N.e<-1||(N.e==0?N.c[0]>1||b&&N.c[1]>=24e7:N.c[0]<8e13||b&&N.c[0]<=9999975e7)))return F=N.s<0&&Ul(x)?-0:0,N.e>-1&&(F=1/F),new I(A?1/F:F);m&&(F=Qf(m/Ve+2))}for(b?(v=new I(.5),A&&(x.s=1),L=Ul(x)):(f=Math.abs(+z(x)),L=f%2),B=new I(i);;){if(L){if(B=B.times(N),!B.c)break;F?B.c.length>F&&(B.c.length=F):k&&(B=B.mod(w))}if(f){if(f=lr(f/2),f===0)break;L=f%2}else if(x=x.times(v),P(x,x.e+1,1),x.e>14)L=Ul(x);else{if(f=+z(x),f===0)break;L=f%2}N=N.times(N),F?N.c&&N.c.length>F&&(N.c.length=F):k&&(N=N.mod(w))}return k?B:(A&&(B=i.div(B)),w?B.mod(w):F?P(B,m,a,S):B)},o.integerValue=function(x){var w=new I(this);return x==null?x=a:Rt(x,0,8),P(w,w.e+1,x)},o.isEqualTo=o.eq=function(x,w){return Jo(this,new I(x,w))===0},o.isFinite=function(){return!!this.c},o.isGreaterThan=o.gt=function(x,w){return Jo(this,new I(x,w))>0},o.isGreaterThanOrEqualTo=o.gte=function(x,w){return(w=Jo(this,new I(x,w)))===1||w===0},o.isInteger=function(){return!!this.c&&cr(this.e/Ve)>this.c.length-2},o.isLessThan=o.lt=function(x,w){return Jo(this,new I(x,w))<0},o.isLessThanOrEqualTo=o.lte=function(x,w){return(w=Jo(this,new I(x,w)))===-1||w===0},o.isNaN=function(){return!this.s},o.isNegative=function(){return this.s<0},o.isPositive=function(){return this.s>0},o.isZero=function(){return!!this.c&&this.c[0]==0},o.minus=function(x,w){var v,k,f,F,S=this,b=S.s;if(x=new I(x,w),w=x.s,!b||!w)return new I(NaN);if(b!=w)return x.s=-w,S.plus(x);var A=S.e/Ve,L=x.e/Ve,B=S.c,N=x.c;if(!A||!L){if(!B||!N)return B?(x.s=-w,x):new I(N?S:NaN);if(!B[0]||!N[0])return N[0]?(x.s=-w,x):new I(B[0]?S:a==3?-0:0)}if(A=cr(A),L=cr(L),B=B.slice(),b=A-L){for((F=b<0)?(b=-b,f=B):(L=A,f=N),f.reverse(),w=b;w--;f.push(0));f.reverse()}else for(k=(F=(b=B.length)<(w=N.length))?b:w,b=w=0;w<k;w++)if(B[w]!=N[w]){F=B[w]<N[w];break}if(F&&(f=B,B=N,N=f,x.s=-x.s),w=(k=N.length)-(v=B.length),w>0)for(;w--;B[v++]=0);for(w=kr-1;k>b;){if(B[--k]<N[k]){for(v=k;v&&!B[--v];B[v]=w);--B[v],B[k]+=kr}B[k]-=N[k]}for(;B[0]==0;B.splice(0,1),--L);return B[0]?_(x,B,L):(x.s=a==3?-1:1,x.c=[x.e=0],x)},o.modulo=o.mod=function(x,w){var v,k,f=this;return x=new I(x,w),!f.c||!x.s||x.c&&!x.c[0]?new I(NaN):!x.c||f.c&&!f.c[0]?new I(f):(d==9?(k=x.s,x.s=1,v=t(f,x,0,3),x.s=k,v.s*=k):v=t(f,x,0,d),x=f.minus(v.times(x)),!x.c[0]&&d==1&&(x.s=f.s),x)},o.multipliedBy=o.times=function(x,w){var v,k,f,F,S,b,A,L,B,N,h,j,H,M,X,Z=this,me=Z.c,xe=(x=new I(x,w)).c;if(!me||!xe||!me[0]||!xe[0])return!Z.s||!x.s||me&&!me[0]&&!xe||xe&&!xe[0]&&!me?x.c=x.e=x.s=null:(x.s*=Z.s,!me||!xe?x.c=x.e=null:(x.c=[0],x.e=0)),x;for(k=cr(Z.e/Ve)+cr(x.e/Ve),x.s*=Z.s,A=me.length,N=xe.length,A<N&&(H=me,me=xe,xe=H,f=A,A=N,N=f),f=A+N,H=[];f--;H.push(0));for(M=kr,X=ko,f=N;--f>=0;){for(v=0,h=xe[f]%X,j=xe[f]/X|0,S=A,F=f+S;F>f;)L=me[--S]%X,B=me[S]/X|0,b=j*L+B*h,L=h*L+b%X*X+H[F]+v,v=(L/M|0)+(b/X|0)+j*B,H[F--]=L%M;H[F]=v}return v?++k:H.splice(0,1),_(x,H,k)},o.negated=function(){var x=new I(this);return x.s=-x.s||null,x},o.plus=function(x,w){var v,k=this,f=k.s;if(x=new I(x,w),w=x.s,!f||!w)return new I(NaN);if(f!=w)return x.s=-w,k.minus(x);var F=k.e/Ve,S=x.e/Ve,b=k.c,A=x.c;if(!F||!S){if(!b||!A)return new I(f/0);if(!b[0]||!A[0])return A[0]?x:new I(b[0]?k:f*0)}if(F=cr(F),S=cr(S),b=b.slice(),f=F-S){for(f>0?(S=F,v=A):(f=-f,v=b),v.reverse();f--;v.push(0));v.reverse()}for(f=b.length,w=A.length,f-w<0&&(v=A,A=b,b=v,w=f),f=0;w;)f=(b[--w]=b[w]+A[w]+f)/kr|0,b[w]=kr===b[w]?0:b[w]%kr;return f&&(b=[f].concat(b),++S),_(x,b,S)},o.precision=o.sd=function(x,w){var v,k,f,F=this;if(x!=null&&x!==!!x)return Rt(x,1,sn),w==null?w=a:Rt(w,0,8),P(new I(F),x,w);if(!(v=F.c))return null;if(f=v.length-1,k=f*Ve+1,f=v[f]){for(;f%10==0;f/=10,k--);for(f=v[0];f>=10;f/=10,k++);}return x&&F.e+1>k&&(k=F.e+1),k},o.shiftedBy=function(x){return Rt(x,-Jf,Jf),this.times("1e"+x)},o.squareRoot=o.sqrt=function(){var x,w,v,k,f,F=this,S=F.c,b=F.s,A=F.e,L=s+4,B=new I("0.5");if(b!==1||!S||!S[0])return new I(!b||b<0&&(!S||S[0])?NaN:S?F:1/0);if(b=Math.sqrt(+z(F)),b==0||b==1/0?(w=ar(S),(w.length+A)%2==0&&(w+="0"),b=Math.sqrt(+w),A=cr((A+1)/2)-(A<0||A%2),b==1/0?w="5e"+A:(w=b.toExponential(),w=w.slice(0,w.indexOf("e")+1)+A),v=new I(w)):v=new I(b+""),v.c[0]){for(A=v.e,b=A+L,b<3&&(b=0);;)if(f=v,v=B.times(f.plus(t(F,f,L,1))),ar(f.c).slice(0,b)===(w=ar(v.c)).slice(0,b))if(v.e<A&&--b,w=w.slice(b-3,b+1),w=="9999"||!k&&w=="4999"){if(!k&&(P(f,f.e+s+2,0),f.times(f).eq(F))){v=f;break}L+=4,b+=4,k=1}else{(!+w||!+w.slice(1)&&w.charAt(0)=="5")&&(P(v,v.e+s+2,1),x=!v.times(v).eq(F));break}}return P(v,v.e+s+1,a,x)},o.toExponential=function(x,w){return x!=null&&(Rt(x,0,sn),x++),D(this,x,w,1)},o.toFixed=function(x,w){return x!=null&&(Rt(x,0,sn),x=x+this.e+1),D(this,x,w)},o.toFormat=function(x,w,v){var k,f=this;if(v==null)x!=null&&w&&typeof w=="object"?(v=w,w=null):x&&typeof x=="object"?(v=x,x=w=null):v=C;else if(typeof v!="object")throw Error(Rn+"Argument not an object: "+v);if(k=f.toFixed(x,w),f.c){var F,S=k.split("."),b=+v.groupSize,A=+v.secondaryGroupSize,L=v.groupSeparator||"",B=S[0],N=S[1],h=f.s<0,j=h?B.slice(1):B,H=j.length;if(A&&(F=b,b=A,A=F,H-=F),b>0&&H>0){for(F=H%b||b,B=j.substr(0,F);F<H;F+=b)B+=L+j.substr(F,b);A>0&&(B+=L+j.slice(F)),h&&(B="-"+B)}k=N?B+(v.decimalSeparator||"")+((A=+v.fractionGroupSize)?N.replace(new RegExp("\\d{"+A+"}\\B","g"),"$&"+(v.fractionGroupSeparator||"")):N):B}return(v.prefix||"")+k+(v.suffix||"")},o.toFraction=function(x){var w,v,k,f,F,S,b,A,L,B,N,h,j=this,H=j.c;if(x!=null&&(b=new I(x),!b.isInteger()&&(b.c||b.s!==1)||b.lt(i)))throw Error(Rn+"Argument "+(b.isInteger()?"out of range: ":"not an integer: ")+z(b));if(!H)return new I(j);for(w=new I(i),L=v=new I(i),k=A=new I(i),h=ar(H),F=w.e=h.length-j.e-1,w.c[0]=Zf[(S=F%Ve)<0?Ve+S:S],x=!x||b.comparedTo(w)>0?F>0?w:L:b,S=p,p=1/0,b=new I(h),A.c[0]=0;B=t(b,w,0,1),f=v.plus(B.times(k)),f.comparedTo(x)!=1;)v=k,k=f,L=A.plus(B.times(f=L)),A=f,w=b.minus(B.times(f=w)),b=f;return f=t(x.minus(v),k,0,1),A=A.plus(f.times(L)),v=v.plus(f.times(k)),A.s=L.s=j.s,F=F*2,N=t(L,k,F,a).minus(j).abs().comparedTo(t(A,v,F,a).minus(j).abs())<1?[L,k]:[A,v],p=S,N},o.toNumber=function(){return+z(this)},o.toPrecision=function(x,w){return x!=null&&Rt(x,1,sn),D(this,x,w,2)},o.toString=function(x){var w,v=this,k=v.s,f=v.e;return f===null?k?(w="Infinity",k<0&&(w="-"+w)):w="NaN":(x==null?w=f<=u||f>=c?jl(ar(v.c),f):eo(ar(v.c),f,"0"):x===10&&E?(v=P(new I(v),s+f+1,a),w=eo(ar(v.c),v.e,"0")):(Rt(x,2,T.length,"Base"),w=n(eo(ar(v.c),f,"0"),10,x,k,!0)),k<0&&v.c[0]&&(w="-"+w)),w},o.valueOf=o.toJSON=function(){return z(this)},o._isBigNumber=!0,o[Symbol.toStringTag]="BigNumber",o[Symbol.for("nodejs.util.inspect.custom")]=o.valueOf,e!=null&&I.set(e),I}function cr(e){var t=e|0;return e>0||e===t?t:t-1}function ar(e){for(var t,n,r=1,o=e.length,i=e[0]+"";r<o;){for(t=e[r++]+"",n=Ve-t.length;n--;t="0"+t);i+=t}for(o=i.length;i.charCodeAt(--o)===48;);return i.slice(0,o+1||1)}function 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!==lr(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 Ul(e){var t=e.c.length-1;return cr(e.e/Ve)==t&&e.c[t]%2!=0}function jl(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function eo(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 az=gv(),fv=az;var lz=24,Gs=32,cz=()=>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,tm=cz(),em=(e=4,t=tm)=>{let n="";for(;n.length<e;)n=n+Math.floor(t()*36).toString(36);return n};function uz(e){let t=new fv(0);for(let n of e.values())t=t.multipliedBy(256).plus(n);return t}var hv=(e="")=>{let t=new TextEncoder;return uz(pv(t.encode(e))).toString(36).slice(1)},mv=Array.from({length:26},(e,t)=>String.fromCharCode(t+97)),pz=e=>mv[Math.floor(e()*mv.length)],dz=({globalObj:e=typeof global<"u"?global:typeof window<"u"?window:{},random:t=tm}={})=>{let n=Object.keys(e).toString(),r=n.length?n+em(Gs,t):em(Gs,t);return hv(r).substring(0,Gs)},gz=e=>()=>e++,fz=476782367,xv=({random:e=tm,counter:t=gz(Math.floor(e()*fz)),length:n=lz,fingerprint:r=dz({random:e})}={})=>{if(n>Gs)throw new Error(`Length must be between 2 and ${Gs}. Received: ${n}`);return function(){let i=pz(e),s=Date.now().toString(36),a=t().toString(36),u=em(n,e),c=`${s+u+a+r}`;return`${i+hv(c).substring(1,n)}`}},Co=mz(xv);function mz(e){let t;return()=>(t||(t=e()),t())}var yz=Oa(Sv());Rs();Ne();var Hl=/\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*-\s*(.+)/g;function bz(e){return e.replace(/\*\*/g,"").replace(/\*/g,"").replace(/__/g,"").replace(/_/g," ").trim()}function nm(e,t){let n=[],r=e.split(`
15
+ `);for(let s=0;s<r.length;s++){let a=bz(r[s]),u=Hl.exec(a);if(u){let[,c,l,,p]=u,g=Sz(l),d=wz(r,s+1),m={id:Co(),reviewId:t,type:c.trim(),severity:g,title:p.trim(),description:d.description,file:d.file,lineNumber:d.lineNumber,property:d.property,currentValue:d.currentValue,suggestedValue:d.suggestedValue,suggestedCode:d.suggestedCode,suggestedFix:d.suggestedFix,fixTarget:d.fixTarget,fixRequired:d.fixRequired,status:"pending",selectedForFix:!1,createdAt:new Date};n.push(m)}Hl.lastIndex=0}return n.map(s=>{let a=Ds(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 Sz(e){let t=e.toLowerCase().trim();return t.includes("critical")||t.includes("high")?"critical":t.includes("major")||t.includes("medium")?"major":"minor"}function wz(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||Hl.test(i)){Hl.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}Ne();var qs=null,wv=0,vz=3e4;async function kz(){let e=Date.now();if(qs&&e-wv<vz)return qs;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 qs=n.entries||n.stories||{},wv=e,y.debug("[storyFilePaths] Fetched index.json, entries:",Object.keys(qs).length),qs}catch(t){throw y.error("[storyFilePaths] Error fetching index.json:",t),t}}async function Ys(e){try{let n=(await kz())[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 rm(e,t){if(e==="css")return t.cssFile;if(e==="component")return t.componentFile;if(e==="story")return t.storyFile}function Cz(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 om(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):Cz(e.type,t)}Ne();function Tz(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 Iz(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 Fz(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 Ez(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 im(e){if(!e||e.length===0)return[];let t=e.filter(i=>!Fz(i)),n=[],r=[];for(let i of t){let s=Tz(i),a=Iz(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(Ez(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}Ne();var Az=[/Failed to fetch/i,/NetworkError/i,/network request failed/i,/load failed/i,/ERR_(NETWORK|INTERNET|CONNECTION|NAME_NOT_RESOLVED)/i,/timed out/i,/aborted/i],Pz=[/credits?/i,/Rate limit/i,/Figma connection expired/i,/Map.*to Figma|Figma mapping required/i,/No project selected/i,/Not authenticated/i,/No story/i,/Monthly review limit/i,/Upgrade your plan/i];function vv(e){let t=e instanceof Error?e.message:typeof e=="string"?e:"Review failed";return Pz.some(n=>n.test(t))?t:Az.some(n=>n.test(t))?"Can't reach UI Parity. Check your internet connection and try again. If the dashboard URL is wrong, fix it in Settings.":/Unauthorized|401/i.test(t)?"Your session expired. Sign out and back in from Settings to continue.":/Internal Server Error|5\d\d|server error/i.test(t)?"UI Parity's servers had a hiccup. Try the review again in a moment. If it keeps failing, send feedback.":/parsing|SSE|stream|structured result|failed to receive/i.test(t)?"Review completed but the result was malformed. Try again, or send feedback if it keeps happening.":`Review failed: ${t}. Try again, or send feedback if this keeps happening.`}je();import{addons as Wl}from"storybook/manager-api";var sm="uireview/badge",Bi={REVIEW_START:"uireview/review-start",REVIEW_COMPLETE:"uireview/review-complete",REVIEW_ERROR:"uireview/review-error"};function Lz(e){return e.criticalCount>0||e.score<70?"status-value:error":e.majorCount>0||e.score<90?"status-value:warning":"status-value:success"}function Mz(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 Bz(e){return e.score>=90?`\u2713 Score ${e.score}`:e.score>=70?`\u26A0 Score ${e.score}`:`\u2717 Score ${e.score}`}function Di(){try{let e=localStorage.getItem("uicopilot_feature_flags");return e?!!JSON.parse(e).enableReviewBadges:!1}catch{return!1}}function Tv(e){if(Di())try{Wl.getChannel().emit(Bi.REVIEW_START,{storyId:e})}catch{}}function To(e,t){if(Di())try{Wl.getChannel().emit(Bi.REVIEW_COMPLETE,{storyId:e,summary:t})}catch{}}function Iv(e){if(Di())try{Wl.getChannel().emit(Bi.REVIEW_ERROR,{storyId:e})}catch{}}function kv(e){try{typeof e.unset=="function"?e.unset():typeof e.set=="function"&&e.set([])}catch{}}var Cv=null;function Fv(e){if(Cv!==null)return;let t=Wl.getChannel(),n=o=>i=>{Di()&&o(i)};t.on(Bi.REVIEW_START,n(({storyId:o})=>{e.set([{value:"status-value:pending",typeId:sm,storyId:o,title:"Reviewing...",description:"AI review in progress"}])})),t.on(Bi.REVIEW_COMPLETE,n(({storyId:o,summary:i})=>{e.set([{value:Lz(i),typeId:sm,storyId:o,title:Bz(i),description:Mz(i)}])})),t.on(Bi.REVIEW_ERROR,n(({storyId:o})=>{e.set([{value:"status-value:error",typeId:sm,storyId:o,title:"Review Failed",description:"An error occurred during review"}])}));let r=Di();r||kv(e),Cv=setInterval(()=>{let o=Di();o!==r&&(r=o,o||kv(e))},1500)}var am=G(),lm=180;function Io(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 cm=()=>{let{isReviewing:e,reviewError:t,reviewResults:n,showReviewMenu:r,severityFilter:o,showStreamingPanel:i,streamingPanelCollapsed:s,streamingMessages:a,streamingProgress:u,streamingStatus:c,selectedModels:l,setIsReviewing:p,setReviewError:g,setReviewResults:d,setShowReviewMenu:m,setSeverityFilter:C,setShowStreamingPanel:T,setStreamingPanelCollapsed:E,addStreamingMessage:I,updateStreamingMessage:D,clearStreamingMessages:R,setStreamingProgress:_,setStreamingStatus:P,setFullPrompt:z,setFullResponse:x,setFigmaImageUrl:w,storybookImageUrl:v,setStorybookImageUrl:k,setFigmaDimensions:f,setMultiModelResults:F,updateMultiModelStreamingMessages:S,setModelCompleted:b,setActiveModelId:A,resetReview:L,addReview:B,setReviewDetailTab:N,includeTextComparison:h,usePromptCache:j,setApplyFixesResult:H,featureFlags:M}=ce(),{sessionToken:X,usageData:Z,setUsageData:me}=we(),{selectedProjectId:xe}=Je(),{currentStoryId:oe,currentStoryName:Ye}=nt(),be=Vl(Z);be.current=Z;let Ce=Vl(null),te=Vl(null),Le=Vl({}),Ee=Ks((ge,tt)=>{I({role:ge,content:tt})},[I]),pe=Ks((ge,tt)=>{_(ge),P(tt)},[_,P]),At=Ks(async ge=>{let{isIteration:tt=!1,parentReviewId:he=null}=ge||{};if(!X)throw new Error("Not authenticated");if(!xe)throw new Error("No project selected");if(!oe||!Ye)throw new Error("No story is currently selected in Storybook");if(e){y.debug("[useAIReview] Review already in progress, ignoring duplicate request");return}let ie=Date.now();try{p(!0),g(null),d(null),N("issues"),H(null),oe&&M.enableReviewBadges&&Tv(oe),te.current&&clearTimeout(te.current),te.current=setTimeout(()=>{y.debug(`[useAIReview] Auto-stopping review after ${lm}s timeout`),Ce.current&&Ce.current.abort(),I({role:"system",content:`Review auto-stopped after ${lm} seconds timeout.`})},lm*1e3),z(""),x(""),T(!0),E(!1),R(),pe(0,"Starting review..."),pe(5,"Refreshing component preview..."),y.debug("[Review] Forcing iframe reload for fresh styles..."),await Ol(),y.debug("[Review] Iframe reloaded, styles should be fresh"),pe(20,"Capturing screenshot & extracting styles..."),y.debug("[Review] Starting parallel data collection...");let[Y,fe,se]=await Promise.all([zl({sessionToken:X||void 0}),Promise.resolve(Ws()),Promise.resolve(Wf())]);if(Y&&Y!==v&&(k(Y),y.debug("[Review] Storybook screenshot captured and set")),!fe)throw new Error("Failed to extract styles from component");let{computed:O,declared:U,markup:W,textElementStyles:Me,nestedElementStyles:_e}=fe;se?y.debug("[Review] DOM tree extracted:",{selector:se.selector,childrenCount:se.children.length}):(y.error("[Review] DOM tree extraction FAILED - domTree is null"),y.error("[Review] This will cause AI to use comparison table instead of tree comparison")),pe(50,"Preparing metadata..."),y.debug("[Review] Current story:",{id:oe,name:Ye});let xt=dt.getState().currentMapping?.figmaNodeId??null,Hn=dt.getState().figmaImageUrl;if(xt&&(y.debug("[Review] Using Figma node ID from store:",xt),Hn&&(pe(65,"Using existing Figma design..."),y.debug("[Review] Reusing already-loaded Figma image"))),!xt)try{let Qe=await fetch(`${am}/api/mappings?projectId=${xe}&storyId=${oe}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${X}`}});if(Qe.ok){let Dt=await Qe.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:",oe)}else y.debug("[Review] Failed to fetch mapping:",Qe.status)}catch(Qe){y.error("[Review] Error fetching mapping:",Qe)}if(xt&&!Hn){pe(65,"Fetching Figma design...");try{let Qe=await fetch(`${am}/api/figma/frames?projectId=${xe}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${X}`}});if(Qe.ok){let _t=(await Qe.json()).thumbnails?.[xt];_t?(w(_t),y.debug("[Review] Figma thumbnail fetched and displayed:",_t)):y.warn("[Review] No thumbnail found for node:",xt)}else y.warn("[Review] Failed to fetch Figma frames:",Qe.status)}catch(Qe){y.error("[Review] Error fetching Figma frames:",Qe)}}if(!xt)throw new Error('Figma mapping required. Please link this story to a Figma frame using the "Map to Figma" button before reviewing.');pe(80,"AI is analyzing your component..."),y.debug("[Review] Sending to streaming API...");let Zn={projectId:xe,storyId:oe,storyName:Ye,storybookScreenshot:Y,computedStyles:O,declaredStyles:U,textElementStyles:Me,nestedElementStyles:_e,componentMarkup:W,domTree:se,figmaNodeId:xt,figmaImageUrl:Hn||void 0,aiModels:l,includeTextComparison:h,usePromptCache:j,parentReviewId:tt?he:void 0,isIteration:tt};y.debug("[Review] Request payload:",{...Zn,storybookScreenshot:Y?`${Y.substring(0,50)}...`:null,domTree:se?{selector:se.selector,childrenCount:se.children.length}:null}),Ce.current=new AbortController;let Fn=await fetch(`${am}/api/review/stream`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${X}`},body:JSON.stringify(Zn),signal:Ce.current.signal});if(y.debug("[Review] Response status:",Fn.status,Fn.statusText),!Fn.ok){let Qe=await Fn.json();if(y.error("[Review] API error response:",Qe),Fn.status===429){let Dt=Qe.retryAfter||60;throw new Error(`Rate limit exceeded. Please wait ${Dt} seconds before trying again.`)}if(Fn.status===402){if(Qe.code==="INSUFFICIENT_CREDITS"){let Dt=Qe.details?.required??1,_t=Qe.details?.balance??0;throw new Error(`Not enough credits. This review requires ${Dt} credit(s) but you have ${_t}. Visit Settings to add more.`)}throw Qe.code==="SUBSCRIPTION_LIMIT_EXCEEDED"?new Error(Qe.message||"Monthly review limit reached. Upgrade your plan to continue."):new Error(Qe.message||"Payment required")}throw Fn.status===401&&Qe.code==="FIGMA_AUTH_EXPIRED"?new Error("Figma connection expired. Open Settings \u2192 Disconnect \u2192 Reconnect Figma to continue."):new Error(Qe.error||Qe.message||"Review request failed")}let po=Fn.body?.getReader(),Sn=new TextDecoder,Lr="",nn="",$e=null,su=null,Jx=l.length>1,jo={},is={},aV={};if(!po)throw new Error("Response body is not readable");let Zx=dt.getState().streamingMessages.length;for(Ee("assistant","");;){let{done:Qe,value:Dt}=await po.read();if(Qe)break;Lr+=Sn.decode(Dt,{stream:!0});let _t=Lr.split(`
17
+ `);Lr=_t.pop()||"";for(let Wn of _t)if(Wn.startsWith("data: ")){let un=Wn.slice(6);if(un==="[DONE]")continue;try{let re=JSON.parse(un);if(re.type!=="text"&&re.type!=="content"&&y.debug("[Review] SSE Event received:",re.type),re.type==="prompt")re.prompt&&(z(re.prompt),y.debug("[Review] Prompt received early"));else if(re.type==="model_started")y.debug("[Review] Model started:",re.modelId),jo[re.modelId]||(jo[re.modelId]="",is[re.modelId]=[{role:"assistant",content:""}]);else if(re.type==="text"||re.type==="content")if(Jx&&re.modelId){jo[re.modelId]||(jo[re.modelId]="",is[re.modelId]=[{role:"assistant",content:""}]),jo[re.modelId]+=re.content,is[re.modelId][0].content=jo[re.modelId],S(re.modelId,is[re.modelId]);let Gt=Object.entries(jo).map(([pn,st])=>`[${pn}]
18
18
  ${st}`).join(`
19
19
 
20
20
  ---
21
21
 
22
- `);z(Wx,Gt)}else Zt+=ne.content,z(Wx,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")),Hx&&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&&M(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",`
22
+ `);D(Zx,Gt)}else nn+=re.content,D(Zx,nn);else if(re.type==="model_completed")y.debug("[Review] Model completed:",re.modelId,re.complianceScore),b(re.modelId);else if(re.type==="figma_image")re.url&&(w(re.url),y.debug("[Review] Figma image URL received:",re.url));else if(re.type==="figma_dimensions")re.width&&re.height&&(f({width:re.width,height:re.height}),y.debug("[Review] Figma dimensions received:",re.width,"x",re.height));else if(re.type==="complete"||re.type==="result")$e=re,y.debug("[Review] Final result received! Type:",re.type),y.debug("[Review] Final result issues count:",re.issues?.length||0),y.debug("[Review] Final result score:",re.validation?.complianceScore),re.remainingCredits!=null&&be.current&&me({...be.current,creditBalance:re.remainingCredits,reviewCredits:Math.floor(re.remainingCredits)});else if(re.type==="all_complete")$e=re,y.debug("[Review] Multi-model results received:",Object.keys(re.byModel)),re.remainingCredits!=null&&be.current&&me({...be.current,creditBalance:re.remainingCredits,reviewCredits:Math.floor(re.remainingCredits)});else if(re.type==="error"||re.type==="model_error"){let Gt=new Error(re.message||re.error||"Streaming error");throw Gt.isServerError=!0,Gt}}catch(re){if(re.isServerError)throw re;let Gt=re instanceof Error?{message:re.message,name:re.name,stack:re.stack}:String(re);y.error("[Review] Error parsing SSE data:",Gt),y.error("[Review] Failed to parse data:",un.substring(0,200)+(un.length>200?"...":"")),su=re instanceof Error?re:new Error(String(re))}}}if(pe(100,"Review complete!"),!$e&&su&&(y.error("[Review] No final result received. Last parse error:",su),y.error("[Review] Streaming text available:",nn.length,"chars")),Jx&&$e?.type==="all_complete"){let Qe=Object.keys($e.byModel).reduce((_t,Wn)=>{let un=$e.byModel[Wn];return _t[Wn]={...un,fullResponse:un.response||un.fullResponse||"",fullPrompt:un.prompt||un.fullPrompt||"",streamingMessages:is[Wn]||[]},_t},{}),Dt=Object.keys($e.byModel)[0];F({byModel:Qe,activeModelId:Dt}),Qe[Dt]?.fullPrompt&&z(Qe[Dt].fullPrompt),y.debug("[Review] Multi-model results stored:",Object.keys($e.byModel));try{let _t=Co(),Wn=$e.byModel?.[Dt]?.issues,un=Wn&&Wn.length>0,re=un?Wn.map(de=>({id:Co(),reviewId:_t,dbId:de.dbId,type:de.type,severity:de.severity,title:de.description,description:de.description,property:de.property,expected:Io(de.expected),actual:Io(de.actual),currentValue:Io(de.actual),suggestedValue:Io(de.expected),source:de.source||"computed-styles",suggestedFix:de.suggestedFix,file:de.file,domElement:de.domElement,figmaElement:de.figmaElement,fixTarget:de.fixTarget,fixRequired:de.fixRequired,detectedBy:de.detectedBy,dismissed:de.dismissed??!1,dismissReason:de.dismissReason,dismissedAt:de.dismissed?new Date:void 0,_unreliable:de._unreliable,_validationError:de._validationError,figmaContext:de.figmaContext,relatedTo:Array.isArray(de.relatedTo)?de.relatedTo:void 0,status:"pending",selectedForFix:!1,createdAt:new Date})):nm(Qe[Dt]?.fullResponse||"",_t);y.debug("[Review] Multi-model issues source:",un?"API (server-side dismissal)":"client-side parsing"),y.debug("[Review] Multi-model issues count:",re.length,"issues");let Gt=re.filter(de=>de.dismissed).length;Gt>0&&(y.debug("[Review] Multi-model auto-dismissed:",Gt,"false positive issues"),Ee("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=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&&B.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&&M(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",`
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 pn=Le.current[oe];pn||(pn=await Ys(oe)||{storyFile:"",componentFile:"[Component].tsx",cssFile:"[Component].css",baseDir:""},pn.storyFile&&(Le.current[oe]=pn)),y.debug("[Review] Story file paths:",pn);let st=re.map(de=>({...de,file:de.file||rm(de.fixTarget,pn)||om(de,pn)}));if(st=im(st),y.debug("[Review] After de-duplication:",st.length,"issues"),!h){let de=st.length;st=st.filter(wn=>wn.property?.toLowerCase()!=="textcontent"&&!wn.description?.toLowerCase().includes("text content")),de!==st.length&&y.debug("[Review] Filtered out",de-st.length,"textContent issues (toggle OFF)")}let Mr=$e.validation?.complianceScore??Qe[Dt]?.complianceScore;if(y.debug("[Review] Multi-model score sources:",{firstModelId:Dt,validationScore:$e.validation?.complianceScore,modelScore:Qe[Dt]?.complianceScore,multiModelScore:Mr}),Mr==null){let wn=(Qe[Dt]?.fullResponse||"").match(/(?:\*?\*?(?:##?)?\s*)?SCORE:\s*(\d+)/i);Mr=wn?parseInt(wn[1],10):void 0,y.debug("[Review] Parsed multi-model score from response:",Mr)}let En;tt&&he&&(En=(dt.getState().reviewHistory.find(wn=>wn.id===he)?.iterationNumber||0)+1);let ss={id:_t,componentId:oe,storyId:oe,modelId:Dt,parentReviewId:tt&&he||void 0,iterationNumber:En,figmaFileKey:void 0,figmaNodeId:xt||void 0,figmaFileUrl:Hn||void 0,complianceScore:Mr,visualSimilarity:$e.visualSimilarity,issuesCount:st.filter(de=>!de.dismissed).length,issues:st,createdAt:new Date,reviewDurationMs:Date.now()-ie,costUsd:$e.costUsd,inputTokens:$e.inputTokens,outputTokens:$e.outputTokens,cacheCreationTokens:$e.cacheCreationTokens,cacheReadTokens:$e.cacheReadTokens};if(y.debug("[Review] Multi-model token data:",{costUsd:$e.costUsd,inputTokens:$e.inputTokens,outputTokens:$e.outputTokens,cacheCreationTokens:$e.cacheCreationTokens,cacheReadTokens:$e.cacheReadTokens,reviewTokens:ss.inputTokens}),B(ss),oe&&M.enableReviewBadges){let de=st.filter(wn=>!wn.dismissed);To(oe,{score:Mr??100,issueCount:de.length,criticalCount:de.filter(wn=>wn.severity==="critical").length,majorCount:de.filter(wn=>wn.severity==="major").length,minorCount:de.filter(wn=>wn.severity==="minor").length})}N("issues");let za=st.filter(de=>!de.dismissed).length;y.debug("[Review] Created multi-model review with",za,"active issues,",st.length-za,"dismissed");let Te=xt||dt.getState().currentMapping?.figmaNodeId;y.debug("[Review] Issue validation handled server-side. Active:",st.filter(de=>!de.dismissed).length,"Dismissed:",st.filter(de=>de.dismissed).length)}catch(_t){y.error("[Review] Failed to parse issues from multi-model response:",_t)}}else if($e){$e.prompt&&z($e.prompt),($e.response||nn)&&x($e.response||nn),$e.figmaImageUrl&&w($e.figmaImageUrl),y.debug("[Review] State updated with prompt, response, and screenshots");try{let Qe=Co(),Dt=$e.response||nn,_t=$e.issues,Wn=_t&&_t.length>0,un=Wn?_t.map(Te=>({id:Co(),reviewId:Qe,dbId:Te.dbId,type:Te.type,severity:Te.severity,title:Te.description,description:Te.description,property:Te.property,expected:Io(Te.expected),actual:Io(Te.actual),currentValue:Io(Te.actual),suggestedValue:Io(Te.expected),source:Te.source||"computed-styles",suggestedFix:Te.suggestedFix,file:Te.file,domElement:Te.domElement,figmaElement:Te.figmaElement,fixTarget:Te.fixTarget,fixRequired:Te.fixRequired,detectedBy:Te.detectedBy,dismissed:Te.dismissed??!1,dismissReason:Te.dismissReason,dismissedAt:Te.dismissed?new Date:void 0,_unreliable:Te._unreliable,_validationError:Te._validationError,figmaContext:Te.figmaContext,relatedTo:Array.isArray(Te.relatedTo)?Te.relatedTo:void 0,status:"pending",selectedForFix:!1,createdAt:new Date})):nm(Dt,Qe);y.debug("[Review] Issues source:",Wn?"API (server-side dismissal)":"client-side parsing"),y.debug("[Review] Issues count:",un.length,"issues");let re=un.filter(Te=>Te.dismissed).length;re>0&&(y.debug("[Review] Auto-dismissed:",re,"false positive issues"),Ee("system",`
27
27
 
28
28
  ---
29
29
 
30
- \u2705 ${ne} issue${ne>1?"s were":" was"} auto-dismissed as false positive${ne>1?"s":""} (values already match design spec). Score recalculated to reflect active issues only.`));let 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&&B.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&&B.enableReviewBadges&&pv(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,M,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:P,resetReview:L,getFilteredIssues:fe}};we();De();Ue();import{useCallback as AX}from"react";var BX=q();we();De();import{useEffect as fv,useRef as gv}from"react";import{useStorybookApi as az,useStorybookState as lz,addons as cz}from"storybook/manager-api";var mv="storyArgsUpdated",Zg=()=>{let e=az(),t=lz(),{currentStoryId:n,currentStoryName:r,setCurrentStoryId:o,setCurrentStoryName:i}=rt(),{clearStaleReviewsForStory:s,resetReview:a,isReviewing:u,isValidating:c}=se(),l=gv(null),p=gv(0);return fv(()=>{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]),fv(()=>{let f=cz.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(mv,m),()=>{f.off(mv,m),d&&clearTimeout(d)}},[n,a,u,c]),{currentStoryId:n,currentStoryName:r}};we();Ue();pt();import{useCallback as hv}from"react";import{addons as xv}from"storybook/manager-api";var yv=q(),Ho=()=>{let{currentMapping:e,loadingMapping:t,setCurrentMapping:n,refreshMappings:r}=rt(),{sessionToken:o}=Se(),{selectedProjectId:i}=Ze(),s=hv(async c=>{if(!o)throw new Error("Not authenticated");if(!i)throw new Error("No project selected");let l=await ie(`${yv}/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{xv.getChannel().emit("uireview/mappings-changed")}catch{}return p.mapping},[o,i,r]),a=hv(async c=>{if(!o)throw new Error("Not authenticated");if(!(await ie(`${yv}/api/mappings?id=${encodeURIComponent(c)}`,{method:"DELETE",headers:{Authorization:`Bearer ${o}`}})).ok)throw new Error("Failed to delete mapping");r();try{xv.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 bv,useRef as uz}from"react";import{useChannel as pz,addons as Sv}from"storybook/manager-api";De();var dz=3e4,fz="forceRemount";function gz(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 mz(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 hz="UICOPILOT/APPLY_FIXES",xz="UICOPILOT/FIX_STARTED",yz="UICOPILOT/FIX_COMPLETED",bz="UICOPILOT/FIX_FAILED",Sz="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=uz(null),l=em(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]);bv(()=>()=>l(),[l]),bv(()=>{let m=Sv.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=pz({[xz]:({issueId:m})=>{y.debug(`[useApplyFixes] Fix started for issue: ${m}`),a(m,{status:"applying"})},[yz]:({issueId:m,result:w})=>{y.debug(`[useApplyFixes] Fix completed for issue: ${m}`,w),s(m,"applied"),a(m,{status:"applied"})},[bz]:({issueId:m,error:w})=>{y.error(`[useApplyFixes] Fix failed for issue: ${m}`,w),s(m,"failed",w),a(m,{status:"failed",error:w})},[Sz]: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{Sv.getChannel().emit(fz,{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&&gz(z,R)){w.push(C);continue}if(mz(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 P=O.toLowerCase().split(".").pop()||"",M=["tsx","jsx","ts","js"].includes(P)?"component":"css";F.push({...C,targetFilePath:O,targetFileType:M})}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."}))},dz),p(hz,{issues:w.actionable,storybookRoot:n||void 0})},[p,r,o,i,f,n,l]),isApplying:r}};we();Ue();import{useState as eQ}from"react";var rQ=q();we();import{useState as Wo}from"react";Ue();De();pt();var wz=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(`${wz}/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 wv(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 vz=["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"],kz=["no changes required","no changes needed","no fix required","no fix needed","values already match","already matches","matches expected","correctly implemented","implementation is correct"],Cz=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:P,recalculateScore:M,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(`${Cz}/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)),L=b.filter(S=>!A.has(S.id));L.length>0&&(y.warn(`[useBatchGenerateFixes] ${L.length} issues not returned by API, marking as failed`),L.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=vz.some(qe=>J.includes(qe.toLowerCase())||J.replace(/[-_]/g,"").includes(qe.replace(/[-_]/g,""))),ae=kz.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 B=G?.programmaticallyVerified===!0;if(y.debug(`[useBatchGenerateFixes] Processing fix for issue ${S.issueId}:`,{isFalsePositive:j,isProgrammaticIssue:B,detectedBy:G?.detectedBy,noChangesNeeded:S.noChangesNeeded,fixStrategy:S.fixStrategy,title:G?.title?.substring(0,50)}),B&&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}"`),P(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`),M(),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`),wv(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 Tz=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(`${Tz}/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(P=>!P.dismissed),z=C.filter(P=>P.severity==="critical").length,R=C.filter(P=>P.severity==="major").length,O=C.filter(P=>P.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 Iz,useState as Fz,useRef as _l}from"react";import{useChannel as Ez}from"storybook/manager-api";var Az="UICOPILOT/WORKSPACE_PATH",vv="UICOPILOT/REQUEST_WORKSPACE_PATH",Pz=3e3,Lz=500,Mz=5,sm=()=>{let[e,t]=Fz({isSupported:!1,isDetecting:!0,workspacePath:null}),{setWorkspacePath:n}=se(),r=_l(!1),o=_l(null),i=_l(0),s=_l(null),a=Ez({[Az]:({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 Iz(()=>(y.debug("[useAutoApplySupport] Requesting workspace path from server (retry 0)..."),a(vv,{}),s.current=setInterval(()=>{!r.current&&i.current<Mz&&(i.current++,y.debug(`[useAutoApplySupport] Requesting workspace path from server (retry ${i.current})...`),a(vv,{}))},Lz),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}))}},Pz),()=>{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 Bz,useRef as Dz}from"react";var DQ=q(),Rz=new Set;function lm(){let{sessionToken:e}=Se(),{selectedProjectId:t}=Ze(),n=Dz(!1);Bz(()=>{t&&Rz.add(t)},[e,t])}we();import{useCallback as zz,useState as kv}from"react";function cm(){let[e,t]=kv(!1),[n,r]=kv(null),{currentStoryId:o}=rt(),{currentReviewId:i}=se();return{exportPDF:zz(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 Cv(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 Cv(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 Cv(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?Nz(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,P=0,M=!0;for(;O>0;){M||m.addPage();let g=M?F:l,x=M?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,P,s,E,0,0,s,E);let I=h.toDataURL("image/png");m.addImage(I,"PNG",l,g,p,b)}P+=E,O-=b,M=!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 Nz(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 Rv,useCallback as Ai}from"react";Ue();De();pt();import{useState as Kr,useEffect as $l,useRef as Ei,useCallback as um}from"react";var Oz=300;function Tv({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),P=Ei(1),M=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:B,figmaPage:J,limit:Z}=h.current;if(!j||!G)return;M.current&&M.current.abort();let oe=new AbortController;M.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),B.trim()&&qe.append("search",B.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)),P.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()?Oz:0;return g.current=setTimeout(()=>{P.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 B=await ie(`${j}/api/figma/frames?projectId=${S}&thumbnailIds=${D.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${G}`}});if(B.ok){let J=await B.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(()=>()=>{M.current&&M.current.abort(),g.current&&clearTimeout(g.current)},[]);let v=um(async()=>{let D=P.current+1;await T(D,!0)},[T]),A=um(()=>{E.current=!1,P.current=1,a([]),c({}),b(D=>D+1)},[]),L=s.length<l;return{frames:s,thumbnails:u,totalFrames:l,availablePages:f,recentlyAdded:m,isLoading:k,loadingMore:C,hasMore:L,loadMore:v,refresh:A,error:R}}Ue();De();pt();import{useState as Gs,useCallback as Ul,useRef as _z}from"react";function Iv({projectId:e}){let[t,n]=Gs({}),[r,o]=Gs({}),[i,s]=Gs(new Set),[a,u]=Gs(new Set),[c,l]=Gs({}),p=_z({}),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(P=>({...P,[k]:R.variants}));let O={};for(let P of R.variants)P.thumbnailCdnUrl&&(O[P.id]=P.thumbnailCdnUrl);o(P=>({...P,[k]:{...P[k]||{},...O}})),p.current[k]||(p.current[k]=new Set),Object.keys(O).forEach(P=>p.current[k].add(P))}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"),P=await ie(`${R}/api/figma/variants?projectId=${e}&componentSetId=${k}&thumbnailIds=${z.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${O}`}});if(P.ok){let M=await P.json();M.thumbnails&&Object.keys(M.thumbnails).length>0&&o(g=>({...g,[k]:{...g[k]||{},...M.thumbnails}})),Array.isArray(M.failed)&&M.failed.length>0&&l(g=>{let x=new Set(g[k]||[]);for(let b of M.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 Fv,useEffect as Ev,useRef as Av,useCallback as pm}from"react";function Pv({expandedSetId:e,availableFilters:t,filtersReady:n}){let[r,o]=Fv(null),[i,s]=Fv(!1),a=Av(null),u=Av(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]);Ev(()=>{c()},[c]),Ev(()=>{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 Lv(e,t,n){let r=[];return e&&r.push("COMPONENT_SET"),t&&r.push("FRAME"),n&&r.push("COMPONENT"),r.join(",")}function Mv(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 Bv(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 Dv(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=Lv(r,i,a),{frames:z,thumbnails:R,totalFrames:O,availablePages:P,recentlyAdded:M,isLoading:g,loadingMore:x,hasMore:b,loadMore:E,refresh:h,error:T}=Tv({projectId:e,typeFilter:C,search:c,figmaPage:p||void 0,limit:t,enabled:n&&!!C}),{variantChildren:I,variantThumbnails:v,variantFailed:A,loadingVariants:L,loadingThumbnails:D,fetchVariants:N,fetchVariantThumbnails:S,clearVariantsForSet:j,clearAllVariants:G}=Iv({projectId:e}),B=Rv(()=>{let te=Mv(I),Be=Bv(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=Pv({expandedSetId:J,availableFilters:B,filtersReady:B.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=Rv(()=>d.some(te=>te.value)?z.filter(te=>Dv(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]&&!L.has(te)&&N(te)},[w,I,L,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:P,recentlyAdded:M,showComponentSets:r,showFrames:i,showComponents:a,setShowComponentSets:o,setShowFrames:s,setShowComponents:u,variantFilters:d,availableFilters:B,handleFilterChange:qe,clearFilters:tt,expandedSets:w,toggleExpanded:ae,variantChildren:I,variantThumbnails:v,variantFailed:A,loadingVariants:L,loadingThumbnails:D,fetchVariantThumbnails:S,resolveThumbnail:Ve,filterSuggestion:Z.suggestion,filterSuggestionLoading:Z.isLoading,applySuggestedFilters:oe,dismissFilterSuggestion:Z.dismissSuggestion}}we();import{useEffect as Mr,useCallback as Wz,useState as Vz,useRef as Gz}from"react";import{useChannel as qz}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 zv(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 Uz=q();async function fm(e,t,n){let r=await ie(`${Uz}/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 jz=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(`${jz}/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 Hz=q();async function mm(e,t){let n=await ie(`${Hz}/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 Yz(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 Kz=q(),Xz="UICOPILOT/WORKSPACE_PATH",Qz="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:P}=se(),[M,g]=Vz([]),x=Gz(null);Mr(()=>{let h=T=>{T.origin.startsWith(Kz)&&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=qz({[Xz]:h=>{y.debug("[useDataInit] Received workspace path:",h.path),c(h.path)}});Mr(()=>{b(Qz)},[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")&&zv(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=>Yz(A)).filter(Boolean);v.length>0&&P(v)}}catch(I){I instanceof kn&&n(I.message),y.error("[useDataInit] Failed to fetch reviews:",I)}})(),()=>{h=!0}},[e,o,l]);let E=Wz(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(L=>({id:L.id,reviewId:h.id,type:L.type,severity:L.severity,title:L.description,description:L.description,file:void 0,lineNumber:void 0,property:L.property,currentValue:L.actual,suggestedValue:L.expected,suggestedCode:L.suggestedFix||void 0,status:L.status,dismissed:L.dismissed||!1,dismissReason:L.dismissReason,dismissedBy:L.dismissedBy,figmaContext:L.figmaContext,selectedForFix:!1,error:void 0,createdAt:new Date(L.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 L=h.issues.filter(j=>!j.dismissed),D=L.filter(j=>j.severity==="critical").length,N=L.filter(j=>j.severity==="major").length,S=L.filter(j=>j.severity==="minor").length;xo(A,{score:h.complianceScore,issueCount:L.length,criticalCount:D,majorCount:N,minorCount:S})}},[k,C,z,R,O]);Mr(()=>{if(M.length>0&&l&&x.current!==l){let h=M[0];h&&h.storyId===l&&(y.debug("[useDataInit] Auto-loading review:",h.id,"for:",l),x.current=l,E(h),F("issues"))}},[M,l,E,F])}import{styled as Ys}from"storybook/theming";var Jz=Ys.div({display:"flex",gap:"10px",marginTop:"8px"}),Nv=Ys.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.color.defaultText,cursor:"pointer"})),Zz=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"})),eN=Ys.div({display:"flex",alignItems:"center",gap:"8px"}),tN=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"})),Ov=()=>{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(Jz,null,Mt.createElement(Nv,null,Mt.createElement("input",{type:"radio",name:"authMethod",checked:t==="oauth",onChange:()=>n("oauth")}),"OAuth (Recommended)"),Mt.createElement(Nv,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(Zz,null,Mt.createElement(eN,null,Mt.createElement("span",{style:{fontSize:"18px"}},"\u2713"),Mt.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to UI Copilot")),Mt.createElement(tN,{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 nN=wr.div({marginBottom:"30px"}),rN=wr.div({display:"flex",gap:"8px",alignItems:"center"}),oN=wr(En)({flex:1}),iN=wr(en)({padding:"8px 12px",whiteSpace:"nowrap"}),sN=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"}),aN=wr.div({display:"flex",gap:"8px",marginTop:"12px"}),_v=wr(en)({fontSize:"12px",padding:"6px 12px"}),lN=wr(_v)(({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(nN,null,Yt.createElement(Kx,null,"Project"),Yt.createElement(rN,null,Yt.createElement(oN,{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(iN,{onClick:d,disabled:r,type:"button"},"+ New")),s&&Yt.createElement(sN,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(aN,null,Yt.createElement(_v,{onClick:m,disabled:u||!l.name.trim()},u?"Creating...":"Create"),Yt.createElement(lN,{onClick:()=>{a(!1),p({name:"",storybookRoot:"",figmaFileUrl:""})}},"Cancel"))))};import bt,{useState as Zm,useCallback as SC,useEffect as w$}from"react";import{styled as vr}from"storybook/theming";import So,{useState as km,useEffect as FN,useCallback as jv}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 cN}from"storybook/theming";var uN={autoLayout:"Auto Layout",componentStructure:"Structure",naming:"Naming",constraints:"Constraints",spacing:"Spacing",styles:"Styles",variants:"Variants"},pN=e=>e==="pass"?"\u2713":e==="warn"?"\u26A0":"\u2717",dN=zn.div({position:"relative",display:"inline-flex"}),fN=cN`
30
+ \u2705 ${re} issue${re>1?"s were":" was"} auto-dismissed as false positive${re>1?"s":""} (values already match design spec). Score recalculated to reflect active issues only.`));let Gt=$e.complianceScore??$e.validation?.complianceScore;if(y.debug("[Review] Score sources:",{directScore:$e.complianceScore,validationScore:$e.validation?.complianceScore,parsedScore:Gt}),Gt==null){let Te=Dt.match(/(?:\*?\*?(?:##?)?\s*)?SCORE:\s*(\d+)/i);Gt=Te?parseInt(Te[1],10):void 0,y.debug("[Review] Parsed score from response:",Gt)}let pn=Le.current[oe];pn||(pn=await Ys(oe)||{storyFile:"",componentFile:"[Component].tsx",cssFile:"[Component].css",baseDir:""},pn.storyFile&&(Le.current[oe]=pn)),y.debug("[Review] Story file paths:",pn);let st=un.map(Te=>({...Te,file:Te.file||rm(Te.fixTarget,pn)||om(Te,pn)}));if(st=im(st),y.debug("[Review] After de-duplication:",st.length,"issues"),!h){let Te=st.length;st=st.filter(de=>de.property?.toLowerCase()!=="textcontent"&&!de.description?.toLowerCase().includes("text content")),Te!==st.length&&y.debug("[Review] Filtered out",Te-st.length,"textContent issues (toggle OFF)")}let Mr;tt&&he&&(Mr=(dt.getState().reviewHistory.find(de=>de.id===he)?.iterationNumber||0)+1);let En={id:Qe,componentId:oe,storyId:oe,modelId:l[0],parentReviewId:tt&&he||void 0,iterationNumber:Mr,figmaFileKey:void 0,figmaNodeId:xt||void 0,figmaFileUrl:Hn||void 0,complianceScore:Gt,visualSimilarity:$e.visualSimilarity,issuesCount:st.filter(Te=>!Te.dismissed).length,issues:st,createdAt:new Date,reviewDurationMs:Date.now()-ie,costUsd:$e.costUsd,inputTokens:$e.inputTokens,outputTokens:$e.outputTokens,cacheCreationTokens:$e.cacheCreationTokens,cacheReadTokens:$e.cacheReadTokens,variantMismatch:$e.variantMismatch,storybookVariant:$e.storybookVariant,figmaVariant:$e.figmaVariant};if(y.debug("[useAIReview] About to call addReview with review:",{id:En.id,storyId:En.storyId,issueCount:En.issues?.length,complianceScore:En.complianceScore,createdAt:En.createdAt?.toISOString(),inputTokens:En.inputTokens,outputTokens:En.outputTokens,costUsd:En.costUsd,cacheCreationTokens:En.cacheCreationTokens,cacheReadTokens:En.cacheReadTokens}),B(En),y.debug("[useAIReview] addReview called successfully"),oe&&M.enableReviewBadges){let Te=st.filter(de=>!de.dismissed);To(oe,{score:Gt??100,issueCount:Te.length,criticalCount:Te.filter(de=>de.severity==="critical").length,majorCount:Te.filter(de=>de.severity==="major").length,minorCount:Te.filter(de=>de.severity==="minor").length})}N("issues");let ss=st.filter(Te=>!Te.dismissed).length;y.debug("[Review] Created review with",ss,"active issues,",st.length-ss,"dismissed");let za=xt||dt.getState().currentMapping?.figmaNodeId;y.debug("[Review] Validation check:",{figmaNodeId:xt,effectiveFigmaNodeIdSingle:za,hasSessionToken:!!X,selectedProjectId:xe,issueCount:st.length}),y.debug("[Review] Issue validation handled server-side. Active:",st.filter(Te=>!Te.dismissed).length,"Dismissed:",st.filter(Te=>Te.dismissed).length)}catch(Qe){y.error("[Review] Failed to parse issues:",Qe)}}else throw nn?(y.error("[Review] ERROR: No structured result received from backend!"),y.error("[Review] Streaming text length:",nn.length),y.error("[Review] This indicates a bug in SSE parsing or backend not sending complete event"),new Error("Review completed but failed to receive structured result. Check console for details.")):new Error("No results received from API")}catch(Y){if(Y instanceof Error&&Y.name==="AbortError"){y.debug("[useAIReview] Review cancelled by user"),pe(0,"Review cancelled");return}y.error("[useAIReview] Review error:",Y);let fe=vv(Y);throw g(fe),oe&&M.enableReviewBadges&&Iv(oe),pe(0,`Error: ${fe}`),Y}finally{p(!1),Ce.current=null,te.current&&(clearTimeout(te.current),te.current=null),me(null)}},[e,X,xe,oe,Ye,l,p,g,d,F,S,b,A,T,E,R,Ee,pe,D,k,w,z,x,me]),tn=Ks(()=>n?.issues?o==="all"?n.issues:n.issues.filter(ge=>ge.severity===o):[],[n,o]),Pr=Ks(()=>{Ce.current&&(y.debug("[useAIReview] Cancelling review..."),Ce.current.abort())},[]);return{isReviewing:e,reviewError:t,reviewResults:n,showReviewMenu:r,severityFilter:o,showStreamingPanel:i,streamingPanelCollapsed:s,streamingMessages:a,streamingProgress:u,streamingStatus:c,startReview:At,cancelReview:Pr,setShowReviewMenu:m,setSeverityFilter:C,setShowStreamingPanel:T,setStreamingPanelCollapsed:E,addStreamingMessage:I,updateStreamingMessage:D,clearStreamingMessages:R,setStreamingProgress:_,setStreamingStatus:P,resetReview:L,getFilteredIssues:tn}};ke();Ne();je();import{useCallback as yQ}from"react";var vQ=G();ke();Ne();import{useEffect as Ev,useRef as Av}from"react";import{useStorybookApi as Dz,useStorybookState as Rz,addons as zz}from"storybook/manager-api";var Pv="storyArgsUpdated",um=()=>{let e=Dz(),t=Rz(),{currentStoryId:n,currentStoryName:r,setCurrentStoryId:o,setCurrentStoryName:i}=nt(),{clearStaleReviewsForStory:s,resetReview:a,isReviewing:u,isValidating:c}=ce(),l=Av(null),p=Av(0);return Ev(()=>{let g=t.storyId;if(g){l.current!==g&&(y.debug("[useCurrentStory] Story changed from",l.current,"to",g),s(g),l.current=g,p.current=Date.now()),o(g);let d=e.getData(g),m=d?.name&&d.name!=="default"?`${d.title} / ${d.name}`:d?.title||g;i(m),y.debug("[useCurrentStory] Current story:",{storyId:g,fullName:m})}else o(null),i(""),l.current=null},[t.storyId,e,o,i,s]),Ev(()=>{let g=zz.getChannel(),d=null,m=C=>{if(C.storyId===n){if(u||c){y.debug("[useCurrentStory] Story args changed but review in progress, skipping reset");return}d&&clearTimeout(d),d=setTimeout(()=>{let{isReviewing:T,isValidating:E}=dt.getState();if(T||E){y.debug("[useCurrentStory] Story args changed but review started, skipping reset");return}if(Date.now()-p.current<2e3){y.debug("[useCurrentStory] Story args changed but story just navigated, skipping reset");return}y.debug("[useCurrentStory] Story args changed, clearing stale review"),a()},500)}};return g.on(Pv,m),()=>{g.off(Pv,m),d&&clearTimeout(d)}},[n,a,u,c]),{currentStoryId:n,currentStoryName:r}};ke();je();lt();import{useCallback as Lv}from"react";import{addons as Mv}from"storybook/manager-api";var Bv=G(),Zo=()=>{let{currentMapping:e,loadingMapping:t,setCurrentMapping:n,refreshMappings:r}=nt(),{sessionToken:o}=we(),{selectedProjectId:i}=Je(),s=Lv(async c=>{if(!o)throw new Error("Not authenticated");if(!i)throw new Error("No project selected");let l=await ne(`${Bv}/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{Mv.getChannel().emit("uireview/mappings-changed")}catch{}return p.mapping},[o,i,r]),a=Lv(async c=>{if(!o)throw new Error("Not authenticated");if(!(await ne(`${Bv}/api/mappings?id=${encodeURIComponent(c)}`,{method:"DELETE",headers:{Authorization:`Bearer ${o}`}})).ok)throw new Error("Failed to delete mapping");r();try{Mv.getChannel().emit("uireview/mappings-changed")}catch{}},[o,r]);return{currentMapping:e,loadingMapping:t,hasMapping:!!e,setCurrentMapping:n,createMapping:s,deleteMapping:a,refreshMappings:r}};Us();ke();import{useCallback as pm,useEffect as Dv,useRef as Nz}from"react";import{useChannel as Oz,addons as Rv}from"storybook/manager-api";Ne();var _z=3e4,$z="forceRemount";function Uz(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 jz(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 Hz="UICOPILOT/APPLY_FIXES",Wz="UICOPILOT/FIX_STARTED",Vz="UICOPILOT/FIX_COMPLETED",Gz="UICOPILOT/FIX_FAILED",qz="UICOPILOT/ALL_FIXES_APPLIED",dm=(e={})=>{let{onComplete:t,storybookRoot:n}=e,{isApplying:r,setIsApplying:o,setApplyFixesResult:i,updateIssueStatus:s,updateIssueGeneratedFix:a,setReviewDetailTab:u}=ce(),c=Nz(null),l=pm(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]);Dv(()=>()=>l(),[l]),Dv(()=>{let m=Rv.getChannel(),C=()=>{dt.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",C),()=>m.off("channelWSDisconnect",C)},[l,o,i]);let p=Oz({[Wz]:({issueId:m})=>{y.debug(`[useApplyFixes] Fix started for issue: ${m}`),a(m,{status:"applying"})},[Vz]:({issueId:m,result:C})=>{y.debug(`[useApplyFixes] Fix completed for issue: ${m}`,C),s(m,"applied"),a(m,{status:"applied"})},[Gz]:({issueId:m,error:C})=>{y.error(`[useApplyFixes] Fix failed for issue: ${m}`,C),s(m,"failed",C),a(m,{status:"failed",error:C})},[qz]: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{Rv.getChannel().emit($z,{storyId:dt.getState().currentStoryId}),y.debug("[useApplyFixes] FORCE_REMOUNT emitted")}catch(C){y.warn("[useApplyFixes] Failed to emit FORCE_REMOUNT:",C)}y.debug("[useApplyFixes] Reloading Storybook preview to load fresh CSS..."),await Ol(),y.debug("[useApplyFixes] Storybook preview reloaded")}t&&(y.debug("[useApplyFixes] Triggering screenshot refresh after fixes"),t()),y.debug("[useApplyFixes] Switching to Issues tab to show results"),u("issues")}}),g=pm(m=>{let C=[],T=[],E=[];for(let I of m){let D=I.currentValue||I.actual||"",R=I.suggestedValue||I.expected||"";if(D&&R&&Uz(D,R)){C.push(I);continue}if(jz(I)){T.push(I);continue}let _=I.generatedFix?.filePath||I.file||"";if(!_){y.warn(`[useApplyFixes] Skipping issue ${I.id} - no target file path`);continue}let P=_.toLowerCase().split(".").pop()||"",z=["tsx","jsx","ts","js"].includes(P)?"component":"css";E.push({...I,targetFilePath:_,targetFileType:z})}return{actionable:E,negligible:C,designTokens:T}},[]);return{applyFixes:pm(m=>{if(r){y.warn("[useApplyFixes] Already applying fixes");return}if(m.length===0){y.warn("[useApplyFixes] No issues to fix");return}let C=g(m);if(C.negligible.length>0&&y.debug(`[useApplyFixes] Filtered ${C.negligible.length} negligible issue(s)`),C.designTokens.length>0&&y.debug(`[useApplyFixes] Skipped ${C.designTokens.length} design token suggestion(s)`),C.actionable.length===0){y.warn("[useApplyFixes] No actionable issues to fix after filtering");return}let T=C.actionable.filter(D=>D.targetFileType==="css"),E=C.actionable.filter(D=>D.targetFileType==="component");if(y.debug("[useApplyFixes] Applying fixes:"),T.length>0){let D=[...new Set(T.map(R=>R.targetFilePath))];y.debug(` - ${T.length} CSS issue(s) in: ${D.join(", ")}`)}if(E.length>0){let D=[...new Set(E.map(R=>R.targetFilePath))];y.debug(` - ${E.length} component issue(s) in: ${D.join(", ")}`),y.warn(" \u26A0\uFE0F Component files will be modified - review changes carefully!")}if(!document.querySelector("#storybook-preview-iframe")?.contentWindow){y.error("[useApplyFixes] Storybook preview iframe not found \u2014 connection lost"),i({succeeded:0,failed:0,total:C.actionable.length,error:"Connection lost. Please reload the page and try again."});return}o(!0),l(),c.current=setTimeout(()=>{dt.getState().isApplying&&(y.error("[useApplyFixes] Apply timed out \u2014 no response from server"),o(!1),i({succeeded:0,failed:0,total:C.actionable.length,error:"Apply timed out. The Storybook server may have disconnected. Please reload the page and try again."}))},_z),p(Hz,{issues:C.actionable,storybookRoot:n||void 0})},[p,r,o,i,g,n,l]),isApplying:r}};ke();je();import{useState as HQ}from"react";var GQ=G();ke();import{useState as ei}from"react";je();Ne();lt();var Yz=G();async function Gl(e,t,n,r,o){if(!e)return y.warn("[DismissalSync] No database ID provided, skipping server sync"),{success:!1,error:"No database ID"};try{let i=await ne(`${Yz}/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 zv(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=>Gl(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"}}Rs();Vf();Us();Ne();je();var Kz=["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"],Xz=["no changes required","no changes needed","no fix required","no fix needed","values already match","already matches","matches expected","correctly implemented","implementation is correct"],Qz=G();function gm(){let[e,t]=ei(!1),[n,r]=ei(null),[o,i]=ei(null),[s,a]=ei(null),[u,c]=ei(null),[l,p]=ei(null),[g,d]=ei(null),{sessionToken:m}=we(),{selectedProjectId:C}=Je(),{currentStoryId:T,currentStoryName:E}=nt(),{workspacePath:I,updateIssueGeneratedFix:D,batchUpdateIssueGeneratedFixes:R,includeComponentIssues:_,dismissIssue:P,recalculateScore:z,addStreamingMessage:x}=ce();return{generateBatchFixes:async v=>{if(!m){r("Not authenticated");return}if(!C){r("No project selected");return}if(!T){r("No story selected");return}if(v.length===0){r("No issues provided");return}t(!0),r(null),i(null),c(null),p(null),a({total:v.length,completed:0});let k=v.map(f=>({issueId:f.id,generatedFix:{code:"",diffPreview:"",filePath:f.file||"",confidence:0,strategy:"",status:"generating"}}));R(k);try{y.debug("[useBatchGenerateFixes] Generating fixes for",v.length,"issues");let f=null;try{let h=Ws();h?.computed&&(f=h.computed,y.debug("[useBatchGenerateFixes] Extracted computed styles for fix context"))}catch(h){y.warn("[useBatchGenerateFixes] Could not extract computed styles:",h)}let F=null;try{F=await Ys(T),F&&y.debug("[useBatchGenerateFixes] Resolved file paths from index.json:",F)}catch(h){y.warn("[useBatchGenerateFixes] Could not resolve story file paths:",h)}let S=await fetch(`${Qz}/api/fixes/generate-batch`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${m}`},body:JSON.stringify({projectId:C,storyId:T,workspacePath:I,includeComponentIssues:_,computedStyles:f,storyFilePaths:F,reviewContext:{storyName:E||void 0,variantArgs:Li()||void 0},issues:v.map(h=>({id:h.id,dbId:h.dbId,title:h.title,description:h.description,property:h.property,currentValue:h.currentValue,suggestedValue:h.suggestedValue,file:h.file,lineNumber:h.lineNumber,severity:h.severity,type:h.type,fixTarget:h.fixTarget,domElement:h.domElement,figmaContext:h.figmaContext,suggestedFix:h.suggestedFix}))})});if(!S.ok){let h=await S.json().catch(()=>({}));throw new Error(h.error||"Batch fix generation failed")}let b=await S.json();if(!b.success)throw new Error(b.error||"Batch fix generation failed");if(y.debug("[useBatchGenerateFixes] Generated",b.result.fixes.length,"fixes"),b.result.storybookRoot&&(d(b.result.storybookRoot),y.debug("[useBatchGenerateFixes] Stored storybookRoot:",b.result.storybookRoot)),b.result.selfReview&&(p(b.result.selfReview),y.debug("[useBatchGenerateFixes] Self-review:",b.result.selfReview)),b.result.partialFailure){let{failedBatches:h,errors:j}=b.result.partialFailure;y.warn(`[useBatchGenerateFixes] Partial failure: ${h.join(", ")} batch(es) failed`),y.warn("[useBatchGenerateFixes] Errors:",j),r(`Some fixes couldn't be generated (${h.join(", ")}): ${j[0]||"Unknown error"}`)}a({total:v.length,completed:b.result.fixes.length});let A=new Set(b.result.fixes.map(h=>h.issueId)),L=v.filter(h=>!A.has(h.id));L.length>0&&(y.warn(`[useBatchGenerateFixes] ${L.length} issues not returned by API, marking as failed`),L.forEach(h=>{D(h.id,{code:"",diffPreview:"",filePath:h.file||"",confidence:0,strategy:"skipped",status:"failed",error:"Fix generation skipped by server"})})),b.timing&&(i({durationSec:b.timing.durationSec,issueCount:b.timing.issueCount,avgPerIssueSec:b.timing.avgPerIssueSec}),y.debug(`[useBatchGenerateFixes] Generation took ${b.timing.durationSec}s for ${b.timing.issueCount} issues`)),b.result?.usage&&(c({inputTokens:b.result.usage.inputTokens||0,outputTokens:b.result.usage.outputTokens||0,costUsd:b.result.usage.costUsd||0,modelId:b.result.usage.modelId||"unknown",provider:b.result.usage.provider||"unknown"}),y.debug(`[useBatchGenerateFixes] Token usage: ${b.result.usage.inputTokens} in, ${b.result.usage.outputTokens} out, $${b.result.usage.costUsd?.toFixed(4)}`));let B=[],N=[];if(b.result.fixes.forEach(h=>{let j=h.noChangesNeeded===!0;if(!j){let X=(h.fixStrategy||"").toLowerCase(),Z=(h.generatedCode||"").toLowerCase(),me=(h.diffPreview||"").toLowerCase(),xe=Kz.some(Ye=>X.includes(Ye.toLowerCase())||X.replace(/[-_]/g,"").includes(Ye.replace(/[-_]/g,""))),oe=Xz.some(Ye=>Z.includes(Ye)||me.includes(Ye));j=xe||oe}let H=v.find(X=>X.id===h.issueId);if(j&&H){let X=H.suggestedValue,Z=H.currentValue;X&&Z&&!Ko(X,Z)&&(y.debug(`[useBatchGenerateFixes] SAFETY CHECK: values differ (expected="${X}", actual="${Z}"), NOT auto-dismissing issue ${h.issueId}`),j=!1)}let M=H?.programmaticallyVerified===!0;if(y.debug(`[useBatchGenerateFixes] Processing fix for issue ${h.issueId}:`,{isFalsePositive:j,isProgrammaticIssue:M,detectedBy:H?.detectedBy,noChangesNeeded:h.noChangesNeeded,fixStrategy:h.fixStrategy,title:H?.title?.substring(0,50)}),M&&j&&(y.debug(`[useBatchGenerateFixes] SKIPPING auto-dismiss for programmatic issue ${h.issueId} (detectedBy: ${H?.detectedBy})`),j=!1),j){let X=`Auto-dismissed: ${h.fixStrategy} - values already match`;y.debug(`[useBatchGenerateFixes] Auto-dismissing issue ${h.issueId} - noChangesNeeded: ${h.noChangesNeeded}, strategy: "${h.fixStrategy}"`),P(h.issueId,X),B.push({localId:h.issueId,dbId:H?.dbId,dismissReason:X}),N.push({issueId:h.issueId,generatedFix:{code:h.generatedCode||"",diffPreview:h.diffPreview||"",filePath:h.filePath,confidence:h.confidence,strategy:h.fixStrategy,status:"ready",error:void 0,noChangesExplanation:h.noChangesExplanation}})}else{let X=h.error||h.fixStrategy==="skipped"?"failed":"ready";N.push({issueId:h.issueId,generatedFix:{code:h.generatedCode,diffPreview:h.diffPreview,filePath:h.filePath,confidence:h.confidence,strategy:h.fixStrategy,status:X,error:h.error,noChangesExplanation:h.noChangesExplanation}})}}),N.length>0&&(y.debug(`[useBatchGenerateFixes] Applying ${N.length} fix updates in batch`),R(N)),B.length>0){if(y.debug(`[useBatchGenerateFixes] Auto-dismissed ${B.length} false positive(s), recalculating score`),z(),m){let j=B.filter(H=>H.dbId).map(H=>({dbId:H.dbId,dismissed:!0,dismissReason:H.dismissReason,dismissedBy:"system"}));j.length>0&&(y.debug(`[useBatchGenerateFixes] Syncing ${j.length} dismissals to server`),zv(j,m).then(H=>{H.success?y.debug(`[useBatchGenerateFixes] Server score updated to: ${H.newScore}`):y.warn("[useBatchGenerateFixes] Failed to sync dismissals:",H.error)}).catch(H=>{y.error("[useBatchGenerateFixes] Error syncing dismissals:",H)}))}let h=B.length===1?"1 issue was auto-dismissed as a false positive (values already match the design). The compliance score has been recalculated.":`${B.length} issues were auto-dismissed as false positives (values already match the design). The compliance score has been recalculated.`;x({role:"system",content:h})}y.debug("[useBatchGenerateFixes] Updated",b.result.fixes.length,"issues with fixes")}catch(f){y.error("[useBatchGenerateFixes] Failed to generate batch fixes:",f),r(f?.message||"Failed to generate batch fixes");let F=v.map(S=>({issueId:S.id,generatedFix:{code:"",diffPreview:"",filePath:S.file||"",confidence:0,strategy:"",status:"failed",error:f?.message||"Failed to generate fix"}}));R(F)}finally{t(!1),setTimeout(()=>a(null),1500)}},isGenerating:e,error:n,timing:o,progress:s,usage:u,selfReview:l,lastStorybookRoot:g}}ke();Ne();je();lt();import{useState as fm,useCallback as mm}from"react";var Jz=G();function hm(){let[e,t]=fm([]),[n,r]=fm(!1),[o,i]=fm(null),{sessionToken:s}=we(),{selectedProjectId:a}=Je(),{currentStoryId:u}=nt(),{setReviewResults:c}=ce(),l=mm(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 ne(`${Jz}/api/reviews/list?${d.toString()}`,{method:"GET",credentials:"include",headers:{Authorization:`Bearer ${s}`}});if(!m.ok){let T=await m.json().catch(()=>({}));throw new Error(T.error||"Failed to fetch reviews")}let C=await m.json();if(!C.success)throw new Error("Failed to fetch reviews");y.debug("[useReviewHistory] Fetched",C.reviews.length,"reviews for:",u),t(C.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=mm(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(I){y.error("[useReviewHistory] Failed to parse models:",I),m=["claude-sonnet-4-20250514"]}else m=d.models;let C=d.issues.map(I=>({id:I.id,reviewId:d.id,type:I.type,severity:I.severity,title:I.description,description:I.description,file:void 0,lineNumber:void 0,property:I.property,currentValue:I.actual,suggestedValue:I.expected,suggestedCode:I.suggestedFix||void 0,status:I.status,dismissed:I.dismissed||!1,dismissReason:I.dismissReason,dismissedBy:I.dismissedBy,selectedForFix:!1,error:void 0,createdAt:new Date(I.createdAt)})),T=d.completedAt&&d.createdAt?new Date(d.completedAt).getTime()-new Date(d.createdAt).getTime():void 0,E=d.storyId||"";if(c({id:d.id,componentId:"",storyId:E,modelId:m[0]||"claude-sonnet-4-5-20250929",complianceScore:d.complianceScore,issuesCount:d.issuesCount,issues:C,createdAt:new Date(d.createdAt),timestamp:new Date(d.createdAt).toISOString(),costUsd:d.costUsd,inputTokens:d.inputTokens,outputTokens:d.outputTokens,reviewDurationMs:T}),E){let I=d.issues.filter(P=>!P.dismissed),D=I.filter(P=>P.severity==="critical").length,R=I.filter(P=>P.severity==="major").length,_=I.filter(P=>P.severity==="minor").length;To(E,{score:d.complianceScore,issueCount:I.length,criticalCount:D,majorCount:R,minorCount:_})}},[c]),g=mm(d=>{let m=e.find(C=>C.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:g}}ke();Ne();import{useEffect as Zz,useState as eN,useRef as ql}from"react";import{useChannel as tN}from"storybook/manager-api";var nN="UICOPILOT/WORKSPACE_PATH",Nv="UICOPILOT/REQUEST_WORKSPACE_PATH",rN=3e3,oN=500,iN=5,xm=()=>{let[e,t]=eN({isSupported:!1,isDetecting:!0,workspacePath:null}),{setWorkspacePath:n}=ce(),r=ql(!1),o=ql(null),i=ql(0),s=ql(null),a=tN({[nN]:({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 Zz(()=>(y.debug("[useAutoApplySupport] Requesting workspace path from server (retry 0)..."),a(Nv,{}),s.current=setInterval(()=>{!r.current&&i.current<iN&&(i.current++,y.debug(`[useAutoApplySupport] Requesting workspace path from server (retry ${i.current})...`),a(Nv,{}))},oN),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}))}},rN),()=>{o.current&&clearTimeout(o.current),s.current&&clearInterval(s.current)}),[a]),e},ym=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}};ke();je();import{useEffect as sN,useRef as aN}from"react";var kJ=G(),lN=new Set;function bm(){let{sessionToken:e}=we(),{selectedProjectId:t}=Je(),n=aN(!1);sN(()=>{t&&lN.add(t)},[e,t])}ke();import{useCallback as IJ,useState as FJ}from"react";import{useState as ti,useMemo as Yv,useCallback as zi}from"react";je();Ne();lt();import{useState as to,useEffect as Yl,useRef as Ri,useCallback as Sm}from"react";var cN=300;function Ov({projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o=20,enabled:i=!0}){let[s,a]=to([]),[u,c]=to({}),[l,p]=to(0),[g,d]=to([]),[m,C]=to(new Set),[T,E]=to(!1),[I,D]=to(!1),[R,_]=to(null),P=Ri(1),z=Ri(null),x=Ri(null),[w,v]=to(0),k=Ri(!1),f=Ri({projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o});f.current={projectId:e,typeFilter:t,search:n,figmaPage:r,limit:o};let F=Sm(async(B,N,h=!1)=>{let{projectId:j,typeFilter:H,search:M,figmaPage:X,limit:Z}=f.current;if(!j||!H)return;z.current&&z.current.abort();let me=new AbortController;z.current=me,N?D(!0):E(!0),_(null);try{let xe=G(),oe=localStorage.getItem("uicopilot_session_token");if(!oe)throw new Error("Not authenticated. Please connect to UI Parity first.");let Ye=new URLSearchParams({projectId:j,page:String(B),limit:String(Z)});H&&Ye.append("type",H),X&&Ye.append("figmaPage",X),M.trim()&&Ye.append("search",M.trim()),h&&Ye.append("refresh","true");let be=await fetch(`${xe}/api/figma/frames?${Ye.toString()}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${oe}`},signal:me.signal});if(!be.ok){let pe=await be.json();throw new Error(pe.error||"Failed to fetch frames")}let Ce=await be.json(),te=Ce.frames||[],Le=Ce.thumbnails||{},Ee=be.headers.get("X-Cache-Status");if(te.length===0&&B===1&&!N&&!h&&!k.current&&Ee!=="HIT"){y.debug("[useFigmaFrameFetch] Empty result (cache miss), retrying with refresh=true"),k.current=!0,await F(1,!1,!0);return}N?(a(pe=>[...pe,...te]),c(pe=>({...pe,...Le}))):(a(te),c(Le)),p(Ce.total||te.length),Ce.pages&&d(Ce.pages),Ce.cacheDiff?.added&&C(new Set(Ce.cacheDiff.added)),P.current=B}catch(xe){if(xe instanceof DOMException&&xe.name==="AbortError")return;let oe=xe instanceof Error?xe.message:"Failed to fetch Figma frames.";_(oe),y.error("Error fetching frames:",xe)}finally{me.signal.aborted||(E(!1),D(!1))}},[]);Yl(()=>{if(!i||!e||!t)return;k.current=!1,x.current&&clearTimeout(x.current);let B=n.trim()?cN:0;return x.current=setTimeout(()=>{P.current=1,F(1,!1)},B),()=>{x.current&&clearTimeout(x.current)}},[e,t,n,r,i,w,F]);let S=Ri(new Set);Yl(()=>{if(s.length===0)return;let B={};for(let N of s)N.thumbnailCdnUrl&&!u[N.id]&&(B[N.id]=N.thumbnailCdnUrl);Object.keys(B).length>0&&c(N=>({...N,...B}))},[s]),Yl(()=>{if(s.length===0)return;let B=s.filter(h=>!h.thumbnailCdnUrl&&!u[h.id]&&!S.current.has(h.id)).map(h=>h.id);if(B.length===0)return;B.forEach(h=>S.current.add(h)),(async()=>{try{let{projectId:h}=f.current,j=G(),H=localStorage.getItem("uicopilot_session_token");if(!H||!h)return;let M=await ne(`${j}/api/figma/frames?projectId=${h}&thumbnailIds=${B.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${H}`}});if(M.ok){let X=await M.json();X.thumbnails&&Object.keys(X.thumbnails).length>0&&c(Z=>({...Z,...X.thumbnails}))}}catch(h){B.forEach(j=>S.current.delete(j)),y.error("Failed to fetch frame thumbnails:",h)}})()},[s,u]),Yl(()=>()=>{z.current&&z.current.abort(),x.current&&clearTimeout(x.current)},[]);let b=Sm(async()=>{let B=P.current+1;await F(B,!0)},[F]),A=Sm(()=>{k.current=!1,P.current=1,a([]),c({}),v(B=>B+1)},[]),L=s.length<l;return{frames:s,thumbnails:u,totalFrames:l,availablePages:g,recentlyAdded:m,isLoading:T,loadingMore:I,hasMore:L,loadMore:b,refresh:A,error:R}}je();Ne();lt();import{useState as Xs,useCallback as Kl,useRef as uN}from"react";function _v({projectId:e}){let[t,n]=Xs({}),[r,o]=Xs({}),[i,s]=Xs(new Set),[a,u]=Xs(new Set),[c,l]=Xs({}),p=uN({}),g=Kl(async T=>{if(!(!e||i.has(T))){s(E=>new Set(E).add(T));try{let E=G(),I=localStorage.getItem("uicopilot_session_token"),D=await ne(`${E}/api/figma/variants?projectId=${e}&componentSetId=${T}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`}});if(D.ok){let R=await D.json();if(R.variants){n(P=>({...P,[T]:R.variants}));let _={};for(let P of R.variants)P.thumbnailCdnUrl&&(_[P.id]=P.thumbnailCdnUrl);o(P=>({...P,[T]:{...P[T]||{},..._}})),p.current[T]||(p.current[T]=new Set),Object.keys(_).forEach(P=>p.current[T].add(P))}else o(_=>({..._,[T]:_[T]||{}}))}else o(R=>({...R,[T]:{}}))}catch(E){y.error("Failed to fetch variant metadata:",E),o(I=>({...I,[T]:{}}))}finally{s(E=>{let I=new Set(E);return I.delete(T),I})}}},[e,i]),d=Kl(async(T,E)=>{if(!e||E.length===0)return;p.current[T]||(p.current[T]=new Set);let I=r[T]||{},D=E.filter(R=>!p.current[T].has(R)&&!I[R]);if(D.length!==0){D.forEach(R=>p.current[T].add(R)),u(R=>new Set(R).add(T));try{let R=G(),_=localStorage.getItem("uicopilot_session_token"),P=await ne(`${R}/api/figma/variants?projectId=${e}&componentSetId=${T}&thumbnailIds=${D.join(",")}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${_}`}});if(P.ok){let z=await P.json();z.thumbnails&&Object.keys(z.thumbnails).length>0&&o(x=>({...x,[T]:{...x[T]||{},...z.thumbnails}})),Array.isArray(z.failed)&&z.failed.length>0&&l(x=>{let w=new Set(x[T]||[]);for(let v of z.failed)w.add(v);return{...x,[T]:w}})}}catch(R){y.error("Failed to fetch variant thumbnails:",R),D.forEach(_=>p.current[T]?.delete(_))}finally{u(R=>{let _=new Set(R);return _.delete(T),_})}}},[e]),m=Kl(T=>{o(E=>{let I={...E};return delete I[T],I}),n(E=>{let I={...E};return delete I[T],I}),l(E=>{let I={...E};return delete I[T],I}),delete p.current[T]},[]),C=Kl(()=>{o({}),n({}),l({}),p.current={}},[]);return{variantChildren:t,variantThumbnails:r,variantFailed:c,loadingVariants:i,loadingThumbnails:a,fetchVariants:g,fetchVariantThumbnails:d,clearVariantsForSet:m,clearAllVariants:C}}je();Us();ke();Ne();lt();import{useState as $v,useEffect as Uv,useRef as jv,useCallback as wm}from"react";function Hv({expandedSetId:e,availableFilters:t,filtersReady:n}){let[r,o]=$v(null),[i,s]=$v(!1),a=jv(null),u=jv(new Set),c=wm(async()=>{if(!e||!n||t.length===0||a.current===e||u.current.has(e))return;let g=Li();if(!g||Object.keys(g).length===0)return;let d=dt.getState().currentStoryId||"",m=d.replace(/--/g," / ").replace(/-/g," ").replace(/\b\w/g,C=>C.toUpperCase());a.current=e,s(!0),o(null);try{let C=G(),T=localStorage.getItem("uicopilot_session_token"),E=await ne(`${C}/api/figma/match-filters`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${T}`},body:JSON.stringify({storyName:m,storyId:d,storyArgs:g,availableFilters:t.map(I=>({property:I.property,values:I.values}))})});if(E.ok){let I=await E.json();I.confidence>0&&Object.keys(I.suggestedFilters).length>0&&(y.debug("[useFilterSuggestion] Suggestion:",I),o(I))}}catch(C){y.error("[useFilterSuggestion] Error:",C)}finally{s(!1)}},[e,t,n]);Uv(()=>{c()},[c]),Uv(()=>{e||(o(null),a.current=null)},[e]);let l=wm(()=>{},[]),p=wm(()=>{e&&u.current.add(e),o(null)},[e]);return{suggestion:r,isLoading:i,applySuggestion:l,dismissSuggestion:p}}function Wv(e,t,n){let r=[];return e&&r.push("COMPONENT_SET"),t&&r.push("FRAME"),n&&r.push("COMPONENT"),r.join(",")}function Vv(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 Gv(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 qv(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]=ti(!0),[i,s]=ti(!1),[a,u]=ti(!1),[c,l]=ti(""),[p,g]=ti(""),[d,m]=ti([]),[C,T]=ti(new Set),E=zi(te=>{l(te),d.length>0&&m([]),C.size>0&&T(new Set)},[d.length,C.size]),I=Wv(r,i,a),{frames:D,thumbnails:R,totalFrames:_,availablePages:P,recentlyAdded:z,isLoading:x,loadingMore:w,hasMore:v,loadMore:k,refresh:f,error:F}=Ov({projectId:e,typeFilter:I,search:c,figmaPage:p||void 0,limit:t,enabled:n&&!!I}),{variantChildren:S,variantThumbnails:b,variantFailed:A,loadingVariants:L,loadingThumbnails:B,fetchVariants:N,fetchVariantThumbnails:h,clearVariantsForSet:j,clearAllVariants:H}=_v({projectId:e}),M=Yv(()=>{let te=Vv(S),Le=Gv(D),Ee={};for(let pe of[...te,...Le])Ee[pe.property]||(Ee[pe.property]=new Set),pe.values.forEach(At=>Ee[pe.property].add(At));return Object.entries(Ee).map(([pe,At])=>({property:pe,values:Array.from(At).sort()}))},[S,D]),X=C.size===1?Array.from(C)[0]:null,Z=Hv({expandedSetId:X,availableFilters:M,filtersReady:M.length>0}),me=zi(()=>{if(!Z.suggestion)return;let{suggestedFilters:te}=Z.suggestion,Le=Object.entries(te).map(([Ee,pe])=>({property:Ee,value:pe}));m(Le),Z.dismissSuggestion()},[Z.suggestion]),xe=Yv(()=>d.some(te=>te.value)?D.filter(te=>qv(te,d,S[te.id])):D,[D,d,S]),oe=zi((te,Le)=>{Le.stopPropagation();let Ee=!C.has(te);T(pe=>{let At=new Set(pe);return At.has(te)?At.delete(te):At.add(te),At}),Ee&&!S[te]&&!L.has(te)?N(te):Ee||j(te)},[C,S,L,N,j]),Ye=zi((te,Le)=>{let Ee=Le===""?null:Le;m(pe=>pe.find(tn=>tn.property===te)?pe.map(tn=>tn.property===te?{...tn,value:Ee}:tn):[...pe,{property:te,value:Ee}])},[]),be=zi(()=>{m([])},[]),Ce=zi(te=>{let Le=D.find(Ee=>Ee.id===te);if(Le?.thumbnailCdnUrl)return Le.thumbnailCdnUrl;if(R[te])return R[te];for(let Ee of Object.values(b))if(Ee[te])return Ee[te]},[R,b]);return{frames:D,filteredFrames:xe,thumbnails:R,totalFrames:_,isLoading:x,loadingMore:w,hasMore:v,error:F,loadMore:k,refresh:f,search:c,setSearch:E,figmaPage:p,setFigmaPage:g,availablePages:P,recentlyAdded:z,showComponentSets:r,showFrames:i,showComponents:a,setShowComponentSets:o,setShowFrames:s,setShowComponents:u,variantFilters:d,availableFilters:M,handleFilterChange:Ye,clearFilters:be,expandedSets:C,toggleExpanded:oe,variantChildren:S,variantThumbnails:b,variantFailed:A,loadingVariants:L,loadingThumbnails:B,fetchVariantThumbnails:h,resolveThumbnail:Ce,filterSuggestion:Z.suggestion,filterSuggestionLoading:Z.isLoading,applySuggestedFilters:me,dismissFilterSuggestion:Z.dismissSuggestion}}ke();import{useEffect as Cr,useCallback as mN,useState as hN,useRef as xN}from"react";import{useChannel as yN}from"storybook/manager-api";function Fo(e){return e.status===401||e.status===403}var Tn=class extends Error{constructor(t){super(`Authentication failed (${t}). Please reconnect.`),this.name="AuthError",this.status=t}};function Kv(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 Parity: Error parsing Figma URL:",t),null}}Ne();je();je();lt();var pN=G();async function vm(e){let t=await ne(`${pN}/api/projects`,{headers:{Authorization:`Bearer ${e}`}});if(Fo(t))throw new Tn(t.status);return t.ok?(await t.json()).projects||[]:[]}je();lt();var dN=G();async function km(e,t){let n=await ne(`${dN}/api/mappings?projectId=${t}`,{headers:{Authorization:`Bearer ${e}`}});if(Fo(n))throw new Tn(n.status);if(!n.ok)return[];let r=await n.json();return Array.isArray(r.mappings)?r.mappings:[]}je();lt();var gN=G();async function Cm(e,t,n,r=10,o=!1){let i=new URLSearchParams({projectId:t,limit:String(r),storyId:n});o&&i.set("includeAI","true");let s=await ne(`${gN}/api/reviews/list?${i}`,{headers:{Authorization:`Bearer ${e}`}});if(Fo(s))throw new Tn(s.status);if(!s.ok)return[];let a=await s.json();return a.success?a.reviews||[]:[]}je();lt();var fN=G();async function Tm(e,t){let n=await ne(`${fN}/api/reviews/status?projectId=${t}`,{headers:{Authorization:`Bearer ${e}`}});if(Fo(n))throw new Tn(n.status);if(!n.ok)return{};let r=await n.json();return r.success?r.statuses||{}:{}}function bN(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 SN=G(),wN="UICOPILOT/WORKSPACE_PATH",vN="UICOPILOT/REQUEST_WORKSPACE_PATH",Im=!1;function Fm(){let{sessionToken:e,setSessionToken:t,setAuthError:n}=we(),{projects:r,selectedProjectId:o,currentStorybookPath:i,setProjects:s,setSelectedProjectId:a,setLoadingProjects:u,setCurrentStorybookPath:c}=Je(),{currentStoryId:l,mappingsRefreshKey:p,mappingsByStoryId:g,setFigmaFileUrl:d,setCurrentMapping:m,setMappingsByStoryId:C,setMappingSource:T,setLoadingMapping:E}=nt(),{setReviewResults:I,setReviewDetailTab:D,setStorybookImageUrl:R,setFigmaImageUrl:_,setFullPrompt:P,setFullResponse:z,bulkAddReviews:x}=ce(),[w,v]=hN([]),k=xN(null);Cr(()=>{let S=b=>{b.origin.startsWith(SN)&&b.data?.type==="UICOPILOT_AUTH_SUCCESS"&&b.data.token&&(y.debug("[useDataInit] OAuth success, setting token"),t(b.data.token))};return window.addEventListener("message",S),()=>window.removeEventListener("message",S)},[t]);let f=yN({[wN]:S=>{y.debug("[useDataInit] Received workspace path:",S.path),c(S.path)}});Cr(()=>{f(vN)},[f]),Cr(()=>{if(!e)return;let S=!1;return(async()=>{try{u(!0);let A=await vm(e);S||(s(A),n(null))}catch(A){A instanceof Tn&&n(A.message),y.error("[useDataInit] Failed to fetch projects:",A)}finally{S||u(!1)}})(),()=>{S=!0}},[e,s,u]),Cr(()=>{if(!i||r.length===0)return;let S=r.find(b=>b.storybookRoot===i);S&&o!==S.id&&(y.debug("[useDataInit] Auto-selecting project:",S.name),a(S.id))},[i,r,o,a]),Cr(()=>{if(!o||r.length===0)return;let S=r.find(A=>A.id===o),b=S?.figmaFileId;if(S&&typeof b=="string"&&b){let A=b,L=A.includes("figma.com")&&Kv(A)?.fileKey||A;d(`https://www.figma.com/file/${L}`)}},[o,r,d]),Cr(()=>!e||!o||Im?void 0:(Im=!0,(async()=>{try{let b=await Tm(e,o);for(let[A,L]of Object.entries(b))To(A,{score:L.score,issueCount:L.issueCount,criticalCount:L.criticalCount,majorCount:L.majorCount,minorCount:L.minorCount});y.debug("[useDataInit] Populated sidebar badges for",Object.keys(b).length,"stories")}catch(b){b instanceof Tn&&n(b.message),y.error("[useDataInit] Failed to fetch review statuses:",b)}})(),()=>{Im=!1}),[e,o]),Cr(()=>{if(!e||!o)return;let S=!1;return(async()=>{try{let A=await km(e,o);if(S)return;let L={};for(let B of A)B.storyId&&(L[B.storyId]=B);C(L)}catch(A){A instanceof Tn&&n(A.message),y.error("[useDataInit] Failed to fetch all mappings:",A)}})(),()=>{S=!0}},[e,o,p,C]),Cr(()=>{if(!l){m(null),T(null);return}let S=g[l]||null;S?(m(S),T("database")):(m(null),T(null)),E(!1)},[l,g,m,T,E]),Cr(()=>{v([]),k.current=null},[l]),Cr(()=>{if(!e||!o||!l)return;let S=!1;return(async()=>{try{let A=await Cm(e,o,l,10,!0);if(!S){v(A);let L=A.map(B=>bN(B)).filter(Boolean);L.length>0&&x(L)}}catch(A){A instanceof Tn&&n(A.message),y.error("[useDataInit] Failed to fetch reviews:",A)}})(),()=>{S=!0}},[e,o,l]);let F=mN(S=>{y.debug("[useDataInit] Applying review:",S.id,"with",S.issues.length,"issues");let b=[];if(typeof S.models=="string")try{b=JSON.parse(S.models)}catch{b=["claude-sonnet-4-20250514"]}else b=S.models;let A=S.issues.map(h=>({id:h.id,reviewId:S.id,type:h.type,severity:h.severity,title:h.description,description:h.description,file:void 0,lineNumber:void 0,property:h.property,currentValue:h.actual,suggestedValue:h.expected,suggestedCode:h.suggestedFix||void 0,status:h.status,dismissed:h.dismissed||!1,dismissReason:h.dismissReason,dismissedBy:h.dismissedBy,figmaContext:h.figmaContext,selectedForFix:!1,error:void 0,createdAt:new Date(h.createdAt)})),L=S.completedAt&&S.createdAt?new Date(S.completedAt).getTime()-new Date(S.createdAt).getTime():void 0,B=S.storyId||"";I({id:S.id,componentId:"",storyId:B,modelId:b[0]||"claude-sonnet-4-5-20250929",complianceScore:S.complianceScore,issuesCount:S.issuesCount,issues:A,createdAt:new Date(S.createdAt),timestamp:new Date(S.createdAt).toISOString(),costUsd:S.costUsd,inputTokens:S.inputTokens,outputTokens:S.outputTokens,reviewDurationMs:L});let N=dt.getState().currentStoryId;if(B&&B===N&&(S.storybookScreenshot&&(R(S.storybookScreenshot),y.debug("[useDataInit] Loaded persisted Storybook screenshot")),S.figmaScreenshot&&(_(S.figmaScreenshot),y.debug("[useDataInit] Loaded persisted Figma screenshot"))),S.aiPrompt&&(P(S.aiPrompt),y.debug("[useDataInit] Loaded persisted AI prompt")),S.aiResponse&&(z(S.aiResponse),y.debug("[useDataInit] Loaded persisted AI response")),B){let h=S.issues.filter(X=>!X.dismissed),j=h.filter(X=>X.severity==="critical").length,H=h.filter(X=>X.severity==="major").length,M=h.filter(X=>X.severity==="minor").length;To(B,{score:S.complianceScore,issueCount:h.length,criticalCount:j,majorCount:H,minorCount:M})}},[I,R,_,P,z]);Cr(()=>{if(w.length>0&&l&&k.current!==l){let S=w[0];S&&S.storyId===l&&(y.debug("[useDataInit] Auto-loading review:",S.id,"for:",l),k.current=l,F(S),D("issues"))}},[w,l,F,D])}import{styled as Js}from"storybook/theming";var kN=Js.div({display:"flex",gap:"10px",marginTop:"8px"}),Xv=Js.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.color.defaultText,cursor:"pointer"})),CN=Js.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"})),TN=Js.div({display:"flex",alignItems:"center",gap:"8px"}),IN=Js(vn)(({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"})),Qv=()=>{let{sessionToken:e,authMethod:t,setAuthMethod:n,startOAuth:r,logout:o,oauthUrl:i}=Os();return Ft.createElement(Ft.Fragment,null,Ft.createElement(go,null,Ft.createElement(fo,null,"Authentication Method"),Ft.createElement(kN,null,Ft.createElement(Xv,null,Ft.createElement("input",{type:"radio",name:"authMethod",checked:t==="oauth",onChange:()=>n("oauth")}),"OAuth (Recommended)"),Ft.createElement(Xv,null,Ft.createElement("input",{type:"radio",name:"authMethod",checked:t==="apikey",onChange:()=>n("apikey")}),"API Key"))),t==="oauth"&&Ft.createElement(go,null,Ft.createElement(fo,null,"Connect to UI Parity"),e?Ft.createElement(CN,null,Ft.createElement(TN,null,Ft.createElement("span",{style:{fontSize:"18px"}},"\u2713"),Ft.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to UI Parity")),Ft.createElement(IN,{onClick:o},"Disconnect")):i?Ft.createElement("div",null,Ft.createElement("iframe",{src:i,style:{width:"100%",height:"500px",border:"1px solid #e0e0e0",borderRadius:"6px"},title:"Sign in to UI Parity"})):Ft.createElement("div",null,Ft.createElement(cu,{style:{marginBottom:"12px"}},"Connect to UI Parity to manage projects and integrations."),Ft.createElement(vn,{onClick:r},"\u{1F517} Connect to UI Parity"))),t==="apikey"&&Ft.createElement(go,null,Ft.createElement(fo,null,"API Key"),Ft.createElement(cu,{style:{marginBottom:"12px"}},"Enter your UI Parity API key below."),Ft.createElement(as,{type:"password",placeholder:"Enter API key",disabled:!0}),Ft.createElement(vn,{disabled:!0,style:{marginTop:"12px"}},"Save API Key")))};import Nt,{useState as Zs}from"react";ke();import zn,{useState as FN,useEffect as EN,useCallback as AN}from"react";import{styled as no,keyframes as Jv}from"storybook/theming";var PN=Jv({from:{opacity:0},to:{opacity:1}}),LN=Jv({from:{opacity:0,transform:"translate(-50%, -50%) scale(0.95)"},to:{opacity:1,transform:"translate(-50%, -50%) scale(1)"}}),MN=no.div({position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4,animation:`${PN} 150ms ease-out`}),BN=no.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:`${LN} 150ms ease-out`})),DN=no.h3(({theme:e})=>({margin:0,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,fontFamily:e.typography.fonts.base,color:e.color.defaultText})),RN=no.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})),zN=no.div(({theme:e})=>({display:"flex",justifyContent:"flex-end",gap:`${e.layoutMargin*.8}px`})),NN=no.input(({theme:e})=>({width:"100%",padding:`${e.layoutMargin*.6}px ${e.layoutMargin*.8}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,backgroundColor:e.background.app,color:e.color.defaultText,marginBottom:`${e.layoutMargin}px`,boxSizing:"border-box","&:focus":{outline:"none",borderColor:e.color.secondary}})),ON=no.p(({theme:e})=>({margin:`0 0 ${e.layoutMargin*.6}px`,fontSize:e.typography.size.s1,fontFamily:e.typography.fonts.base,color:e.color.mediumdark})),_N=no.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}})),$N=no.button(({theme:e,variant:t})=>({padding:`${e.layoutMargin*.8}px ${e.layoutMargin*1.6}px`,fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,fontFamily:e.typography.fonts.base,border:"none",borderRadius:e.appBorderRadius,cursor:"pointer",transition:"opacity 0.15s",backgroundColor:t==="danger"?e.color.negative:e.color.secondary,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9},"&:disabled":{opacity:.4,cursor:"not-allowed"}})),Nr=({isOpen:e,title:t,message:n,confirmLabel:r="OK",cancelLabel:o="Cancel",variant:i="default",confirmText:s,onConfirm:a,onCancel:u})=>{let[c,l]=FN(""),p=!!s&&c!==s,g=AN(d=>{d.key==="Escape"&&u()},[u]);return EN(()=>{if(e)return l(""),document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[e,g]),e?zn.createElement(zn.Fragment,null,zn.createElement(MN,{onClick:u}),zn.createElement(BN,{role:"dialog","aria-modal":"true","aria-label":t},zn.createElement(DN,null,t),zn.createElement(RN,null,n),s&&zn.createElement(zn.Fragment,null,zn.createElement(ON,null,"Type ",zn.createElement("strong",null,s)," to confirm:"),zn.createElement(NN,{type:"text",value:c,onChange:d=>l(d.target.value),placeholder:s,autoFocus:!0})),zn.createElement(zN,null,zn.createElement(_N,{onClick:u},o),zn.createElement($N,{variant:i,onClick:a,disabled:p},r)))):null};import{styled as ur}from"storybook/theming";var UN=ur.div({marginBottom:"30px"}),jN=ur.div({display:"flex",gap:"8px",alignItems:"center"}),HN=ur(mn)({flex:1}),WN=ur(qt)({padding:"8px 12px",whiteSpace:"nowrap"}),VN=ur.div(({theme:e})=>({marginTop:"12px",padding:"12px",backgroundColor:e.background.hoverable,borderRadius:"6px"})),Em=ur.div({marginBottom:"10px","&:last-child":{marginBottom:0}}),Am=ur.label(({theme:e})=>({display:"block",fontSize:"12px",fontWeight:500,marginBottom:"4px",color:e.color.mediumdark})),Pm=ur(as)({fontSize:"13px",padding:"6px 8px"}),GN=ur.div({display:"flex",gap:"8px",marginTop:"12px"}),Zv=ur(qt)({fontSize:"12px",padding:"6px 12px"}),qN=ur(Zv)(({theme:e})=>({backgroundColor:"transparent",color:e.color.mediumdark,border:`1px solid ${e.appBorderColor}`,"&:hover":{backgroundColor:e.background.hoverable}})),YN=ur.button(({theme:e})=>({padding:"8px",backgroundColor:"transparent",border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,color:e.color.mediumdark,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:e.typography.size.s1,transition:"all 0.15s","&:hover:not(:disabled)":{borderColor:e.color.negative,color:e.color.negative},"&:disabled":{opacity:.4,cursor:"not-allowed"}})),ek=()=>{let{projects:e,selectedProjectId:t,setSelectedProjectId:n,loadingProjects:r,createProject:o,deleteProject:i}=Zr(),{currentStorybookPath:s}=Je(),[a,u]=Zs(!1),[c,l]=Zs(!1),[p,g]=Zs(!1),[d,m]=Zs(!1),[C,T]=Zs({name:"",storybookRoot:"",figmaFileUrl:""}),E=e.find(z=>z.id===t),I=z=>{n(z||null),u(!1)},D=async()=>{if(t)try{m(!0),await i(t),g(!1)}catch(z){console.error("Failed to delete project:",z)}finally{m(!1)}},R=()=>{if(u(!0),s){let z=s.replace(/\/+$/,"").split("/").pop()||"";T({storybookRoot:s,name:z,figmaFileUrl:""})}},_=async()=>{if(C.name.trim())try{l(!0);let z;if(C.figmaFileUrl.trim()){let w=C.figmaFileUrl.trim(),v=w.match(/figma\.com\/(?:file|design)\/([a-zA-Z0-9]+)/);z=v?v[1]:w}let x=await o({name:C.name.trim(),storybookRoot:C.storybookRoot.trim()||void 0,figmaFileId:z});n(x.id),u(!1),T({name:"",storybookRoot:"",figmaFileUrl:""})}catch(z){console.error("Failed to create project:",z)}finally{l(!1)}},P=z=>{T(x=>{let w={...x,storybookRoot:z};if(!x.name&&z){let v=z.replace(/\/+$/,"").split("/").pop()||"";w.name=v}return w})};return Nt.createElement(UN,null,Nt.createElement(oy,null,"Project"),Nt.createElement(jN,null,Nt.createElement(HN,{value:t||"",onChange:z=>I(z.target.value),disabled:r||a},Nt.createElement("option",{value:""},"-- Select a project --"),e.map(z=>Nt.createElement("option",{key:z.id,value:z.id},z.name))),Nt.createElement(WN,{onClick:R,disabled:r,type:"button"},"+ New"),Nt.createElement(YN,{onClick:()=>g(!0),disabled:!t||r,title:"Delete project",type:"button"},"\u{1F5D1}")),Nt.createElement(Nr,{isOpen:p,title:"Delete Project",message:`This will permanently remove all reviews, mappings, and history for "${E?.name||"this project"}". This cannot be undone.`,confirmLabel:d?"Deleting...":"Delete",confirmText:E?.name,variant:"danger",onConfirm:D,onCancel:()=>g(!1)}),a&&Nt.createElement(VN,null,Nt.createElement(Em,null,Nt.createElement(Am,null,"Storybook Path (for fix generation)"),Nt.createElement(Pm,{type:"text",placeholder:"/path/to/your/storybook",value:C.storybookRoot,onChange:z=>P(z.target.value)})),Nt.createElement(Em,null,Nt.createElement(Am,null,"Project Name *"),Nt.createElement(Pm,{type:"text",placeholder:"my-storybook",value:C.name,onChange:z=>{let x=z.target.value;T(w=>({...w,name:x}))}})),Nt.createElement(Em,null,Nt.createElement(Am,null,"Figma File URL (for design comparison)"),Nt.createElement(Pm,{type:"text",placeholder:"https://www.figma.com/file/...",value:C.figmaFileUrl,onChange:z=>{let x=z.target.value;T(w=>({...w,figmaFileUrl:x}))}})),Nt.createElement(GN,null,Nt.createElement(Zv,{onClick:_,disabled:c||!C.name.trim()},c?"Creating...":"Create"),Nt.createElement(qN,{onClick:()=>{u(!1),T({name:"",storybookRoot:"",figmaFileUrl:""})}},"Cancel"))))};import bt,{useState as lh,useCallback as MC,useEffect as e4}from"react";import{styled as Ir}from"storybook/theming";import Or,{useState as ea,useEffect as gO,useCallback as Mm}from"react";import{styled as Eo}from"storybook/theming";ke();je();lt();ke();je();lt();import jt,{useState as Lm}from"react";import{styled as Nn,keyframes as KN}from"storybook/theming";var XN={autoLayout:"Auto Layout",componentStructure:"Structure",naming:"Naming",constraints:"Constraints",spacing:"Spacing",styles:"Styles",variants:"Variants"},QN=e=>e==="pass"?"\u2713":e==="warn"?"\u26A0":"\u2717",JN=Nn.div({position:"relative",display:"inline-flex"}),ZN=KN`
31
31
  0% { transform: rotate(0deg); }
32
32
  100% { transform: rotate(360deg); }
33
- `,gN=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}}}),mN=zn.span`
33
+ `,eO=Nn.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}}}),tO=Nn.span`
34
34
  display: inline-block;
35
35
  width: 10px;
36
36
  height: 10px;
37
37
  border: 2px solid rgba(255,255,255,0.3);
38
38
  border-top-color: #fff;
39
39
  border-radius: 50%;
40
- animation: ${fN} 0.8s linear infinite;
41
- `,hN=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})),xN=zn.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",paddingBottom:"8px",borderBottom:`1px solid ${e.appBorderColor}`})),yN=zn.div(({theme:e})=>({fontWeight:e.typography.weight.bold,color:e.color.defaultText,fontSize:e.typography.size.s2})),bN=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()}}),SN=zn.div({display:"flex",flexDirection:"column",gap:"6px",marginBottom:"10px"}),wN=zn.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:e.typography.size.s1,color:e.color.defaultText})),vN=zn.span({display:"flex",alignItems:"center",gap:"4px"}),kN=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})),CN=zn.span(({theme:e})=>({fontWeight:500,color:e.color.mediumdark})),TN=zn.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,lineHeight:1.4,fontStyle:"italic"})),IN=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"}})),Uv=({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(dN,{onMouseEnter:()=>s&&r(!0),onMouseLeave:()=>r(!1)},Ut.createElement(gN,{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(mN,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(hN,null,Ut.createElement(xN,null,Ut.createElement(yN,null,"Figma Design Quality"),Ut.createElement(bN,{score:s.score},Math.round(s.score),"%")),Ut.createElement(SN,null,Object.entries(s.categories).map(([c,l])=>Ut.createElement(wN,{key:c},Ut.createElement(vN,null,Ut.createElement(kN,{status:l.status},pN(l.status)),uN[c]||c),Ut.createElement(CN,null,l.score)))),s.summary&&Ut.createElement(TN,null,s.summary),s.recommendations?.length>0&&Ut.createElement(IN,null,s.recommendations.slice(0,2).map((c,l)=>Ut.createElement("li",{key:l},c))))):null};var EN=Go.div(({theme:e})=>({padding:"12px 16px",marginBottom:"16px"})),AN=Go.div({display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"}),PN=Go.label(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),LN=Go.div({display:"flex",gap:"8px",alignItems:"center"}),MN=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}})),BN=Go(en)({whiteSpace:"nowrap"}),DN=Go.span(({variant:e})=>({fontSize:"12px",color:e==="success"?"#16a34a":"#dc2626",marginTop:"4px",display:"block"})),Hv=()=>{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||"";FN(()=>{s(p),l(null)},[o?.id,p]);let f=i!==p,d=jv(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=jv(w=>{w.key==="Enter"&&f&&!a&&d()},[f,a,d]);return e?So.createElement(EN,null,So.createElement(AN,null,So.createElement(PN,null,"Figma File URL"),So.createElement(Uv,{figmaFileUrl:p})),So.createElement(LN,null,So.createElement(MN,{type:"text",value:i,onChange:w=>s(w.target.value),onKeyDown:m,placeholder:"https://www.figma.com/file/..."}),So.createElement(BN,{onClick:d,disabled:!f||a},a?"Saving...":"Save")),c&&So.createElement(DN,{variant:c.type},c.message)):null};import kt,{useState as nc,useEffect as J_}from"react";import{styled as Yn}from"storybook/theming";we();Ue();import Je,{useState as Bi,useEffect as k_,useCallback as Co}from"react";import{styled as Jt}from"storybook/theming";Ue();Ue();De();import K,{useState as Li,useEffect as Pk,useMemo as Nm,useCallback as Lk}from"react";import{styled as Ye}from"storybook/theming";pt();import Pe,{useState as Dm,useEffect as Ak,memo as RN}from"react";import{styled as he}from"storybook/theming";var Wv=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}),Vv=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}`})),Gv=he.div(({theme:e})=>({padding:"16px 20px",borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",justifyContent:"space-between",alignItems:"center"})),qv=he.h2(({theme:e})=>({margin:0,fontSize:"16px",fontWeight:600,color:e.color.defaultText})),Yv=he(wn)({fontSize:"20px",padding:"4px 8px"}),Kv=he.div({flex:1,overflow:"auto",padding:"20px"}),Xv=he(so)({fontSize:"14px",marginBottom:"16px"}),Cm=he.div({display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"12px"}),Qv=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"})),Jv=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"})),Zv=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"})),ek=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"}})),tk=he.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"14px"})),nk=he.div(({theme:e})=>({padding:"20px",backgroundColor:e.background.critical,color:e.color.inverseText,borderRadius:"4px",fontSize:"14px"})),rk=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}})),ok=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)"}})),ik=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})),sk=he.div({display:"flex",flexWrap:"wrap",gap:"4px",marginTop:"4px",marginBottom:"4px"}),$Z=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"})),ak=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"})),lk=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"}})),ck=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})),uk=he.span(({theme:e})=>({fontWeight:600,color:e.color.mediumdark})),pk=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%"}}})),dk=he.div(({theme:e})=>({display:"flex",flexDirection:"column",border:`2px solid ${e.appBorderColor}`,borderRadius:"8px",backgroundColor:e.background.app,overflow:"hidden"})),fk=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}`})),gk=he.span(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText})),mk=he(En)({flex:1,width:"auto"}),hk=he.span(({theme:e,hasMapping:t})=>({fontSize:"12px",color:t?e.color.positive:e.color.mediumdark,fontWeight:t?500:400})),xk=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"})),yk=he.span(({theme:e})=>({color:e.color.secondary,fontWeight:e.typography.weight.bold})),bk=he.span(({theme:e})=>({color:e.color.defaultText})),Sk=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}})),wk=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}})),vk=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`}})),kk=he.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",padding:"8px 0",borderBottom:`1px solid ${e.appBorderColor}`})),Ck=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)"}})),Tk=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"})),Ik=he.div(({theme:e})=>({padding:"16px 20px",borderTop:`1px solid ${e.appBorderColor}`,display:"flex",justifyContent:"flex-end",gap:"12px"})),Fk=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}})),Ek=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();import{styled as zN}from"storybook/theming";var NN=zN.button(({theme:e})=>({gridColumn:"1 / -1",padding:"8px 16px",backgroundColor:"transparent",border:`1px dashed ${e.appBorderColor}`,borderRadius:e.appBorderRadius,color:e.color.mediumdark,fontSize:e.typography.size.s1,cursor:"pointer",transition:"all 0.15s","&:hover":{borderColor:e.color.secondary,color:e.color.secondary}})),Rm=RN(({src:e,alt:t,isComponentSet:n,loadingDone:r,failed:o})=>{let[i,s]=Dm(!1),[a,u]=Dm(!1);return Ak(()=>{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(Zv,{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 w=e.type==="COMPONENT_SET",k=w&&(e.children&&e.children.length>0||(e.childCount??0)>0),[F,C]=Dm(1),z=e.children||o||[],R=Pe.useMemo(()=>z.length===0?[]:d.some(M=>M.value)?z.filter(M=>M.variantProperties?d.every(g=>g.value?M.variantProperties?.[g.property]===g.value:!0):!1):z,[z,d]);Ak(()=>{C(1)},[d]);let O=M=>{if(w&&k){c(e.id,M);return}l(e)},P=p?Mm:Qv;return Pe.createElement(Pe.Fragment,null,Pe.createElement(P,{onClick:O,title:e.name,isSelected:p?f.has(e.id):void 0,style:{cursor:"pointer"}},p&&!k&&Pe.createElement(Bm,{isSelected:f.has(e.id)},f.has(e.id)?"\u2713":""),w?Pe.createElement(Jv,null,k&&Pe.createElement(rk,{onClick:M=>c(e.id,M),title:a?"Collapse variants":"Expand variants"},a?"\u25BC":"\u25B6"),k&&Pe.createElement(ik,null,R.length>0&&R.length!==z.length?`${R.length} / ${z.length}`:e.childCount??z.length," variants"),Pe.createElement(Rm,{src:t,alt:e.name,isComponentSet:!0})):Pe.createElement(Tm,null,Pe.createElement(Rm,{src:t,alt:e.name,isComponentSet:!1})),Pe.createElement(Em,null,Pe.createElement(Am,null,e.name,u&&Pe.createElement(Ek,null,"New")),Pe.createElement(Pm,null,e.type))),k&&a&&s&&Pe.createElement(Pe.Fragment,null,Array.from({length:Math.min(6,e.childCount??e.children?.length??6)}).map((M,g)=>Pe.createElement(ak,{key:`skeleton-${g}`},Pe.createElement(lk,null),Pe.createElement(Lm,{width:"80%"}),Pe.createElement(Lm,{width:"50%"})))),k&&a&&!s&&R.slice(0,F*50).map(M=>Pe.createElement(zm,{key:M.id,variant:M,thumbnail:r?.[M.id]||n[M.id],onSelect:l,multiSelect:p,isSelected:f.has(M.id),loadingDone:!!t||r!==void 0&&M.id in(r||{}),failed:i?.has(M.id)})),k&&a&&!s&&R.length>F*50&&Pe.createElement(NN,{onClick:()=>C(M=>M+1)},"Show more (",R.length-F*50," remaining)"))},zm=({variant:e,thumbnail:t,onSelect:n,multiSelect:r=!1,isSelected:o=!1,loadingDone:i=!1,failed:s=!1})=>Pe.createElement(r?Mm:ok,{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(Rm,{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(sk,null,Object.entries(e.variantProperties).map(([c,l])=>Pe.createElement(ck,{key:c},Pe.createElement(uk,null,c,":")," ",Pe.createElement(pk,null,l)))),Pe.createElement(Pm,{style:{marginTop:"6px"}},"VARIANT")));var ON=Ye.div({display:"flex",height:"100%",overflow:"hidden"}),_N=Ye.div(({theme:e})=>({width:"380px",minWidth:"300px",borderRight:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",overflow:"hidden"})),$N=Ye.div({flex:1,display:"flex",flexDirection:"column",overflow:"hidden"}),Mk=Ye.div(({theme:e})=>({padding:"12px 16px",borderBottom:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app})),Bk=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"}),UN=Ye(En)({flex:1,width:"auto"}),Dk=Ye(so)({flex:1,fontSize:"13px"}),jN=Ye.div({flex:1,overflow:"auto",padding:"8px"}),HN=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}})),WN=Ye.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"}),VN=Ye.div(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),GN=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})),qN=Ye.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),YN=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"})),KN=Ye.img(({theme:e})=>({width:"48px",height:"36px",objectFit:"contain",backgroundColor:e.background.content,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`,flexShrink:0})),XN=Ye.div({flex:1,overflow:"hidden"}),QN=Ye.div({fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),JN=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)"}}})),ZN=Ye.img(({theme:e})=>({width:"100%",maxWidth:"260px",maxHeight:"200px",objectFit:"contain",borderRadius:"4px",backgroundColor:e.background.app,display:"block"})),eO=Ye.div(({theme:e})=>({marginTop:"8px",fontSize:"12px",fontWeight:500,color:e.color.defaultText,textAlign:"center",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),tO=Ye.div({flex:1,display:"flex",flexDirection:"column",overflow:"hidden",position:"relative"}),nO=Ye.div({display:"flex",gap:"8px",flexWrap:"wrap"}),Om=Ye.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",color:e.color.mediumdark,cursor:"pointer","& input":{cursor:"pointer"}})),rO=Ye.div({flex:1,overflow:"auto",padding:"12px",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"12px",alignContent:"start"}),_m=20,oO=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"})),iO=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`}})),sO=Ye.div(({theme:e})=>({gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:"12px",padding:"8px 12px",backgroundColor:e.background.app,borderRadius:"6px",marginBottom:"8px"})),aO=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`}})),lO=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"})),Um=Ye.div(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:e.color.mediumdark,fontSize:"14px",gap:"8px"})),cO=Ye.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.color.mediumdark,fontSize:"14px"})),uO=Ye.div({flex:1,overflow:"auto",padding:"12px",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"12px",alignContent:"start"}),Rk=Ye.div(({theme:e})=>({borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,overflow:"hidden",backgroundColor:e.background.content})),zk=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"}}})),Nk=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"}}})),pO=()=>K.createElement(uO,null,Array.from({length:8}).map((e,t)=>K.createElement(Rk,{key:t},K.createElement(zk,null),K.createElement(Nk,{width:`${60+t%3*15}%`})))),dO=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"})),fO=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"}),gO=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)"}}})),mO=Ye.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark})),Ok=({stories:e,loading:t,selectedStoryId:n,onSelectStory:r,onStoryMapped:o,projectId:i})=>{let s=qs({projectId:i,limit:_m,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=Nm(()=>{let h=new Set;return e.forEach(T=>{T.componentTitle&&h.add(T.componentTitle)}),Array.from(h).sort()},[e]),R=Nm(()=>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,P=Nm(()=>{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]),M=P.slice(0,d*_m),g=P.length>d*_m;Pk(()=>{if(!p||M.length===0)return;let h=M.map(T=>T.id);s.fetchVariantThumbnails(p,h)},[p,M.length,d]),Pk(()=>{C(!1)},[]);let x=Lk(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=Lk((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(cO,null,"Loading stories..."):K.createElement(ON,null,K.createElement(_N,null,K.createElement(Mk,null,K.createElement(Bk,null,"Storybook Stories"),K.createElement(Gl,null,K.createElement(UN,{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(Dk,{type:"text",placeholder:"Search stories...",value:c,onChange:h=>l(h.target.value)}))),K.createElement(jN,null,R.length===0?K.createElement(Um,null,"No stories found"):R.map(h=>K.createElement(HN,{key:h.id,selected:h.id===n,mapped:!!h.figmaMapping,onClick:()=>r(h.id)},K.createElement(WN,null,K.createElement(VN,null,h.name),K.createElement(GN,{mapped:!!h.figmaMapping},h.figmaMapping?"Mapped":"Unmapped")),K.createElement(qN,null,h.title),h.figmaMapping&&K.createElement(YN,{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(KN,{src:I,alt:h.figmaMapping?.figmaFrameName||""}):K.createElement("span",null,"\u{1F517}"),w===h.id&&I&&K.createElement(JN,null,K.createElement(ZN,{src:I,alt:h.figmaMapping?.figmaFrameName||""}),K.createElement(eO,null,h.figmaMapping?.figmaFrameName)))})(),K.createElement(XN,null,K.createElement(QN,null,h.figmaMapping.figmaFrameName))))))),K.createElement($N,null,n?K.createElement(K.Fragment,null,K.createElement(dO,null,K.createElement("span",null,"Click a Figma component below to link it to"," ",K.createElement("strong",null,E?.name))),K.createElement(Mk,null,K.createElement(Bk,null,"Figma Components"),K.createElement(Gl,null,K.createElement(nO,null,K.createElement(Om,null,K.createElement("input",{type:"checkbox",checked:s.showComponentSets,onChange:h=>s.setShowComponentSets(h.target.checked)}),"Component Sets"),K.createElement(Om,null,K.createElement("input",{type:"checkbox",checked:s.showFrames,onChange:h=>s.setShowFrames(h.target.checked)}),"Frames"),K.createElement(Om,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(Dk,{type:"text",placeholder:"Search Figma components...",value:s.search,onChange:h=>s.setSearch(h.target.value)}))),K.createElement(tO,null,F&&K.createElement(fO,null,K.createElement(gO,null),K.createElement(mO,null,"Loading thumbnails...")),s.isLoading?K.createElement(pO,null):s.filteredFrames.length===0?K.createElement(Um,null,K.createElement("span",null,"No components found")):K.createElement(rO,null,p&&O?K.createElement(K.Fragment,null,K.createElement(sO,null,K.createElement(aO,{onClick:()=>{f(null),m(1)}},"Back"),K.createElement(lO,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(Rk,{key:`variant-skeleton-${T}`},K.createElement(zk,null),K.createElement(Nk,{width:`${60+T%3*15}%`})))):K.createElement(K.Fragment,null,K.createElement($m,null,"Showing ",M.length," of ",P.length," variants"),M.map(h=>K.createElement(zm,{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(oO,null,K.createElement(iO,{disabled:s.loadingMore,onClick:async()=>{p?m(h=>h+1):await s.loadMore()}},s.loadingMore?"Loading...":"Load More"))))):K.createElement(Um,null,K.createElement("span",null,"Select a story from the left to link it to Figma"))))};Ue();import et,{useState as jm,useMemo as _k,useCallback as $k}from"react";import{styled as zt}from"storybook/theming";pt();var hO=zt.div({display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"}),xO=zt.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px 20px",backgroundColor:e.background.app,borderBottom:`1px solid ${e.appBorderColor}`,flexWrap:"wrap"})),yO=zt(En)({width:"auto",minWidth:"200px"}),bO=zt(so)({fontSize:"13px",minWidth:"250px"}),SO=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}})),wO=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}})),vO=zt.div({flex:1,overflow:"auto"}),kO=zt.table(({theme:e})=>({width:"100%",borderCollapse:"collapse",fontSize:"13px"})),CO=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}`})),TO=zt.tbody({}),IO=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"})),FO=zt.div({display:"flex",flexDirection:"column",gap:"2px"}),EO=zt.div(({theme:e})=>({fontWeight:500,color:e.color.defaultText})),AO=zt.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark})),PO=zt.div(({theme:e,mapped:t})=>({color:t?e.color.positive:e.color.mediumlight,fontWeight:t?500:400,display:"flex",alignItems:"center",gap:"6px"})),LO=zt.div({display:"flex",alignItems:"center",gap:"8px"}),MO=zt.span(({theme:e,mapped:t})=>({width:"10px",height:"10px",borderRadius:"50%",backgroundColor:t?e.color.positive:e.color.mediumlight})),BO=zt.span(({theme:e,mapped:t})=>({color:t?e.color.positive:e.color.mediumdark,fontWeight:500})),Uk=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`}})),DO=zt.div(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:e.color.mediumdark,fontSize:"14px",gap:"8px",padding:"40px"})),RO=zt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.color.mediumdark,fontSize:"14px"})),jk=({stories:e,loading:t,onLink:n,onUnlink:r,projectId:o})=>{let[i,s]=jm("all"),[a,u]=jm(""),[c,l]=jm(!0),p=_k(()=>{let k=new Set;return e.forEach(F=>{F.componentTitle&&k.add(F.componentTitle)}),Array.from(k).sort()},[e]),f=_k(()=>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(RO,null,"Loading mappings...");let w=e.filter(k=>k.figmaMapping).length;return et.createElement(hO,null,et.createElement(xO,null,et.createElement(yO,{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(bO,{type:"text",placeholder:"\u{1F50D} Search stories or Figma components...",value:a,onChange:k=>u(k.target.value)}),et.createElement(SO,{active:c,onClick:()=>l(!c)},c?"\u2611":"\u2610"," Show unmapped"),et.createElement(wO,{onClick:m,disabled:w===0},"\u{1F4E5} Export JSON")),f.length===0?et.createElement(DO,null,et.createElement("span",null,"\u{1F4ED}"),a?"No stories match your search":"No stories found"):et.createElement(vO,null,et.createElement(kO,null,et.createElement(CO,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(TO,null,f.map(k=>et.createElement(IO,{key:k.id,mapped:!!k.figmaMapping},et.createElement(Yl,null,et.createElement(FO,null,et.createElement(EO,null,k.name),et.createElement(AO,null,k.title))),et.createElement(Yl,null,et.createElement(PO,{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(LO,null,et.createElement(MO,{mapped:!!k.figmaMapping}),et.createElement(BO,{mapped:!!k.figmaMapping},k.figmaMapping?"Mapped":"Unmapped"))),et.createElement(Yl,null,k.figmaMapping?et.createElement(Uk,{variant:"unlink",onClick:()=>d(k.id)},"Unlink"):et.createElement(Uk,{variant:"link",onClick:()=>n(k.id)},"Link"))))))))};import ve,{useState as ec,useMemo as Kk}from"react";import{styled as dt}from"storybook/theming";import Hk from"react";import{styled as Wk,keyframes as zO}from"storybook/theming";var NO=zO`
40
+ animation: ${ZN} 0.8s linear infinite;
41
+ `,nO=Nn.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})),rO=Nn.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",paddingBottom:"8px",borderBottom:`1px solid ${e.appBorderColor}`})),oO=Nn.div(({theme:e})=>({fontWeight:e.typography.weight.bold,color:e.color.defaultText,fontSize:e.typography.size.s2})),iO=Nn.span(({score:e,theme:t})=>{let n=()=>e>=80?t.color.positive:e>=50?t.color.warning:t.color.negative;return{fontWeight:700,fontSize:t.typography.size.s3,color:n()}}),sO=Nn.div({display:"flex",flexDirection:"column",gap:"6px",marginBottom:"10px"}),aO=Nn.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:e.typography.size.s1,color:e.color.defaultText})),lO=Nn.span({display:"flex",alignItems:"center",gap:"4px"}),cO=Nn.span(({status:e,theme:t})=>({color:e==="pass"?t.color.positive:e==="warn"?t.color.warning:t.color.negative,fontSize:t.typography.size.s1})),uO=Nn.span(({theme:e})=>({fontWeight:500,color:e.color.mediumdark})),pO=Nn.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,lineHeight:1.4,fontStyle:"italic"})),dO=Nn.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"}})),tk=({figmaFileUrl:e})=>{let{selectedProjectId:t}=Je(),[n,r]=Lm(!1),[o,i]=Lm(!1),[s,a]=Lm(null),u=async()=>{if(!(!e||!t||o)){i(!0);try{let c=G(),l=localStorage.getItem("uicopilot_session_token"),p=await ne(`${c}/api/figma/quality-check`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${l}`},body:JSON.stringify({projectId:t,figmaFileUrl:e,figmaMetadata:{}})});if(!p.ok)throw new Error("Failed to check quality");let g=await p.json();a(g),r(!0)}catch(c){console.error("[FigmaQualityBadge] Quality check error:",c)}finally{i(!1)}}};return e?jt.createElement(JN,{onMouseEnter:()=>s&&r(!0),onMouseLeave:()=>r(!1)},jt.createElement(eO,{score:s?.score,isLoading:o,onClick:u,disabled:o||!t,title:s?"Click to refresh quality check":"Click to check Figma design quality"},o?jt.createElement(jt.Fragment,null,jt.createElement(tO,null)," Checking..."):s?jt.createElement(jt.Fragment,null,"\u{1F3A8} ",Math.round(s.score),"%"):jt.createElement(jt.Fragment,null,"\u{1F3A8} Check Quality")),n&&s&&jt.createElement(nO,null,jt.createElement(rO,null,jt.createElement(oO,null,"Figma Design Quality"),jt.createElement(iO,{score:s.score},Math.round(s.score),"%")),jt.createElement(sO,null,Object.entries(s.categories).map(([c,l])=>jt.createElement(aO,{key:c},jt.createElement(lO,null,jt.createElement(cO,{status:l.status},QN(l.status)),XN[c]||c),jt.createElement(uO,null,l.score)))),s.summary&&jt.createElement(pO,null,s.summary),s.recommendations?.length>0&&jt.createElement(dO,null,s.recommendations.slice(0,2).map((c,l)=>jt.createElement("li",{key:l},c))))):null};var fO=Eo.div(({theme:e})=>({padding:"12px 16px",marginBottom:"16px"})),mO=Eo.div({display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"}),hO=Eo.label(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),xO=Eo.div({display:"flex",gap:"8px",alignItems:"center"}),yO=Eo.input(({theme:e})=>({flex:1,padding:"8px 12px",fontSize:"13px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.input.background,color:e.input.color,outline:"none","&:focus":{borderColor:ae,boxShadow:`0 0 0 1px ${ae}`},"&::placeholder":{color:e.color.mediumlight}})),bO=Eo(qt)({whiteSpace:"nowrap"}),SO=Eo.button(({theme:e})=>({padding:"8px",backgroundColor:"transparent",border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,color:e.color.mediumdark,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"12px",transition:"all 0.15s","&:hover:not(:disabled)":{borderColor:e.color.negative,color:e.color.negative},"&:disabled":{opacity:.4,cursor:"not-allowed"}})),wO=Eo.span(({variant:e})=>({fontSize:"12px",color:e==="success"?"#16a34a":"#dc2626",marginTop:"4px",display:"block"})),nk=()=>{let{selectedProjectId:e,projects:t}=Je(),{sessionToken:n}=we(),{updateProject:r}=Zr(),o=t.find(R=>R.id===e),[i,s]=ea(""),[a,u]=ea(!1),[c,l]=ea(null),p=o?.figmaFileUrl||o?.figmaFileId||"";gO(()=>{s(p),l(null)},[o?.id,p]);let g=i!==p,d=Mm(async()=>{if(!(!e||!g))try{u(!0),l(null),await r(e,{figmaFileUrl:i.trim()||void 0});let R=G();try{await ne(`${R}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({projectId:e})})}catch{}ne(`${R}/api/figma/frames?projectId=${e}&type=COMPONENT_SET&page=1&limit=1&refresh=true`,{headers:{Authorization:`Bearer ${n}`}},6e4).catch(()=>{}),l({type:"success",message:"Saved \u2014 reloading Figma cache\u2026"}),setTimeout(()=>l(null),3e3)}catch(R){l({type:"error",message:R instanceof Error?R.message:"Failed to save"})}finally{u(!1)}},[e,i,g,r]),m=Mm(R=>{R.key==="Enter"&&g&&!a&&d()},[g,a,d]),[C,T]=ea(!1),[E,I]=ea(!1),D=Mm(async()=>{if(!(!e||!n))try{I(!0),await r(e,{figmaFileUrl:""});let R=G();await ne(`${R}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({projectId:e})}).catch(()=>{}),await ne(`${R}/api/figma/frames/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({projectId:e})}).catch(()=>{}),s(""),T(!1),l({type:"success",message:"Figma file removed and cache cleared"}),setTimeout(()=>l(null),3e3)}catch{l({type:"error",message:"Failed to remove Figma file"})}finally{I(!1)}},[e,n,r]);return e?Or.createElement(fO,null,Or.createElement(mO,null,Or.createElement(hO,null,"Figma File URL"),Or.createElement(tk,{figmaFileUrl:p})),Or.createElement(xO,null,Or.createElement(yO,{type:"text",value:i,onChange:R=>s(R.target.value),onKeyDown:m,placeholder:"https://www.figma.com/file/..."}),Or.createElement(bO,{onClick:d,disabled:!g||a},a?"Saving...":"Save"),p&&Or.createElement(SO,{onClick:()=>T(!0),title:"Remove Figma file and clear cache"},"\u{1F5D1}")),Or.createElement(Nr,{isOpen:C,title:"Remove Figma File",message:"This will remove the Figma file link and clear all cached data (thumbnails, enrichment). Component mappings will be preserved but won't have design data until a new file is linked.",confirmLabel:E?"Removing...":"Remove",variant:"danger",onConfirm:D,onCancel:()=>T(!1)}),c&&Or.createElement(wO,{variant:c.type},c.message)):null};import vt,{useState as cc,useEffect as M$}from"react";import{styled as Xn}from"storybook/theming";ke();je();import et,{useState as $i,useEffect as f$,useCallback as Mo}from"react";import{styled as Zt}from"storybook/theming";je();je();Ne();import Q,{useState as Oi,useEffect as Hk,useMemo as Vm,useCallback as Wk}from"react";import{styled as Ke}from"storybook/theming";lt();import De,{useState as jk,useEffect as vO,memo as kO}from"react";import{styled as ye}from"storybook/theming";var rk=ye.div({position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10001}),ok=ye.div(({theme:e})=>({backgroundColor:e.background.content,borderRadius:"6px",width:"90%",maxWidth:"900px",maxHeight:"85vh",display:"flex",flexDirection:"column",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.3)",border:`1px solid ${e.appBorderColor}`})),ik=ye.div(({theme:e})=>({padding:"16px 20px",borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",justifyContent:"space-between",alignItems:"center"})),sk=ye.h2(({theme:e})=>({margin:0,fontSize:"16px",fontWeight:600,color:e.color.defaultText})),ak=ye(kn)({fontSize:"20px",padding:"4px 8px"}),lk=ye.div({flex:1,overflow:"auto",padding:"20px"}),ck=ye(ho)({fontSize:"14px",marginBottom:"16px"}),Bm=ye.div({display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"12px"}),uk=ye.button(({theme:e})=>({display:"flex",flexDirection:"column",padding:0,border:`2px solid ${e.appBorderColor}`,borderRadius:"8px",backgroundColor:e.background.app,color:e.color.defaultText,cursor:"pointer",overflow:"hidden",transition:"all 0.2s","&:hover":{borderColor:ae,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),Dm=ye.div(({theme:e})=>({width:"100%",aspectRatio:"4 / 3",minHeight:"80px",backgroundColor:e.background.app,backgroundImage:`linear-gradient(45deg, ${e.appBorderColor} 25%, transparent 25%), linear-gradient(-45deg, ${e.appBorderColor} 25%, transparent 25%), linear-gradient(45deg, transparent 75%, ${e.appBorderColor} 75%), linear-gradient(-45deg, transparent 75%, ${e.appBorderColor} 75%)`,backgroundSize:"8px 8px",backgroundPosition:"0 0, 0 4px, 4px -4px, -4px 0px",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",position:"relative"})),pk=ye.div(({theme:e})=>({width:"100%",aspectRatio:"4 / 3",minHeight:"80px",backgroundColor:e.background.app,backgroundImage:`linear-gradient(45deg, ${e.appBorderColor} 25%, transparent 25%), linear-gradient(-45deg, ${e.appBorderColor} 25%, transparent 25%), linear-gradient(45deg, transparent 75%, ${e.appBorderColor} 75%), linear-gradient(-45deg, transparent 75%, ${e.appBorderColor} 75%)`,backgroundSize:"8px 8px",backgroundPosition:"0 0, 0 4px, 4px -4px, -4px 0px",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",position:"relative"})),dk=ye.img(({theme:e})=>({maxWidth:"100%",maxHeight:"100%",objectFit:"cover",display:"block",backgroundColor:e.background.content,borderRadius:"4px"})),ta=ye.div(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"8px",width:"100%",height:"100%",minHeight:"80px",backgroundColor:e.base==="dark"?"rgba(255,255,255,0.03)":"rgba(0,0,0,0.02)",color:e.color.mediumdark})),Rm=ye.div(({theme:e})=>({width:"32px",height:"32px",border:`3px solid ${e.appBorderColor}`,borderTopColor:ae,borderRadius:"50%",animation:"thumbnail-spin 0.8s linear infinite","@keyframes thumbnail-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),na=ye.div(({theme:e})=>({fontSize:"11px",fontWeight:500,color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px"})),zm=ye.div(({theme:e})=>({fontSize:"32px",opacity:.5,color:e.color.mediumdark})),Nm=ye.div(({theme:e})=>({padding:"12px",textAlign:"left",backgroundColor:e.background.content,borderTop:`1px solid ${e.appBorderColor}`})),Om=ye.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,marginBottom:"6px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",lineHeight:1.3})),_m=ye.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px"})),gk=ye.div(({theme:e})=>({display:"flex",gap:"16px",marginBottom:"16px",padding:"12px",backgroundColor:e.background.app,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`})),Xl=ye.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.color.defaultText,cursor:"pointer",userSelect:"none","& input":{cursor:"pointer"}})),fk=ye.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"14px"})),mk=ye.div(({theme:e})=>({padding:"20px",backgroundColor:e.background.critical,color:e.color.inverseText,borderRadius:"4px",fontSize:"14px"})),hk=ye.button(({theme:e})=>({position:"absolute",top:"8px",left:"8px",width:"24px",height:"24px",padding:0,background:e.background.content,border:`1px solid ${e.appBorderColor}`,borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:"14px",color:e.color.defaultText,zIndex:10,transition:"all 0.2s","&:hover":{background:e.background.hoverable,borderColor:ae}})),xk=ye.button(({theme:e})=>({display:"flex",flexDirection:"column",padding:0,border:`1px solid ${e.appBorderColor}`,borderLeft:`3px solid ${ae}`,borderRadius:"6px",backgroundColor:e.background.content,color:e.color.defaultText,cursor:"pointer",overflow:"hidden",transition:"all 0.2s",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.08)",height:"auto",minHeight:"200px","&:hover":{borderColor:ae,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),yk=ye.div(({theme:e})=>({position:"absolute",top:"8px",right:"8px",padding:"2px 8px",background:ae,color:e.color.lightest,borderRadius:"4px",fontSize:"10px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",zIndex:10})),bk=ye.div({display:"flex",flexWrap:"wrap",gap:"4px",marginTop:"4px",marginBottom:"4px"}),Oee=ye.div(({theme:e})=>({padding:"20px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px",backgroundColor:e.background.app,border:`2px dashed ${e.appBorderColor}`,borderRadius:"8px",gridColumn:"1 / -1"})),Sk=ye.div(({theme:e})=>({display:"flex",flexDirection:"column",border:`1px solid ${e.appBorderColor}`,borderLeft:`3px solid ${ae}`,borderRadius:"6px",backgroundColor:e.background.content,overflow:"hidden",minHeight:"200px"})),wk=ye.div(({theme:e})=>({width:"100%",aspectRatio:"4 / 3",backgroundColor:e.background.hoverable,position:"relative",overflow:"hidden","&::after":{content:'""',position:"absolute",top:0,left:"-100%",height:"100%",width:"100%",background:`linear-gradient(90deg, transparent, ${e.background.app}40, transparent)`,animation:"shimmer 1.5s infinite"},"@keyframes shimmer":{"0%":{left:"-100%"},"100%":{left:"100%"}}})),$m=ye.div(({theme:e,width:t="70%"})=>({height:"12px",width:t,backgroundColor:e.background.hoverable,borderRadius:"4px",margin:"8px 12px",position:"relative",overflow:"hidden","&::after":{content:'""',position:"absolute",top:0,left:"-100%",height:"100%",width:"100%",background:`linear-gradient(90deg, transparent, ${e.background.app}40, transparent)`,animation:"shimmer 1.5s infinite"}})),vk=ye.span(({theme:e})=>({display:"inline-block",padding:"3px 8px",background:e.background.app,borderRadius:"4px",fontSize:"11px",color:e.color.defaultText,border:`1px solid ${e.appBorderColor}`,lineHeight:1.2})),kk=ye.span(({theme:e})=>({fontWeight:600,color:e.color.mediumdark})),Ck=ye.span(({theme:e})=>({color:e.color.defaultText})),Ql=ye.div(({theme:e,width:t="100%",height:n="40px"})=>({width:t,height:n,backgroundColor:e.appBorderColor,borderRadius:"4px",position:"relative",overflow:"hidden","&::after":{content:'""',position:"absolute",top:0,left:"-100%",height:"100%",width:"100%",background:`linear-gradient(90deg, transparent, ${e.background.hoverable}, transparent)`,animation:"shimmer 1.5s infinite"},"@keyframes shimmer":{"0%":{left:"-100%"},"100%":{left:"100%"}}})),Tk=ye.div(({theme:e})=>({display:"flex",flexDirection:"column",border:`2px solid ${e.appBorderColor}`,borderRadius:"8px",backgroundColor:e.background.app,overflow:"hidden"})),Ik=ye.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",marginBottom:"16px",padding:"12px",backgroundColor:e.background.app,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`})),Fk=ye.span(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText})),Ek=ye(mn)({flex:1,width:"auto"}),Ak=ye.span(({theme:e,hasMapping:t})=>({fontSize:"12px",color:t?e.color.positive:e.color.mediumdark,fontWeight:t?500:400})),Pk=ye.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",marginBottom:"8px",backgroundColor:e.background.hoverable||"#f0f9ff",border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,fontSize:e.typography.size.s1,flexWrap:"wrap"})),Lk=ye.span(({theme:e})=>({color:e.color.secondary,fontWeight:e.typography.weight.bold})),Mk=ye.span(({theme:e})=>({color:e.color.defaultText})),Bk=ye.button(({theme:e})=>({padding:"2px 8px",fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:e.color.lightest,backgroundColor:e.color.secondary,border:"none",borderRadius:e.appBorderRadius,cursor:"pointer","&:hover":{opacity:.9}})),Dk=ye.button(({theme:e})=>({padding:"2px 6px",fontSize:e.typography.size.s1,color:e.color.mediumdark,backgroundColor:"transparent",border:"none",cursor:"pointer","&:hover":{color:e.color.defaultText}})),Rk=ye.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,marginBottom:"8px",fontStyle:"italic"})),Jl=ye.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",marginBottom:"12px",flexWrap:"wrap"})),ra=ye.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),Ni=ye(mn)(({theme:e,isActive:t})=>({width:"auto",padding:"6px 28px 6px 10px",fontSize:"12px",...t&&{borderColor:e.color.secondary,backgroundColor:`${e.color.secondary}14`}})),Zl=ye.button(({theme:e})=>({padding:"6px 10px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:e.color.negative,fontSize:"12px",cursor:"pointer","&:hover":{backgroundColor:`${e.color.negative}15`}})),zk=ye.div(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",padding:"8px 0",borderBottom:`1px solid ${e.appBorderColor}`})),Nk=ye.button(({theme:e})=>({padding:"6px 12px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:ae,fontSize:"12px",cursor:"pointer","&:hover":{backgroundColor:"rgba(234, 88, 12, 0.08)"}})),Ok=ye.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),Um=ye.button(({theme:e,isSelected:t})=>({display:"flex",flexDirection:"column",padding:0,border:`2px solid ${t?ae:e.appBorderColor}`,borderRadius:"8px",backgroundColor:t?"rgba(234, 88, 12, 0.06)":e.background.app,color:e.color.defaultText,cursor:"pointer",overflow:"hidden",transition:"all 0.2s",position:"relative","&:hover":{borderColor:ae,transform:"translateY(-2px)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"}})),jm=ye.div(({theme:e,isSelected:t})=>({position:"absolute",top:"8px",left:"8px",width:"20px",height:"20px",borderRadius:"4px",border:`2px solid ${t?ae:e.appBorderColor}`,backgroundColor:t?ae:e.background.content,display:"flex",alignItems:"center",justifyContent:"center",zIndex:10,fontSize:"12px",color:t?e.color.lightest:"transparent"})),_k=ye.div(({theme:e})=>({padding:"16px 20px",borderTop:`1px solid ${e.appBorderColor}`,display:"flex",justifyContent:"flex-end",gap:"12px"})),$k=ye.button(({theme:e,disabled:t})=>({padding:"10px 20px",border:"none",borderRadius:"4px",backgroundColor:t?e.color.mediumdark:ae,color:e.color.lightest,fontSize:"14px",fontWeight:500,cursor:t?"not-allowed":"pointer",opacity:t?.6:1,transition:"all 0.2s","&:hover":{backgroundColor:t?e.color.mediumdark:ae,opacity:t?.6:.9}})),Uk=ye.span(({theme:e})=>({display:"inline-block",padding:"1px 5px",marginLeft:"6px",borderRadius:"3px",fontSize:"9px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",backgroundColor:"rgba(16, 185, 129, 0.15)",color:e.color.positive,verticalAlign:"middle"}));Ne();import{styled as CO}from"storybook/theming";var TO=CO.button(({theme:e})=>({gridColumn:"1 / -1",padding:"8px 16px",backgroundColor:"transparent",border:`1px dashed ${e.appBorderColor}`,borderRadius:e.appBorderRadius,color:e.color.mediumdark,fontSize:e.typography.size.s1,cursor:"pointer",transition:"all 0.15s","&:hover":{borderColor:e.color.secondary,color:e.color.secondary}})),Hm=kO(({src:e,alt:t,isComponentSet:n,loadingDone:r,failed:o})=>{let[i,s]=jk(!1),[a,u]=jk(!1);return vO(()=>{s(!1),u(!1)},[e]),i?De.createElement(ta,null,De.createElement(zm,null,n?"\u229E":"\u{1F5BC}\uFE0F"),De.createElement(na,null,"Failed to load")):e?De.createElement(De.Fragment,null,!a&&De.createElement(ta,{style:{position:"absolute",inset:0}},De.createElement(Rm,null),De.createElement(na,null,"Loading...")),De.createElement(dk,{src:e,alt:t,onLoad:()=>u(!0),onError:()=>s(!0),style:{opacity:a?1:0}})):r?De.createElement(ta,null,De.createElement(zm,null,n?"\u229E":"\u{1F5BC}\uFE0F"),De.createElement(na,null,o?"Render failed":"No preview")):De.createElement(ta,null,De.createElement(Rm,null),De.createElement(na,null,"Loading..."))}),oa=({frame:e,thumbnail:t,thumbnails:n,variantThumbnails:r,variantChildren:o,variantFailed:i,isLoadingVariants:s=!1,isExpanded:a,isNew:u=!1,onToggleExpand:c,onSelect:l,multiSelect:p=!1,selectedFrames:g=new Set,variantFilters:d=[],variantPage:m=1,onShowMore:C})=>{let E=e.type==="COMPONENT_SET",I=E&&(e.children&&e.children.length>0||(e.childCount??0)>0),D=e.children||o||[],R=De.useMemo(()=>D.length===0?[]:d.some(z=>z.value)?D.filter(z=>z.variantProperties?d.every(x=>x.value?z.variantProperties?.[x.property]===x.value:!0):!1):D,[D,d]),_=z=>{if(E&&I){c(e.id,z);return}l(e)},P=p?Um:uk;return De.createElement(De.Fragment,null,De.createElement(P,{onClick:_,title:e.name,isSelected:p?g.has(e.id):void 0,style:{cursor:"pointer"}},p&&!I&&De.createElement(jm,{isSelected:g.has(e.id)},g.has(e.id)?"\u2713":""),E?De.createElement(pk,null,I&&De.createElement(hk,{onClick:z=>c(e.id,z),title:a?"Collapse variants":"Expand variants"},a?"\u25BC":"\u25B6"),I&&De.createElement(yk,null,R.length>0&&R.length!==D.length?`${R.length} / ${D.length}`:e.childCount??D.length," variants"),De.createElement(Hm,{src:t,alt:e.name,isComponentSet:!0})):De.createElement(Dm,null,De.createElement(Hm,{src:t,alt:e.name,isComponentSet:!1})),De.createElement(Nm,null,De.createElement(Om,null,e.name,u&&De.createElement(Uk,null,"New")),De.createElement(_m,null,e.type))),I&&a&&s&&De.createElement(De.Fragment,null,Array.from({length:Math.min(6,e.childCount??e.children?.length??6)}).map((z,x)=>De.createElement(Sk,{key:`skeleton-${x}`},De.createElement(wk,null),De.createElement($m,{width:"80%"}),De.createElement($m,{width:"50%"})))),I&&a&&!s&&R.slice(0,m*50).map(z=>De.createElement(Wm,{key:z.id,variant:z,thumbnail:r?.[z.id]||n[z.id],onSelect:l,multiSelect:p,isSelected:g.has(z.id),loadingDone:!!t||r!==void 0&&z.id in(r||{}),failed:i?.has(z.id)})),I&&a&&!s&&R.length>m*50&&De.createElement(TO,{onClick:()=>C?.(e.id)},"Show more (",R.length-m*50," remaining)"))},Wm=({variant:e,thumbnail:t,onSelect:n,multiSelect:r=!1,isSelected:o=!1,loadingDone:i=!1,failed:s=!1})=>De.createElement(r?Um:xk,{onClick:()=>{y.debug("[VariantCard] Clicked:",e.id,e.name),n(e)},title:e.name,isSelected:r?o:void 0},r&&De.createElement(jm,{isSelected:o},o?"\u2713":""),De.createElement(Dm,null,De.createElement(Hm,{src:t,alt:e.name,isComponentSet:!1,loadingDone:i,failed:s})),De.createElement(Nm,null,De.createElement(Om,null,e.name),e.variantProperties&&Object.keys(e.variantProperties).length>0&&De.createElement(bk,null,Object.entries(e.variantProperties).map(([c,l])=>De.createElement(vk,{key:c},De.createElement(kk,null,c,":")," ",De.createElement(Ck,null,l)))),De.createElement(_m,{style:{marginTop:"6px"}},"VARIANT")));var IO=Ke.div({display:"flex",height:"100%",overflow:"hidden"}),FO=Ke.div(({theme:e})=>({width:"380px",minWidth:"300px",borderRight:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",overflow:"hidden"})),EO=Ke.div({flex:1,display:"flex",flexDirection:"column",overflow:"hidden"}),Vk=Ke.div(({theme:e})=>({padding:"12px 16px",borderBottom:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app})),Gk=Ke.h4(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.mediumdark,textTransform:"uppercase",letterSpacing:"0.5px",margin:0})),ec=Ke.div({display:"flex",gap:"8px",marginTop:"10px"}),AO=Ke(mn)({flex:1,width:"auto"}),qk=Ke(ho)({flex:1,fontSize:"13px"}),PO=Ke.div({flex:1,overflow:"auto",padding:"8px"}),LO=Ke.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}})),MO=Ke.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"}),BO=Ke.div(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),DO=Ke.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})),RO=Ke.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),zO=Ke.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"})),NO=Ke.img(({theme:e})=>({width:"48px",height:"36px",objectFit:"contain",backgroundColor:e.background.content,borderRadius:"4px",border:`1px solid ${e.appBorderColor}`,flexShrink:0})),OO=Ke.div({flex:1,overflow:"hidden"}),_O=Ke.div({fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),$O=Ke.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)"}}})),UO=Ke.img(({theme:e})=>({width:"100%",maxWidth:"260px",maxHeight:"200px",objectFit:"contain",borderRadius:"4px",backgroundColor:e.background.app,display:"block"})),jO=Ke.div(({theme:e})=>({marginTop:"8px",fontSize:"12px",fontWeight:500,color:e.color.defaultText,textAlign:"center",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),HO=Ke.div({flex:1,display:"flex",flexDirection:"column",overflow:"hidden",position:"relative"}),WO=Ke.div({display:"flex",gap:"8px",flexWrap:"wrap"}),Gm=Ke.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",color:e.color.mediumdark,cursor:"pointer","& input":{cursor:"pointer"}})),VO=Ke.div({flex:1,overflow:"auto",padding:"12px",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"12px",alignContent:"start"}),qm=20,GO=Ke.div(({theme:e})=>({gridColumn:"1 / -1",display:"flex",alignItems:"center",justifyContent:"center",gap:"12px",padding:"12px 0",borderTop:`1px solid ${e.appBorderColor}`,marginTop:"8px"})),qO=Ke.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`}})),YO=Ke.div(({theme:e})=>({gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:"12px",padding:"8px 12px",backgroundColor:e.background.app,borderRadius:"6px",marginBottom:"8px"})),KO=Ke.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`}})),XO=Ke.span(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),Ym=Ke.div(({theme:e})=>({gridColumn:"1 / -1",fontSize:"12px",color:e.color.mediumdark,textAlign:"center",padding:"8px 0"})),Km=Ke.div(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:e.color.mediumdark,fontSize:"14px",gap:"8px"})),QO=Ke.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.color.mediumdark,fontSize:"14px"})),JO=Ke.div({flex:1,overflow:"auto",padding:"12px",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"12px",alignContent:"start"}),Yk=Ke.div(({theme:e})=>({borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,overflow:"hidden",backgroundColor:e.background.content})),Kk=Ke.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"}}})),Xk=Ke.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"}}})),ZO=()=>Q.createElement(JO,null,Array.from({length:8}).map((e,t)=>Q.createElement(Yk,{key:t},Q.createElement(Kk,null),Q.createElement(Xk,{width:`${60+t%3*15}%`})))),e_=Ke.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"})),t_=Ke.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"}),n_=Ke.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)"}}})),r_=Ke.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark})),Qk=({stories:e,loading:t,selectedStoryId:n,onSelectStory:r,onStoryMapped:o,projectId:i})=>{let s=Qs({projectId:i,limit:qm,enabled:!!i}),[a,u]=Oi("all"),[c,l]=Oi(""),[p,g]=Oi(null),[d,m]=Oi(1),[C,T]=Oi(null),[E,I]=Oi(!1),D=Vm(()=>{let f=new Set;return e.forEach(F=>{F.componentTitle&&f.add(F.componentTitle)}),Array.from(f).sort()},[e]),R=Vm(()=>e.filter(f=>{if(a!=="all"&&f.componentTitle!==a)return!1;if(c){let F=c.toLowerCase();return f.name.toLowerCase().includes(F)||f.title.toLowerCase().includes(F)}return!0}),[e,a,c]),_=p?s.frames.find(f=>f.id===p):null,P=Vm(()=>{if(!p)return[];let f=s.variantChildren[p]||[];return f.length===0?[]:s.variantFilters.some(F=>F.value)?f.filter(F=>F.variantProperties?s.variantFilters.every(S=>S.value?F.variantProperties?.[S.property]===S.value:!0):!1):f},[p,s.variantChildren,s.variantFilters]),z=P.slice(0,d*qm),x=P.length>d*qm;Hk(()=>{if(!p||z.length===0)return;let f=z.map(F=>F.id);s.fetchVariantThumbnails(p,f)},[p,z.length,d]),Hk(()=>{I(!1)},[]);let w=Wk(async f=>{if(n)try{let F=G(),S=localStorage.getItem("uicopilot_session_token");if(!(await ne(`${F}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${S}`},body:JSON.stringify({projectId:i,storyId:n,figmaNodeId:f.id,name:f.name})})).ok)throw new Error("Failed to save mapping");o(n,f.id,f.name)}catch(F){y.error("[MapStoriesTab] Error saving mapping:",F)}},[n,i,o]),v=Wk((f,F)=>{if(F.stopPropagation(),p===f){g(null),m(1);return}g(f),m(1),!s.variantThumbnails[f]&&!s.loadingVariants.has(f)&&s.toggleExpanded(f,F)},[p,s]),k=e.find(f=>f.id===n);return t?Q.createElement(QO,null,"Loading stories..."):Q.createElement(IO,null,Q.createElement(FO,null,Q.createElement(Vk,null,Q.createElement(Gk,null,"Storybook Stories"),Q.createElement(ec,null,Q.createElement(AO,{value:a,onChange:f=>u(f.target.value)},Q.createElement("option",{value:"all"},"All Components"),D.map(f=>Q.createElement("option",{key:f,value:f},f)))),Q.createElement(ec,null,Q.createElement(qk,{type:"text",placeholder:"Search stories...",value:c,onChange:f=>l(f.target.value)}))),Q.createElement(PO,null,R.length===0?Q.createElement(Km,null,"No stories found"):R.map(f=>Q.createElement(LO,{key:f.id,selected:f.id===n,mapped:!!f.figmaMapping,onClick:()=>r(f.id)},Q.createElement(MO,null,Q.createElement(BO,null,f.name),Q.createElement(DO,{mapped:!!f.figmaMapping},f.figmaMapping?"Mapped":"Unmapped")),Q.createElement(RO,null,f.title),f.figmaMapping&&Q.createElement(zO,{onMouseEnter:()=>T(f.id),onMouseLeave:()=>T(null)},(()=>{let F=f.figmaMapping?.figmaNodeId,S=F?s.resolveThumbnail(F):void 0;return Q.createElement(Q.Fragment,null,S?Q.createElement(NO,{src:S,alt:f.figmaMapping?.figmaFrameName||""}):Q.createElement("span",null,"\u{1F517}"),C===f.id&&S&&Q.createElement($O,null,Q.createElement(UO,{src:S,alt:f.figmaMapping?.figmaFrameName||""}),Q.createElement(jO,null,f.figmaMapping?.figmaFrameName)))})(),Q.createElement(OO,null,Q.createElement(_O,null,f.figmaMapping.figmaFrameName))))))),Q.createElement(EO,null,n?Q.createElement(Q.Fragment,null,Q.createElement(e_,null,Q.createElement("span",null,"Click a Figma component below to link it to"," ",Q.createElement("strong",null,k?.name))),Q.createElement(Vk,null,Q.createElement(Gk,null,"Figma Components"),Q.createElement(ec,null,Q.createElement(WO,null,Q.createElement(Gm,null,Q.createElement("input",{type:"checkbox",checked:s.showComponentSets,onChange:f=>s.setShowComponentSets(f.target.checked)}),"Component Sets"),Q.createElement(Gm,null,Q.createElement("input",{type:"checkbox",checked:s.showFrames,onChange:f=>s.setShowFrames(f.target.checked)}),"Frames"),Q.createElement(Gm,null,Q.createElement("input",{type:"checkbox",checked:s.showComponents,onChange:f=>s.setShowComponents(f.target.checked)}),"Components")),s.availablePages.length>1&&Q.createElement(Ni,{isActive:!!s.figmaPage,value:s.figmaPage,onChange:f=>s.setFigmaPage(f.target.value)},Q.createElement("option",{value:""},"All pages"),s.availablePages.map(f=>Q.createElement("option",{key:f,value:f},f)))),s.availableFilters.length>0&&Q.createElement(Jl,null,Q.createElement(ra,null,"Filters:"),s.availableFilters.slice(0,5).map(({property:f,values:F})=>{let S=s.variantFilters.find(b=>b.property===f);return Q.createElement(Ni,{key:f,isActive:!!S?.value,value:S?.value||"",onChange:b=>s.handleFilterChange(f,b.target.value)},Q.createElement("option",{value:""},f),F.map(b=>Q.createElement("option",{key:b,value:b},f,"=",b)))}),s.availableFilters.length>5&&Q.createElement(ra,{style:{opacity:.6,fontSize:"11px"}},"+",s.availableFilters.length-5," more"),s.variantFilters.some(f=>f.value)&&Q.createElement(Zl,{onClick:s.clearFilters},"Clear All")),Q.createElement(ec,null,Q.createElement(qk,{type:"text",placeholder:"Search Figma components...",value:s.search,onChange:f=>s.setSearch(f.target.value)}))),Q.createElement(HO,null,E&&Q.createElement(t_,null,Q.createElement(n_,null),Q.createElement(r_,null,"Loading thumbnails...")),s.isLoading?Q.createElement(ZO,null):s.filteredFrames.length===0?Q.createElement(Km,null,Q.createElement("span",null,"No components match. Try a different search term, or check that your Figma file has component sets defined.")):Q.createElement(VO,null,p&&_?Q.createElement(Q.Fragment,null,Q.createElement(YO,null,Q.createElement(KO,{onClick:()=>{g(null),m(1)}},"Back"),Q.createElement(XO,null,_.name)),s.loadingVariants.has(p)?Q.createElement(Q.Fragment,null,Q.createElement(Ym,null,"Loading ",_.childCount??"..."," ","variants..."),Array.from({length:Math.min(8,_.childCount??8)}).map((f,F)=>Q.createElement(Yk,{key:`variant-skeleton-${F}`},Q.createElement(Kk,null),Q.createElement(Xk,{width:`${60+F%3*15}%`})))):Q.createElement(Q.Fragment,null,Q.createElement(Ym,null,"Showing ",z.length," of"," ",P.length," variants"),z.map(f=>Q.createElement(Wm,{key:f.id,variant:f,thumbnail:s.variantThumbnails[p]?.[f.id]||s.thumbnails[f.id],onSelect:w,loadingDone:s.variantThumbnails[p]!==void 0&&!s.loadingVariants.has(p),failed:s.variantFailed[p]?.has(f.id)})))):Q.createElement(Q.Fragment,null,Q.createElement(Ym,null,"Showing ",s.frames.length," of ",s.totalFrames," ","components"),s.filteredFrames.map(f=>Q.createElement(oa,{key:f.id,frame:f,thumbnail:s.thumbnails[f.id],thumbnails:s.thumbnails,variantThumbnails:s.variantThumbnails[f.id],variantChildren:s.variantChildren[f.id],variantFailed:s.variantFailed[f.id],isLoadingVariants:s.loadingVariants.has(f.id),isExpanded:!1,onToggleExpand:v,onSelect:w,variantFilters:s.variantFilters}))),(p?x:s.hasMore)&&Q.createElement(GO,null,Q.createElement(qO,{disabled:s.loadingMore,onClick:async()=>{p?m(f=>f+1):await s.loadMore()}},s.loadingMore?"Loading...":"Load More"))))):Q.createElement(Km,null,Q.createElement("span",null,"\u{1F448} Pick a story from the left, then browse your Figma file to find a matching frame. The mapping is saved per story."))))};je();import rt,{useState as Xm,useMemo as Jk,useCallback as Zk}from"react";import{styled as zt}from"storybook/theming";lt();var o_=zt.div({display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"}),i_=zt.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px 20px",backgroundColor:e.background.app,borderBottom:`1px solid ${e.appBorderColor}`,flexWrap:"wrap"})),s_=zt(mn)({width:"auto",minWidth:"200px"}),a_=zt(ho)({fontSize:"13px",minWidth:"250px"}),l_=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}})),c_=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}})),u_=zt.div({flex:1,overflow:"auto"}),p_=zt.table(({theme:e})=>({width:"100%",borderCollapse:"collapse",fontSize:"13px"})),d_=zt.thead(({theme:e})=>({position:"sticky",top:0,backgroundColor:e.background.app,zIndex:1})),tc=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}`})),g_=zt.tbody({}),f_=zt.tr(({theme:e,mapped:t})=>({backgroundColor:t?"transparent":`${e.color.warning}05`,"&:hover":{backgroundColor:e.background.hoverable}})),nc=zt.td(({theme:e})=>({padding:"14px 20px",borderBottom:`1px solid ${e.appBorderColor}`,verticalAlign:"middle"})),m_=zt.div({display:"flex",flexDirection:"column",gap:"2px"}),h_=zt.div(({theme:e})=>({fontWeight:500,color:e.color.defaultText})),x_=zt.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark})),y_=zt.div(({theme:e,mapped:t})=>({color:t?e.color.positive:e.color.mediumlight,fontWeight:t?500:400,display:"flex",alignItems:"center",gap:"6px"})),b_=zt.div({display:"flex",alignItems:"center",gap:"8px"}),S_=zt.span(({theme:e,mapped:t})=>({width:"10px",height:"10px",borderRadius:"50%",backgroundColor:t?e.color.positive:e.color.mediumlight})),w_=zt.span(({theme:e,mapped:t})=>({color:t?e.color.positive:e.color.mediumdark,fontWeight:500})),eC=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`}})),v_=zt.div(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:e.color.mediumdark,fontSize:"14px",gap:"8px",padding:"40px"})),k_=zt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.color.mediumdark,fontSize:"14px"})),tC=({stories:e,loading:t,onLink:n,onUnlink:r,projectId:o})=>{let[i,s]=Xm("all"),[a,u]=Xm(""),[c,l]=Xm(!0),p=Jk(()=>{let T=new Set;return e.forEach(E=>{E.componentTitle&&T.add(E.componentTitle)}),Array.from(T).sort()},[e]),g=Jk(()=>e.filter(T=>{if(i!=="all"&&T.componentTitle!==i||!c&&!T.figmaMapping)return!1;if(a){let E=a.toLowerCase();return T.name.toLowerCase().includes(E)||T.title.toLowerCase().includes(E)||(T.figmaMapping?.figmaFrameName?.toLowerCase().includes(E)??!1)}return!0}),[e,i,a,c]),d=Zk(async T=>{try{let E=G(),I=localStorage.getItem("uicopilot_session_token");if(!(await ne(`${E}/api/mappings?projectId=${o}&storyId=${T}`,{method:"DELETE",headers:{Authorization:`Bearer ${I}`}})).ok)throw new Error("Failed to delete mapping");r(T)}catch(E){console.error("[ViewAllMappingsTab] Error unlinking:",E)}},[o,r]),m=Zk(()=>{let T=e.filter(R=>R.figmaMapping).map(R=>({storyId:R.id,storyName:R.name,storyTitle:R.title,figmaNodeId:R.figmaMapping.figmaNodeId,figmaFrameName:R.figmaMapping.figmaFrameName})),E=new Blob([JSON.stringify(T,null,2)],{type:"application/json"}),I=URL.createObjectURL(E),D=document.createElement("a");D.href=I,D.download=`figma-mappings-${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(D),D.click(),document.body.removeChild(D),URL.revokeObjectURL(I)},[e]);if(t)return rt.createElement(k_,null,"Loading mappings...");let C=e.filter(T=>T.figmaMapping).length;return rt.createElement(o_,null,rt.createElement(i_,null,rt.createElement(s_,{value:i,onChange:T=>s(T.target.value)},rt.createElement("option",{value:"all"},"All Components"),p.map(T=>rt.createElement("option",{key:T,value:T},T))),rt.createElement(a_,{type:"text",placeholder:"\u{1F50D} Search stories or Figma components...",value:a,onChange:T=>u(T.target.value)}),rt.createElement(l_,{active:c,onClick:()=>l(!c)},c?"\u2611":"\u2610"," Show unmapped"),rt.createElement(c_,{onClick:m,disabled:C===0},"\u{1F4E5} Export JSON")),g.length===0?rt.createElement(v_,null,rt.createElement("span",null,"\u{1F4ED}"),a?"No stories match your search":"No stories found"):rt.createElement(u_,null,rt.createElement(p_,null,rt.createElement(d_,null,rt.createElement("tr",null,rt.createElement(tc,{style:{width:"35%"}},"Story"),rt.createElement(tc,{style:{width:"35%"}},"Figma Component"),rt.createElement(tc,{style:{width:"15%"}},"Status"),rt.createElement(tc,{style:{width:"15%"}},"Actions"))),rt.createElement(g_,null,g.map(T=>rt.createElement(f_,{key:T.id,mapped:!!T.figmaMapping},rt.createElement(nc,null,rt.createElement(m_,null,rt.createElement(h_,null,T.name),rt.createElement(x_,null,T.title))),rt.createElement(nc,null,rt.createElement(y_,{mapped:!!T.figmaMapping},T.figmaMapping?rt.createElement(rt.Fragment,null,rt.createElement("span",null,"\u{1F3A8}"),T.figmaMapping.figmaFrameName):"\u2014")),rt.createElement(nc,null,rt.createElement(b_,null,rt.createElement(S_,{mapped:!!T.figmaMapping}),rt.createElement(w_,{mapped:!!T.figmaMapping},T.figmaMapping?"Mapped":"Unmapped"))),rt.createElement(nc,null,T.figmaMapping?rt.createElement(eC,{variant:"unlink",onClick:()=>d(T.id)},"Unlink"):rt.createElement(eC,{variant:"link",onClick:()=>n(T.id)},"Link"))))))))};import Ie,{useState as lc,useMemo as lC}from"react";import{styled as pt}from"storybook/theming";import nC from"react";import{styled as rC,keyframes as C_}from"storybook/theming";var T_=C_`
42
42
  0% { transform: rotate(0deg); }
43
43
  100% { transform: rotate(360deg); }
44
- `,OO=Wk.span(({theme:e})=>({display:"inline-block",width:"12px",height:"12px",border:`2px solid ${e.appBorderColor}`,borderTopColor:"currentColor",borderRadius:"50%",animation:`${NO} 0.6s linear infinite`,marginRight:"6px",verticalAlign:"middle"})),_O=Wk.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})=>Hk.createElement(_O,{variant:r,disabled:t||e,onClick:n},e&&Hk.createElement(OO,null),e&&i?i:o);Ue();import on from"react";import{styled as Zs}from"storybook/theming";var Vk=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"})),$O=Zs.div({display:"flex",alignItems:"center",gap:"12px"}),Kl=Zs.span({whiteSpace:"nowrap"}),Gk=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*cw;return r?on.createElement(Vk,null,on.createElement(Kl,null,o.toLocaleString()," tokens"),on.createElement(Gk,null,on.createElement(Xl,null,"$",n.toFixed(4)),on.createElement("span",null,"\xB7"),on.createElement(Xl,null,"\u20AA",i.toFixed(2)))):on.createElement(Vk,null,on.createElement($O,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(Gk,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 Hm(e){if(typeof e!="string")return e;try{let t=JSON.parse(e);if(t.summary)return t}catch{}return{summary:e}}var UO=wo.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:`${e.layoutMargin*.5}px`})),qk=wo.div(({theme:e,color:t})=>({fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:t||e.color.defaultText,lineHeight:"1.4"})),jO=wo.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.25}px`,flexWrap:"wrap",fontSize:e.typography.size.s1,color:e.color.mediumdark})),HO=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})),WO=wo.span(({theme:e})=>({color:e.color.mediumlight,fontSize:e.typography.size.s1})),VO=wo.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,fontStyle:"italic"})),GO=wo.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,display:"flex",gap:`${e.layoutMargin*.25}px`})),qO=wo.span(({theme:e})=>({fontWeight:e.typography.weight.bold,color:e.color.defaultText})),Yk=({data:e,color:t,compact:n})=>n?Nn.createElement(qk,{color:t},e.summary):Nn.createElement(UO,null,Nn.createElement(qk,{color:t},e.summary),e.mappings&&e.mappings.length>0&&Nn.createElement(jO,null,e.mappings.map((r,o)=>Nn.createElement(Nn.Fragment,{key:o},Nn.createElement(HO,null,r.from," ",Nn.createElement(WO,null,"\u2192")," ",r.to)))),e.candidates!=null&&e.candidates>1&&Nn.createElement(VO,null,e.candidates," candidate variants matched"),e.defaults&&e.defaults.length>0&&Nn.createElement(Nn.Fragment,null,e.defaults.map((r,o)=>Nn.createElement(GO,{key:o},Nn.createElement(qO,null,r.choice),Nn.createElement("span",null,"\u2014 ",r.why)))));var YO=dt.div({display:"flex",flexDirection:"column",flex:1,overflow:"hidden"}),KO=dt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px",borderBottom:`1px solid ${e.appBorderColor}`})),XO=dt.div({display:"flex",flexDirection:"column",gap:"4px"}),QO=dt.div({display:"flex",alignItems:"center",gap:"10px"}),JO=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"})),Xk=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})),ZO=dt.span(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark})),e_=dt.div({display:"flex",gap:"8px"}),t_=dt.div(({theme:e})=>({display:"flex",alignItems:"center",padding:"12px 24px",gap:"12px",borderBottom:`1px solid ${e.appBorderColor}`})),n_=dt(so)(({theme:e})=>({flex:1,fontSize:e.typography.size.s2})),r_=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}})),o_=dt.div({display:"flex",flexDirection:"column",flex:1,padding:"16px 24px",gap:"8px",overflowY:"auto"}),i_=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}})),s_=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}`}})),a_=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}`})),l_=dt.img({width:"100%",height:"100%",objectFit:"contain"}),tC=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)"}}})),Qk=dt.div({flex:1,display:"flex",flexDirection:"column",gap:"2px",minWidth:0}),Jk=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"})),Wm=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"})),Eee=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"})),c_=dt.div(({theme:e})=>({flexShrink:0,color:e.color.mediumlight,fontSize:"14px"})),u_=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})),p_=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}})),d_=dt.div(({theme:e})=>({padding:"16px 0",marginTop:"8px",borderTop:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",gap:"8px"})),f_=dt.div({display:"flex",flexWrap:"wrap",gap:"6px"}),g_=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})),m_=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})),h_=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"}})),Aee=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})),Zk=({src:e,alt:t})=>{let[n,r]=ec(!1);return ve.createElement(ve.Fragment,null,!n&&ve.createElement(tC,null),ve.createElement(l_,{src:e,alt:t,onLoad:()=>r(!0),style:n?void 0:{position:"absolute",opacity:0}}))};function eC(e){return e>=90?"high":e>=70?"medium":"low"}function x_(e){return e==="high"?"#16a34a":e==="medium"?"#d97706":"#ef4444"}var nC=({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=Kk(()=>{let b=new Map;for(let E of t)b.set(E.id,{name:E.name,title:E.title});return b},[t]),z=Kk(()=>{let b=e.mappings;if(k!=="all"&&(b=b.filter(E=>eC(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)},P=e.mappings.filter(b=>b.confidence>=90).length,M=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(YO,null,ve.createElement(KO,null,ve.createElement(XO,null,ve.createElement(QO,null,ve.createElement(JO,null,"Auto-Map Results"),ve.createElement(Xk,{variant:"success"},e.stats.matched," matched"),e.unmatched.length>0&&ve.createElement(Xk,{variant:"danger"},e.unmatched.length," unmatched"),a&&ve.createElement(m_,{variant:a},a==="cache"?"Loaded from cache":"Fresh analysis")),ve.createElement(ZO,null,"Review matches below. Uncheck any incorrect mappings before applying.")),ve.createElement(e_,null,a==="cache"&&o&&ve.createElement(h_,{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(t_,null,ve.createElement(n_,{type:"text",placeholder:"Filter stories...",value:m,onChange:b=>w(b.target.value)}),ve.createElement(r_,null,ve.createElement(Jl,{active:k==="all",onClick:()=>F("all")},"All ",e.mappings.length),P>0&&ve.createElement(Jl,{active:k==="high",onClick:()=>F("high")},"\u226590% (",P,")"),M>0&&ve.createElement(Jl,{active:k==="medium",onClick:()=>F("medium")},"70-89% (",M,")"),g>0&&ve.createElement(Jl,{active:k==="low",onClick:()=>F("low")},"<70% (",g,")"))),ve.createElement(o_,null,z.map(b=>{let E=C.get(b.storyId),h=eC(b.confidence),T=f.has(b.storyId),I=h==="low";return ve.createElement(i_,{key:b.storyId,dimmed:I&&!T},ve.createElement(s_,{checked:T,onClick:()=>R(b.storyId)},T?"\u2713":""),(()=>{let v=c?.(b.storyId);return v?ve.createElement(Zl,null,ve.createElement(Zk,{src:v,alt:E?.name||b.storyId})):l?ve.createElement(Zl,null,ve.createElement(tC,null)):ve.createElement(a_,{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(Qk,null,ve.createElement(Jk,null,E?.name||b.storyId),ve.createElement(Wm,null,E?.title||"")),ve.createElement(c_,null,"\u2192"),(()=>{let v=u?.(b.figmaNodeId),A=Hm(b.reason),L=A.summary+(A.candidates?` (${A.candidates} candidates)`:"");return v?ve.createElement(Zl,{title:L},ve.createElement(Zk,{src:v,alt:b.figmaFrameName})):ve.createElement(Zl,{title:L},ve.createElement("span",{style:{fontFamily:"Inter",fontSize:"10px",fontWeight:500,color:"#94a3b8"}},"No thumbnail"))})(),ve.createElement(Qk,null,ve.createElement(Jk,null,b.componentSetName),ve.createElement(Wm,null,b.figmaFrameName),ve.createElement(Yk,{data:Hm(b.reason),color:x_(h)})),ve.createElement(u_,{level:h},b.confidence,"%"),p&&ve.createElement(p_,{onClick:()=>p(b.componentSetName)},"Browse"))}),e.unmatched.length>0&&ve.createElement(d_,null,ve.createElement(Wm,null,e.unmatched.length," stories couldn't be matched \u2014 map manually after applying"),ve.createElement(f_,null,e.unmatched.map(b=>{let E=C.get(b);return ve.createElement(g_,{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 y_}from"react";import{useStorybookApi as b_}from"storybook/manager-api";function rC({projectId:e}){let t=b_(),n=y_(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(L=>T[L].type==="story");y.debug(`[useAutoMap] Found ${I.length} stories in index.json`);let v=[];for(let L of I){let D=T[L],N=t.getData(L),S={...N?.initialArgs||{}},j=N?.argTypes||{};for(let[G,B]of Object.entries(j))if(!(G in S)){let J=B;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:L,name:D.name||L.split("--").pop()||L,title:D.title||"",initialArgs:S,argTypes:j})}let A=v.filter(L=>Object.keys(L.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 L=await A.json();f(L),C("llm"),k(`Found ${L.stats.matched} matches (${L.stats.highConfidence} high confidence)`),y.debug(`[useAutoMap] Results: ${L.stats.matched}/${L.stats.total} matched, ${L.unmatched.length} unmatched`)}catch(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]),P=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]),M=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:P,rerun:M,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 Vm,useEffect as S_,useRef as oC}from"react";var iC=2;async function w_(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 sC(e){let[t,n]=Vm({}),[r,o]=Vm(0),[i,s]=Vm(!1),a=oC(null),u=oC(""),c=e.join(",");return S_(()=>{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+=iC){let m=e.slice(d,d+iC),w=await Promise.all(m.map(F=>w_(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 aC,useEffect as tc,useMemo as v_}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]=aC(new Set),[m,w]=aC(i||o[0]?.id||"");tc(()=>{i&&w(i)},[i]),tc(()=>{l.expandedSets.forEach(M=>{let g=l.variantChildren[M];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.map(E=>E.id);b.length>0&&l.fetchVariantThumbnails(M,b)})},[l.expandedSets,l.variantChildren,l.variantFilters]),tc(()=>{d(new Set)},[m]);let k=v_(()=>{let M=[];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;M.push(...x)}else M.push(g)}),M},[l.filteredFrames,l.variantFilters]),F=M=>{if(a)d(g=>{let x=new Set(g);return x.has(M.id)?x.delete(M.id):x.add(M.id),x});else{let g=l.resolveThumbnail(M.id);try{n({...M,thumbnail:g})}catch(x){y.error("[ComponentBrowserModal] onSelect threw error:",x)}t()}},C=()=>{let M=k.map(x=>x.id),g=M.every(x=>f.has(x));d(g?new Set:new Set(M))},z=()=>{if(u&&f.size>0){let M=k.filter(g=>f.has(g.id)).map(g=>({...g,thumbnail:l.resolveThumbnail(g.id)}));u(M),d(new Set)}},R=M=>{w(M),s?.(M)},O=M=>{M.target===M.currentTarget&&t()},P=o.find(M=>M.id===m);return e?ye.createElement(Wv,{onClick:O},ye.createElement(Vv,null,ye.createElement(Gv,null,ye.createElement(qv,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(Yv,{onClick:t},"\xD7"))),ye.createElement(Kv,null,l.error&&ye.createElement(nk,null,l.error),!l.error&&ye.createElement(ye.Fragment,null,o.length>0&&ye.createElement(fk,null,ye.createElement(gk,null,"Story:"),ye.createElement(mk,{value:m,onChange:M=>R(M.target.value)},o.map(M=>ye.createElement("option",{key:M.id,value:M.id},M.name,M.mappingsCount?` (${M.mappingsCount} linked)`:""))),P?.mappingsCount?ye.createElement(hk,{hasMapping:!0},P.mappingsCount," frames linked"):null),ye.createElement(ek,null,ye.createElement(jl,null,ye.createElement("input",{type:"checkbox",checked:l.showComponentSets,onChange:M=>l.setShowComponentSets(M.target.checked)}),"Component Sets"),ye.createElement(jl,null,ye.createElement("input",{type:"checkbox",checked:l.showFrames,onChange:M=>l.setShowFrames(M.target.checked)}),"Frames"),ye.createElement(jl,null,ye.createElement("input",{type:"checkbox",checked:l.showComponents,onChange:M=>l.setShowComponents(M.target.checked)}),"Components"),l.availablePages.length>1&&ye.createElement(Pi,{isActive:!!l.figmaPage,value:l.figmaPage,onChange:M=>l.setFigmaPage(M.target.value),style:{marginLeft:"auto"}},ye.createElement("option",{value:""},"All pages"),l.availablePages.map(M=>ye.createElement("option",{key:M,value:M},M)))),l.filterSuggestion&&ye.createElement(xk,null,ye.createElement(yk,null,"AI suggests:"),ye.createElement(bk,null,Object.entries(l.filterSuggestion.suggestedFilters).map(([M,g])=>`${M}=${g}`).join(", ")),ye.createElement(Sk,{onClick:l.applySuggestedFilters},"Apply"),ye.createElement(wk,{onClick:l.dismissFilterSuggestion},"Dismiss")),l.filterSuggestionLoading&&ye.createElement(vk,null,"Matching story args to Figma filters..."),l.availableFilters.length>0&&ye.createElement(Wl,null,ye.createElement(Qs,null,"Filters:"),l.availableFilters.map(({property:M,values:g})=>{let x=l.variantFilters.find(b=>b.property===M);return ye.createElement(Pi,{key:M,isActive:!!x?.value,value:x?.value||"",onChange:b=>l.handleFilterChange(M,b.target.value)},ye.createElement("option",{value:""},M),g.map(b=>ye.createElement("option",{key:b,value:b},M,"=",b)))}),l.variantFilters.some(M=>M.value)&&ye.createElement(Vl,{onClick:l.clearFilters},"Clear All")),ye.createElement(Xv,{type:"text",placeholder:"Search frames...",value:l.search,onChange:M=>l.setSearch(M.target.value),autoFocus:!0}),a&&k.length>0&&ye.createElement(kk,null,ye.createElement(Ck,{onClick:C},f.size===k.length?"Deselect All":"Select All Visible"),ye.createElement(Tk,null,f.size>0?`${f.size} selected of `:"Showing ",k.length," frames")),l.isLoading&&ye.createElement(Cm,null,Array.from({length:6}).map((M,g)=>ye.createElement(dk,{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(tk,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(M=>ye.createElement(Js,{key:M.id,frame:M,thumbnail:l.thumbnails[M.id],thumbnails:l.thumbnails,variantThumbnails:l.variantThumbnails[M.id],variantChildren:l.variantChildren[M.id],variantFailed:l.variantFailed[M.id],isLoadingVariants:l.loadingVariants.has(M.id),isExpanded:l.expandedSets.has(M.id),isNew:l.recentlyAdded.has(M.name),onToggleExpand:l.toggleExpanded,onSelect:F,multiSelect:a,selectedFrames:f,variantFilters:l.variantFilters}))))),a&&ye.createElement(Ik,null,ye.createElement(Fk,{disabled:f.size===0,onClick:z},"Link ",f.size," Selected")))):null};we();pt();var C_=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}),T_=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"})),I_=Jt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app})),F_=Jt.div({display:"flex",alignItems:"center",gap:"20px"}),E_=Jt.h2(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.defaultText,margin:0,display:"flex",alignItems:"center",gap:"8px"})),A_=Jt.div({display:"flex",gap:"4px"}),lC=Jt(io)(({theme:e,active:t})=>({padding:"8px 16px",borderBottom:"none",borderRadius:"6px",backgroundColor:t?e.background.hoverable:"transparent","&:hover":{backgroundColor:e.background.hoverable}})),P_=Jt(wn)({width:"32px",height:"32px",fontSize:"20px",borderRadius:"6px"}),L_=Jt.div({flex:1,overflow:"hidden",display:"flex",flexDirection:"column"}),M_=Jt.div(({theme:e})=>({padding:"12px 20px",borderTop:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app,display:"flex",alignItems:"center",justifyContent:"space-between"})),B_=Jt.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,display:"flex",gap:"16px"})),D_=Jt.div({display:"flex",flexDirection:"column",flex:1,alignItems:"center",justifyContent:"center",backgroundColor:"rgba(255, 255, 255, 0.95)",padding:"40px"}),R_=Jt.div({display:"flex",flexDirection:"column",alignItems:"center",gap:"20px",maxWidth:"400px"}),z_=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"})),N_=Jt.div(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark,textAlign:"center"})),O_=Jt.div(({theme:e})=>({width:"100%",height:"8px",backgroundColor:e.appBorderColor,borderRadius:"4px",overflow:"hidden"})),__=Jt.div(({theme:e})=>({width:"100%",height:"100%",backgroundColor:e.color.secondary,borderRadius:"4px",opacity:.6})),$_=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"}})),cC=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"}})),uC=({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=rC({projectId:n}),{refreshMappings:k}=rt(),{featureFlags:F}=se(),C=Je.useMemo(()=>w.results?.mappings.map(v=>v.storyId)||[],[w.results]),z=sC(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(),L=A.entries||A.stories||{},D=Object.entries(L).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 B=await G.json(),J=new Map((B.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]);k_(()=>{e&&R()},[e,R]);let O=Co((v,A,L)=>{s(S=>S.map(j=>j.id===v?{...j,figmaMapping:{figmaNodeId:A,figmaFrameName:L}}:j));let D=i.findIndex(S=>S.id===v),N=i.find((S,j)=>j>D&&!S.figmaMapping);N&&l(N.id)},[i]),P=Co(v=>{s(A=>A.map(L=>L.id===v?{...L,figmaMapping:null}:L))},[]),M=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(C_,{onClick:h},Je.createElement(T_,{onClick:v=>v.stopPropagation()},Je.createElement(I_,null,Je.createElement(F_,null,Je.createElement(E_,null,Je.createElement("span",null,"\u{1F517}"),"Link Stories to Figma"),Je.createElement(A_,null,Je.createElement(lC,{active:r==="map",onClick:()=>o("map")},"Map Stories"),Je.createElement(lC,{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($_,{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(P_,{onClick:t},"\xD7"))),Je.createElement(L_,null,(w.isCollecting||w.isMapping)&&Je.createElement(D_,null,Je.createElement(R_,null,Je.createElement(O_,null,Je.createElement(__,null)),Je.createElement(z_,null,"Auto-mapping stories to Figma"),Je.createElement(N_,null,w.progress),Je.createElement(Br,{onClick:w.cancel,variant:"ghost"},"Cancel"))),p&&w.results&&Je.createElement(nC,{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(Ok,{stories:i,loading:a,selectedStoryId:c,onSelectStory:l,onStoryMapped:O,projectId:n}):Je.createElement(jk,{stories:i,loading:a,onLink:M,onUnlink:P,projectId:n}))),Je.createElement(M_,null,Je.createElement(B_,null,Je.createElement("span",null,"Total: ",I," stories"),Je.createElement(cC,{type:"mapped"},Je.createElement("span",{className:"dot"}),T," mapped"),Je.createElement(cC,{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 U_,useCallback as j_}from"react";import{styled as qo,keyframes as pC}from"storybook/theming";var H_=pC({from:{opacity:0},to:{opacity:1}}),W_=pC({from:{opacity:0,transform:"translate(-50%, -50%) scale(0.95)"},to:{opacity:1,transform:"translate(-50%, -50%) scale(1)"}}),V_=qo.div({position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4,animation:`${H_} 150ms ease-out`}),G_=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:`${W_} 150ms ease-out`})),q_=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})),Y_=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})),K_=qo.div(({theme:e})=>({display:"flex",justifyContent:"flex-end",gap:`${e.layoutMargin*.8}px`})),X_=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}})),Q_=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=j_(c=>{c.key==="Escape"&&a()},[a]);return U_(()=>{if(e)return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[e,u]),e?Xr.createElement(Xr.Fragment,null,Xr.createElement(V_,{onClick:a}),Xr.createElement(G_,{role:"dialog","aria-modal":"true","aria-label":t},Xr.createElement(q_,null,t),Xr.createElement(Y_,null,n),Xr.createElement(K_,null,Xr.createElement(X_,{onClick:a},o),Xr.createElement(Q_,{variant:i,onClick:s},r)))):null};pt();var dC=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}})),Z_=Yn.div(({theme:e})=>({width:"20px",height:"20px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,"& svg":{width:"16px",height:"16px"}})),e$=Yn.div({display:"flex",alignItems:"center",gap:"12px",flex:1}),t$=Yn.div({display:"flex",alignItems:"center",gap:"8px"}),n$=Yn.div(({theme:e})=>({width:"60px",height:"4px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),r$=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"})),o$=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"})),i$=Yn.span(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText})),s$=Yn(Zc)({padding:"4px 10px",fontSize:"12px",fontWeight:600,marginLeft:"auto"}),a$=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)"}})),l$=Yn.span(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,fontStyle:"italic"})),c$=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)"}}})),u$=Yn.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),fC=()=>{let[e,t]=nc(!1),[n,r]=nc({totalStories:0,mappedStories:0,loading:!0}),{selectedProjectId:o}=Ze(),{sessionToken:i}=Se();J_(()=>{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 P=await O.json(),M=P.entries||P.stories||{},g=Object.keys(M).filter(T=>M[T].type==="story").length,x=Object.keys(M).filter(T=>M[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(P=>({...P,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(),P=await ie(`${O}/api/mappings?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}});if(!P.ok)throw new Error("Failed to fetch mappings");let g=(await P.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(dC,null,kt.createElement(l$,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(dC,null,kt.createElement(Z_,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(e$,null,kt.createElement(i$,null,"Figma Mappings"),kt.createElement(t$,null,k?kt.createElement(kt.Fragment,null,kt.createElement(c$,null),kt.createElement(u$,null,"Loading...")):kt.createElement(kt.Fragment,null,kt.createElement(n$,null,kt.createElement(r$,{percent:z,state:C})),kt.createElement(o$,{state:C},`${F}/${w}`)))),F>0&&kt.createElement(a$,{onClick:p,disabled:k||a},a?"Unlinking...":"Unlink All"),kt.createElement(s$,{onClick:d,disabled:k},R)),e&&kt.createElement(uC,{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 Gm,useCallback as p$}from"react";import{styled as Kn}from"storybook/theming";we();Ue();pt();var qm=Kn.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.background.content,borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px",fontSize:"12px"})),Ym=Kn.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),Km=Kn.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),Mte=Kn(Er)({padding:"5px 12px",fontSize:"12px"}),Xm=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}})),d$=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})),f$=Kn.div(({theme:e})=>({marginTop:"6px",padding:"6px 8px",backgroundColor:e.background.hoverable,borderRadius:"4px",color:e.color.mediumdark,lineHeight:"1.4"})),Qm=Kn.span(({theme:e,type:t})=>({fontWeight:500,color:t==="added"?e.color.positive:t==="removed"?e.color.negative:e.color.warning})),g$=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})),gC=new Set,mC=()=>{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=p$(async()=>{if(!(!f||!m))try{let P=q(),M=await ie(`${P}/api/figma/cache-status?projectId=${f}`,{headers:{Authorization:`Bearer ${m}`}});if(M.ok){let g=await M.json();r(g)}}catch(P){console.error("[FigmaCacheSection] Error:",P)}finally{i(!1)}},[f,m]);Gm(()=>{w()},[w]),Gm(()=>{if(o||s||!n||n.structureStatus!=="none"||!f||gC.has(f))return;let P=d.find(g=>g.id===f);(P?.figmaFileUrl||P?.figmaFileId)&&(gC.add(f),k())},[o,s,n?.structureStatus,f,d]),Gm(()=>{let P=n?.thumbnailProgress?.status,M=n?.enrichmentProgress?.status,g=n?.thumbnailProgress?.cached??0,x=n?.thumbnailProgress?.total??0,b=P==="in-progress"||P==="pending"||x>0&&g<x,E=M==="in-progress"||M==="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 P=q();await ie(`${P}/api/figma/frames?projectId=${f}&type=COMPONENT_SET&page=1&limit=1&refresh=true`,{headers:{Authorization:`Bearer ${m}`}},6e4),await new Promise(M=>setTimeout(M,1e3)),await w(),setTimeout(async()=>{await w()},3e3)}catch(P){console.error("[FigmaCacheSection] Reload error:",P)}finally{a(!1)}}},F=async()=>{if(!(!f||!m)){c(!0);try{let P=q(),M=await ie(`${P}/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:",M.status),await ie(`${P}/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(P){console.error("[FigmaCacheSection] Clear cache error:",P)}finally{c(!1)}}},C=async()=>{if(!(!f||!m)){p(!0);try{let P=q();await ie(`${P}/api/figma/enrich`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${m}`},body:JSON.stringify({projectId:f})});let M=setInterval(async()=>{await w()},3e3),g=setInterval(()=>{(n?.enrichmentProgress?.status==="complete"||n?.enrichmentProgress?.status==="error")&&(clearInterval(M),clearInterval(g),p(!1),w())},3e3);setTimeout(()=>{clearInterval(M),clearInterval(g),p(!1)},6e5)}catch(P){console.error("[FigmaCacheSection] Enrich error:",P),p(!1)}}};if(!f)return null;if(o)return ce.createElement(qm,null,ce.createElement(Ym,null,ce.createElement(Km,null,"Figma Cache")),ce.createElement(Xm,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(qm,null,ce.createElement(Ym,null,ce.createElement(Km,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(Xm,null,ce.createElement(rc,null,"No cache \u2014 click Load to fetch from Figma")));let z=P=>{let M=Date.now()-new Date(P).getTime(),g=Math.floor(M/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(qm,null,ce.createElement(Ym,null,ce.createElement(Km,null,"Figma Cache"," ",ce.createElement(d$,{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(Xm,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(g$,null,"Updated ",z(n.structureCachedAt))),O&&ce.createElement(f$,null,"Since last reload:"," ",R.added.length>0&&ce.createElement(Qm,{type:"added"},"+",R.added.length," added"),R.added.length>0&&R.removed.length>0&&" \xB7 ",R.removed.length>0&&ce.createElement(Qm,{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(Qm,{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 Jm=Dr.div({padding:"12px 16px"}),m$=Dr.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),hC=Dr.label(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),xC=Dr.button(({theme:e})=>({background:"none",border:"none",fontSize:"12px",color:le,cursor:"pointer",padding:0,"&:hover":{textDecoration:"underline"}})),h$=Dr.div({display:"flex",gap:"8px",alignItems:"center"}),x$=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"}})),yC=Dr.span(({variant:e})=>({fontSize:"12px",color:e==="success"?"#16a34a":e==="error"?"#dc2626":"#6b7280",marginTop:"6px",display:"block",lineHeight:1.4})),y$=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"}})),b$=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})),S$=Dr.button(({theme:e})=>({background:"none",border:"none",fontSize:"11px",color:"#dc2626",cursor:"pointer",marginLeft:"auto","&:hover":{textDecoration:"underline"}})),bC=({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(Jm,null,ht.createElement(hC,null,"Figma Personal Access Token"),ht.createElement(b$,null,ht.createElement("span",null,"\u2713 Connected as ",ht.createElement("strong",null,l)),ht.createElement(S$,{onClick:()=>{p(null),c(null)}},"Change token"))):n?ht.createElement(Jm,null,ht.createElement(m$,null,ht.createElement(hC,null,"Figma Personal Access Token"),ht.createElement(xC,{onClick:()=>d(!f)},f?"Hide instructions":"How to generate")),f&&ht.createElement(y$,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(h$,null,ht.createElement(x$,{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(yC,{variant:u.type},u.message),ht.createElement(yC,{variant:"info"},"Read-only access. Your token is stored securely and never shared.")):ht.createElement(Jm,null,ht.createElement(xC,{onClick:()=>r(!0)},"Or use a Personal Access Token \u2192"))};we();Ue();pt();var v$=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"})),eh=vr.div(({theme:e})=>({border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",marginBottom:"16px",backgroundColor:e.background.content})),k$=vr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",padding:"10px 16px",backgroundColor:e.background.hoverable,borderBottom:`1px solid ${e.appBorderColor}`})),C$=vr.div({width:"16px",height:"16px",display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}),T$=vr.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,flex:1})),th=vr.div({"& > *":{border:"none",borderRadius:0,marginBottom:0,borderBottom:"1px solid rgba(0,0,0,0.06)","&:last-child":{borderBottom:"none"}}}),I$=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"})),F$=vr.div({display:"flex",alignItems:"center",gap:"8px"}),E$=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"})),A$=vr.div({padding:"20px 16px",display:"flex",flexDirection:"column",gap:"12px"}),Jte=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"}}),P$=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}})),wC=({hideHeader:e=!1})=>{let{sessionToken:t}=Se(),[n,r]=Zm(!1),[o,i]=Zm(null),[s,a]=Zm(!1);w$(()=>{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=SC(()=>{let f=`${q()}/addon/auth`;window.open(f,"figma-oauth","width=600,height=700,left=200,top=100")},[]),c=SC(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(k$,null,bt.createElement(C$,null,v$),bt.createElement(T$,null,"Figma Integration"));return o===null?bt.createElement(eh,null,l,bt.createElement(th,null,bt.createElement("div",{style:{padding:"16px",fontSize:"13px",color:"#9ca3af"}},"Checking Figma connection..."))):o===!1?bt.createElement(eh,null,l,bt.createElement(th,null,bt.createElement(A$,null,bt.createElement(en,{onClick:u,style:{width:"100%"}},"Connect with Figma"),bt.createElement(P$,null,"or"),bt.createElement(bC,{onConnected:()=>i(!0)})))):bt.createElement(eh,null,l,bt.createElement(I$,null,bt.createElement(F$,null,bt.createElement("span",{style:{fontSize:"18px"}},"\u2713"),bt.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to Figma")),bt.createElement(E$,{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(th,null,bt.createElement(Hv,null),bt.createElement(fC,null),bt.createElement(mC,null)))};we();var L$=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"}),M$=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"})),B$=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})),D$=cr.h2(({theme:e})=>({margin:0,fontSize:"16px",fontWeight:600,color:e.color.defaultText})),R$=cr(wn)({fontSize:"18px",padding:"2px 8px",lineHeight:1,background:"transparent",border:"none"}),z$=cr.div({display:"flex",flexDirection:"column",gap:"16px",padding:"0 20px 20px"}),vC=cr.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:"14px",padding:"16px",borderRadius:"12px",border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content})),kC=cr.div({display:"flex",alignItems:"center",gap:"10px"}),CC=cr.h3(({theme:e})=>({margin:0,fontSize:"14px",fontWeight:600,color:e.color.defaultText,flex:1})),N$=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}),O$=cr.div({width:"22px",height:"22px",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center","& svg":{width:"22px",height:"22px"}}),TC=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"}})),IC=({onClose:e})=>{let{isConnected:t}=Se(),{selectedProjectId:n}=Ze();return At.createElement(L$,{onClick:e},At.createElement(M$,{onClick:r=>r.stopPropagation()},At.createElement(B$,null,At.createElement(D$,null,"Settings"),At.createElement(R$,{onClick:e,title:"Close settings"},"\xD7")),At.createElement(z$,null,At.createElement(vC,null,At.createElement(kC,null,At.createElement(N$,null,"UI"),At.createElement(CC,null,"UI Copilot")),At.createElement(TC,null,At.createElement(Ov,null),t&&At.createElement($v,null))),t&&n&&At.createElement(vC,null,At.createElement(kC,null,At.createElement(O$,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(CC,null,"Figma Integration")),At.createElement(TC,null,At.createElement(wC,{hideHeader:!0}))))))};import ft,{useEffect as zC,useMemo as f4,useState as g4,useRef as m4}from"react";import{styled as Cn,keyframes as h4}from"storybook/theming";we();we();import Kt,{useState as _$}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 $$=On.div({display:"flex",alignItems:"center",gap:"8px",width:"100%"}),U$=On.div({display:"inline-flex",flexWrap:"nowrap",gap:"4px",alignItems:"center"}),j$=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"}}),H$=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}})),W$=On.div({position:"relative",display:"inline-block"}),V$=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}})),G$=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"})),nh=On.div(({theme:e})=>({borderBottom:`1px solid ${e.appBorderColor}`,"&:last-child":{borderBottom:"none"}})),rh=On.div(({theme:e})=>({padding:"8px 12px",fontSize:"10px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px",backgroundColor:e.background.app})),q$=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}})),Y$=On.input({cursor:"pointer",flexShrink:0,"&:disabled":{cursor:"not-allowed"}}),K$=On.div({flex:1,minWidth:0}),X$=On.div({fontSize:"12px",fontWeight:500,marginBottom:"2px"}),Q$=On.div(({theme:e})=>({fontSize:"10px",color:e.textMutedColor,lineHeight:"1.2"})),J$=5,FC=()=>{let{selectedModels:e,toggleModel:t,isReviewing:n}=se(),[r,o]=_$(!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<J$,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(q$,{key:d.id,disabled:k,onClick:()=>p(d.id)},Kt.createElement(Y$,{type:"checkbox",checked:m,disabled:k,onChange:()=>{},onClick:F=>F.stopPropagation()}),Kt.createElement(K$,null,Kt.createElement(X$,null,d.name),d.description&&Kt.createElement(Q$,null,d.description)))};return Kt.createElement($$,null,Kt.createElement(W$,null,Kt.createElement(V$,{disabled:n,isOpen:r,onClick:()=>o(!r)},Kt.createElement("span",null,"Select model"),Kt.createElement("span",null,r?"\u25B2":"\u25BC")),r&&Kt.createElement(G$,null,Kt.createElement(nh,null,Kt.createElement(rh,null,"Anthropic"),i.map(f)),Kt.createElement(nh,null,Kt.createElement(rh,null,"OpenAI"),s.map(f)),Kt.createElement(nh,null,Kt.createElement(rh,null,"Google"),a.map(f)))),Kt.createElement(U$,null,u.map(d=>Kt.createElement(j$,{key:d.id,disabled:n,provider:d.provider},d.name,e.length>1&&Kt.createElement(H$,{disabled:n,onClick:m=>l(d.id,m),title:"Remove model"},"\xD7")))))};import ke,{useState as Z$,useEffect as e4}from"react";import{styled as jt,keyframes as Ni}from"storybook/theming";we();var t4=Ni`
44
+ `,I_=rC.span(({theme:e})=>({display:"inline-block",width:"12px",height:"12px",border:`2px solid ${e.appBorderColor}`,borderTopColor:"currentColor",borderRadius:"50%",animation:`${T_} 0.6s linear infinite`,marginRight:"6px",verticalAlign:"middle"})),F_=rC.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}}})),Tr=({loading:e=!1,disabled:t=!1,onClick:n,variant:r="default",children:o,loadingText:i})=>nC.createElement(F_,{variant:r,disabled:t||e,onClick:n},e&&nC.createElement(I_,null),e&&i?i:o);je();import an from"react";import{styled as ia}from"storybook/theming";var oC=ia.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"})),E_=ia.div({display:"flex",alignItems:"center",gap:"12px"}),rc=ia.span({whiteSpace:"nowrap"}),iC=ia.div({display:"flex",alignItems:"center",gap:"8px"}),oc=ia.span(({theme:e})=>({fontWeight:600,color:e.color.defaultText})),ic=({inputTokens:e,outputTokens:t,costUsd:n,compact:r=!1})=>{let o=e+t,i=n*bw;return r?an.createElement(oC,null,an.createElement(rc,null,o.toLocaleString()," tokens"),an.createElement(iC,null,an.createElement(oc,null,"$",n.toFixed(4)),an.createElement("span",null,"\xB7"),an.createElement(oc,null,"\u20AA",i.toFixed(2)))):an.createElement(oC,null,an.createElement(E_,null,an.createElement(rc,null,e.toLocaleString()," input"),an.createElement("span",null,"+"),an.createElement(rc,null,t.toLocaleString()," output"),an.createElement("span",null,"="),an.createElement(rc,null,an.createElement("strong",null,o.toLocaleString())," tokens")),an.createElement(iC,null,an.createElement(oc,null,"$",n.toFixed(4)),an.createElement("span",null,"\xB7"),an.createElement(oc,null,"\u20AA",i.toFixed(2))))};import On from"react";import{styled as Ao}from"storybook/theming";function Qm(e){if(typeof e!="string")return e;try{let t=JSON.parse(e);if(t.summary)return t}catch{}return{summary:e}}var A_=Ao.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:`${e.layoutMargin*.5}px`})),sC=Ao.div(({theme:e,color:t})=>({fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:t||e.color.defaultText,lineHeight:"1.4"})),P_=Ao.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.25}px`,flexWrap:"wrap",fontSize:e.typography.size.s1,color:e.color.mediumdark})),L_=Ao.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})),M_=Ao.span(({theme:e})=>({color:e.color.mediumlight,fontSize:e.typography.size.s1})),B_=Ao.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,fontStyle:"italic"})),D_=Ao.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,display:"flex",gap:`${e.layoutMargin*.25}px`})),R_=Ao.span(({theme:e})=>({fontWeight:e.typography.weight.bold,color:e.color.defaultText})),aC=({data:e,color:t,compact:n})=>n?On.createElement(sC,{color:t},e.summary):On.createElement(A_,null,On.createElement(sC,{color:t},e.summary),e.mappings&&e.mappings.length>0&&On.createElement(P_,null,e.mappings.map((r,o)=>On.createElement(On.Fragment,{key:o},On.createElement(L_,null,r.from," ",On.createElement(M_,null,"\u2192")," ",r.to)))),e.candidates!=null&&e.candidates>1&&On.createElement(B_,null,e.candidates," candidate variants matched"),e.defaults&&e.defaults.length>0&&On.createElement(On.Fragment,null,e.defaults.map((r,o)=>On.createElement(D_,{key:o},On.createElement(R_,null,r.choice),On.createElement("span",null,"\u2014 ",r.why)))));var z_=pt.div({display:"flex",flexDirection:"column",flex:1,overflow:"hidden"}),N_=pt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px",borderBottom:`1px solid ${e.appBorderColor}`})),O_=pt.div({display:"flex",flexDirection:"column",gap:"4px"}),__=pt.div({display:"flex",alignItems:"center",gap:"10px"}),$_=pt.span(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText,letterSpacing:"-0.3px"})),cC=pt.span(({theme:e,variant:t})=>({padding:"3px 10px",borderRadius:"20px",fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s1,fontWeight:500,backgroundColor:t==="success"?`${e.color.positive}1a`:t==="danger"?`${e.color.negative}1a`:`${e.color.secondary}1a`,color:t==="success"?e.color.positive:t==="danger"?e.color.negative:e.color.secondary})),U_=pt.span(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark})),j_=pt.div({display:"flex",gap:"8px"}),H_=pt.div(({theme:e})=>({display:"flex",alignItems:"center",padding:"12px 24px",gap:"12px",borderBottom:`1px solid ${e.appBorderColor}`})),W_=pt(ho)(({theme:e})=>({flex:1,fontSize:e.typography.size.s2})),V_=pt.div({display:"flex",gap:"4px"}),sc=pt.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}})),G_=pt.div({display:"flex",flexDirection:"column",flex:1,padding:"16px 24px",gap:"8px",overflowY:"auto"}),q_=pt.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}})),Y_=pt.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}`}})),K_=pt.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"})),ac=pt.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}`})),X_=pt.img({width:"100%",height:"100%",objectFit:"contain"}),fC=pt.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)"}}})),uC=pt.div({flex:1,display:"flex",flexDirection:"column",gap:"2px",minWidth:0}),pC=pt.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"})),Jm=pt.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"})),Ite=pt.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"})),Q_=pt.div(({theme:e})=>({flexShrink:0,color:e.color.mediumlight,fontSize:"14px"})),J_=pt.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})),Z_=pt.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}})),e$=pt.div(({theme:e})=>({padding:"16px 0",marginTop:"8px",borderTop:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",gap:"8px"})),t$=pt.div({display:"flex",flexWrap:"wrap",gap:"6px"}),n$=pt.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})),r$=pt.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})),o$=pt.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"}})),Fte=pt.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})),dC=({src:e,alt:t})=>{let[n,r]=lc(!1);return Ie.createElement(Ie.Fragment,null,!n&&Ie.createElement(fC,null),Ie.createElement(X_,{src:e,alt:t,onLoad:()=>r(!0),style:n?void 0:{position:"absolute",opacity:0}}))};function gC(e){return e>=90?"high":e>=70?"medium":"low"}function i$(e){return e==="high"?"#16a34a":e==="medium"?"#d97706":"#ef4444"}var mC=({results:e,stories:t,onApply:n,onCancel:r,onRerun:o,isApplying:i,isRerunning:s,source:a,resolveThumbnail:u,resolveStoryScreenshot:c,isCapturingScreenshots:l,onBrowse:p})=>{let[g,d]=lc(()=>{let v=new Set;for(let k of e.mappings)k.confidence>=90&&v.add(k.storyId);return v}),[m,C]=lc(""),[T,E]=lc("all"),I=lC(()=>{let v=new Map;for(let k of t)v.set(k.id,{name:k.name,title:k.title});return v},[t]),D=lC(()=>{let v=e.mappings;if(T!=="all"&&(v=v.filter(k=>gC(k.confidence)===T)),m.trim()){let k=m.toLowerCase();v=v.filter(f=>{let F=I.get(f.storyId);return F?.name.toLowerCase().includes(k)||F?.title.toLowerCase().includes(k)||f.componentSetName.toLowerCase().includes(k)||f.figmaFrameName.toLowerCase().includes(k)})}return v},[e.mappings,T,m,I]),R=v=>{d(k=>{let f=new Set(k);return f.has(v)?f.delete(v):f.add(v),f})},_=()=>{let v=e.mappings.filter(k=>g.has(k.storyId));n(v)},P=e.mappings.filter(v=>v.confidence>=90).length,z=e.mappings.filter(v=>v.confidence>=70&&v.confidence<90).length,x=e.mappings.filter(v=>v.confidence<70).length,w=e.usage;return Ie.createElement(z_,null,Ie.createElement(N_,null,Ie.createElement(O_,null,Ie.createElement(__,null,Ie.createElement($_,null,"Auto-Map Results"),Ie.createElement(cC,{variant:"success"},e.stats.matched," matched"),e.unmatched.length>0&&Ie.createElement(cC,{variant:"danger"},e.unmatched.length," unmatched"),a&&Ie.createElement(r$,{variant:a},a==="cache"?"Loaded from cache":"Fresh analysis")),Ie.createElement(U_,null,"Review matches below. Uncheck any incorrect mappings before applying.")),Ie.createElement(j_,null,a==="cache"&&o&&Ie.createElement(o$,{onClick:o,disabled:s},s?"Re-running...":"Re-run LLM"),Ie.createElement(Tr,{onClick:r,variant:"ghost"},"Cancel"),Ie.createElement(Tr,{loading:i,onClick:_,loadingText:"Applying..."},"Apply ",g.size," Selected"))),Ie.createElement(H_,null,Ie.createElement(W_,{type:"text",placeholder:"Filter stories...",value:m,onChange:v=>C(v.target.value)}),Ie.createElement(V_,null,Ie.createElement(sc,{active:T==="all",onClick:()=>E("all")},"All ",e.mappings.length),P>0&&Ie.createElement(sc,{active:T==="high",onClick:()=>E("high")},"\u226590% (",P,")"),z>0&&Ie.createElement(sc,{active:T==="medium",onClick:()=>E("medium")},"70-89% (",z,")"),x>0&&Ie.createElement(sc,{active:T==="low",onClick:()=>E("low")},"<70% (",x,")"))),Ie.createElement(G_,null,D.map(v=>{let k=I.get(v.storyId),f=gC(v.confidence),F=g.has(v.storyId),S=f==="low";return Ie.createElement(q_,{key:v.storyId,dimmed:S&&!F},Ie.createElement(Y_,{checked:F,onClick:()=>R(v.storyId)},F?"\u2713":""),(()=>{let b=c?.(v.storyId);return b?Ie.createElement(ac,null,Ie.createElement(dC,{src:b,alt:k?.name||v.storyId})):l?Ie.createElement(ac,null,Ie.createElement(fC,null)):Ie.createElement(K_,{bgColor:S?"#f1f5f9":"#eff6ff"},Ie.createElement("span",{style:{fontFamily:"Inter",fontSize:"8px",fontWeight:500,color:S?"#94a3b8":"#3b82f6"}},(k?.name||"?").substring(0,4)))})(),Ie.createElement(uC,null,Ie.createElement(pC,null,k?.name||v.storyId),Ie.createElement(Jm,null,k?.title||"")),Ie.createElement(Q_,null,"\u2192"),(()=>{let b=u?.(v.figmaNodeId),A=Qm(v.reason),L=A.summary+(A.candidates?` (${A.candidates} candidates)`:"");return b?Ie.createElement(ac,{title:L},Ie.createElement(dC,{src:b,alt:v.figmaFrameName})):Ie.createElement(ac,{title:L},Ie.createElement("span",{style:{fontFamily:"Inter",fontSize:"10px",fontWeight:500,color:"#94a3b8"}},"No thumbnail"))})(),Ie.createElement(uC,null,Ie.createElement(pC,null,v.componentSetName),Ie.createElement(Jm,null,v.figmaFrameName),Ie.createElement(aC,{data:Qm(v.reason),color:i$(f)})),Ie.createElement(J_,{level:f},v.confidence,"%"),p&&Ie.createElement(Z_,{onClick:()=>p(v.componentSetName)},"Browse"))}),e.unmatched.length>0&&Ie.createElement(e$,null,Ie.createElement(Jm,null,e.unmatched.length," stories couldn't be matched \u2014 map manually after applying"),Ie.createElement(t$,null,e.unmatched.map(v=>{let k=I.get(v);return Ie.createElement(n$,{key:v},Ie.createElement("span",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#cbd5e1"}}),k?`${k.name} (${k.title})`:v)})))),w&&a!=="cache"&&Ie.createElement("div",{style:{padding:"8px 24px",borderTop:"1px solid #f0f0f0"}},Ie.createElement(ic,{inputTokens:w.inputTokens||0,outputTokens:w.outputTokens||0,costUsd:w.costUsd||0})))};je();Ne();import{useState as Po,useCallback as Lo,useRef as s$}from"react";import{useStorybookApi as a$}from"storybook/manager-api";function hC({projectId:e}){let t=a$(),n=s$(null),[r,o]=Po(!1),[i,s]=Po(!1),[a,u]=Po(!1),[c,l]=Po(null),[p,g]=Po(null),[d,m]=Po(null),[C,T]=Po(""),[E,I]=Po(null),D=Lo(async()=>{let k=await fetch("/index.json");if(!k.ok)throw new Error("Failed to fetch Storybook index");let f=await k.json(),F=f.entries||f.stories||{},S=Object.keys(F).filter(L=>F[L].type==="story");y.debug(`[useAutoMap] Found ${S.length} stories in index.json`);let b=[];for(let L of S){let B=F[L],N=t.getData(L),h={...N?.initialArgs||{}},j=N?.argTypes||{};for(let[H,M]of Object.entries(j))if(!(H in h)){let X=M;if(X.defaultValue!==void 0)h[H]=X.defaultValue;else if(X.table?.defaultValue?.summary!==void 0){let Z=X.table.defaultValue.summary;Z==="false"?h[H]=!1:Z==="true"?h[H]=!0:h[H]=Z}}b.push({id:L,name:B.name||L.split("--").pop()||L,title:B.title||"",initialArgs:h,argTypes:j})}let A=b.filter(L=>Object.keys(L.initialArgs).length>0);return y.debug(`[useAutoMap] Manifest: ${b.length} stories, ${A.length} with args`),b},[t]),R=Lo(async()=>{if(!e)return!1;try{let k=G(),f=localStorage.getItem("uicopilot_session_token");if(!f)return!1;let F=await fetch(`${k}/api/figma/auto-map?projectId=${e}`,{headers:{Authorization:`Bearer ${f}`}});if(!F.ok)return!1;let S=await F.json();return S.hasSuggestions&&S.mappings?.length>0?(g(S),I("cache"),T(`Loaded ${S.mappings.length} saved suggestions`),y.debug(`[useAutoMap] Loaded ${S.mappings.length} existing suggestions from DB`),!0):!1}catch{return!1}},[e]),_=Lo(async k=>{o(!0),T("Collecting story information...");let f;try{if(f=await D(),k?.length&&(f=f.filter(S=>!k.includes(S.id)),y.debug(`[useAutoMap] After excluding mapped: ${f.length} stories`)),f.length===0){l("No unmapped stories found"),o(!1);return}m(f)}catch(S){l(S instanceof Error?S.message:"Failed to collect story manifest"),o(!1);return}o(!1),s(!0),T(`Analyzing ${f.length} stories against Figma components...`);let F=new AbortController;n.current=F;try{let S=G(),b=localStorage.getItem("uicopilot_session_token");if(!b)throw new Error("Not authenticated");let A=await fetch(`${S}/api/figma/auto-map`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${b}`},body:JSON.stringify({projectId:e,stories:f.map(B=>({id:B.id,name:B.name,title:B.title,initialArgs:B.initialArgs,argTypes:B.argTypes}))}),signal:F.signal});if(!A.ok){let B=await A.json();throw new Error(B.error||"Auto-map failed")}let L=await A.json();g(L),I("llm"),T(`Found ${L.stats.matched} matches (${L.stats.highConfidence} high confidence)`),y.debug(`[useAutoMap] Results: ${L.stats.matched}/${L.stats.total} matched, ${L.unmatched.length} unmatched`)}catch(S){if(S instanceof DOMException&&S.name==="AbortError"){T("Cancelled");return}l(S instanceof Error?S.message:"Auto-map failed")}finally{s(!1),n.current=null}},[e,D]),P=Lo(async k=>{if(!e)return;if(l(null),g(null),I(null),o(!0),T("Checking for existing suggestions..."),await R()){o(!1);return}await _(k)},[e,R,_]),z=Lo(async k=>{e&&(l(null),g(null),I(null),await _(k))},[e,_]),x=Lo(async k=>{if(!(!e||k.length===0)){u(!0),T(`Applying ${k.length} mappings...`);try{let f=G(),F=localStorage.getItem("uicopilot_session_token");if(!F)throw new Error("Not authenticated");let S=0;for(let b of k)try{(await fetch(`${f}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${F}`},body:JSON.stringify({projectId:e,storyId:b.storyId,figmaNodeId:b.figmaNodeId,name:b.figmaFrameName||b.componentSetName})})).ok?S++:y.warn(`[useAutoMap] Failed to apply mapping for ${b.storyId}`)}catch(A){y.error(`[useAutoMap] Error applying mapping for ${b.storyId}:`,A)}T(`Applied ${S}/${k.length} mappings`),y.debug(`[useAutoMap] Applied ${S}/${k.length} mappings`)}catch(f){l(f instanceof Error?f.message:"Failed to apply mappings")}finally{u(!1)}}},[e]),w=Lo(()=>{n.current?.abort()},[]),v=Lo(()=>{g(null),m(null),l(null),T(""),I(null)},[]);return{collectAndMap:P,rerun:z,loadExisting:R,applyMappings:x,cancel:w,reset:v,isCollecting:r,isMapping:i,isApplying:a,error:c,results:p,manifest:d,progress:C,source:E}}Ne();import{useState as Zm,useEffect as l$,useRef as xC}from"react";var yC=2;async function c$(e,t){try{let n=await fetch(`/__uicopilot/screenshot?storyId=${encodeURIComponent(e)}`,{signal:t});return n.ok&&(await n.json()).screenshot||null}catch{return null}}function bC(e){let[t,n]=Zm({}),[r,o]=Zm(0),[i,s]=Zm(!1),a=xC(null),u=xC(""),c=e.join(",");return l$(()=>{if(!e.length||c===u.current)return;u.current=c,n({}),o(0),s(!0);let l=new AbortController;a.current=l;let p=0;return(async()=>{for(let d=0;d<e.length&&!l.signal.aborted;d+=yC){let m=e.slice(d,d+yC),C=await Promise.all(m.map(E=>c$(E,l.signal).then(I=>({id:E,img:I}))));if(l.signal.aborted)break;let T={};for(let{id:E,img:I}of C)p++,I&&(T[E]=I);Object.keys(T).length>0&&n(E=>({...E,...T})),o(p)}s(!1),y.debug(`[useStoryScreenshots] Captured ${p}/${e.length} screenshots`)})().catch(()=>s(!1)),()=>{l.abort()}},[c]),{screenshots:t,isCapturing:i,progress:{done:r,total:e.length}}}import ve,{useState as eh,useEffect as sa,useMemo as u$,useCallback as p$}from"react";import{styled as d$}from"storybook/theming";Ne();var g$=d$.button(({theme:e})=>({gridColumn:"1 / -1",padding:"8px 16px",backgroundColor:"transparent",border:`1px dashed ${e.appBorderColor}`,borderRadius:e.appBorderRadius,color:e.color.mediumdark,fontSize:e.typography.size.s1,cursor:"pointer",transition:"all 0.15s","&:hover:not(:disabled)":{borderColor:e.color.secondary,color:e.color.secondary},"&:disabled":{opacity:.5,cursor:"not-allowed"}})),_i=({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=ve.useRef(!1);sa(()=>{e&&c&&!p.current&&(l.setSearch(c),p.current=!0),e||(p.current=!1)},[e,c]);let[g,d]=eh(new Set),[m,C]=eh(i||o[0]?.id||"");sa(()=>{i&&C(i)},[i]);let T=50,[E,I]=eh({}),D=p$(k=>{I(f=>({...f,[k]:(f[k]||1)+1}))},[]);sa(()=>{I({})},[l.variantFilters]),sa(()=>{l.expandedSets.forEach(k=>{let f=l.variantChildren[k];if(!f||f.length===0)return;let F=f;l.variantFilters.some(A=>A.value)&&(F=f.filter(A=>A.variantProperties?l.variantFilters.every(L=>L.value?A.variantProperties?.[L.property]===L.value:!0):!1));let S=E[k]||1,b=F.slice(0,S*T).map(A=>A.id);b.length>0&&l.fetchVariantThumbnails(k,b)})},[l.expandedSets,l.variantChildren,l.variantFilters,E]),sa(()=>{d(new Set)},[m]);let R=u$(()=>{let k=[];return l.filteredFrames.forEach(f=>{if(f.type==="COMPONENT_SET"&&f.children){let F=l.variantFilters.some(S=>S.value)?f.children.filter(S=>S.variantProperties?l.variantFilters.every(b=>b.value?S.variantProperties?.[b.property]===b.value:!0):!1):f.children;k.push(...F)}else k.push(f)}),k},[l.filteredFrames,l.variantFilters]),_=k=>{if(a)d(f=>{let F=new Set(f);return F.has(k.id)?F.delete(k.id):F.add(k.id),F});else{let f=l.resolveThumbnail(k.id);try{n({...k,thumbnail:f})}catch(F){y.error("[ComponentBrowserModal] onSelect threw error:",F)}t()}},P=()=>{let k=R.map(F=>F.id),f=k.every(F=>g.has(F));d(f?new Set:new Set(k))},z=()=>{if(u&&g.size>0){let k=R.filter(f=>g.has(f.id)).map(f=>({...f,thumbnail:l.resolveThumbnail(f.id)}));u(k),d(new Set)}},x=k=>{C(k),s?.(k)},w=k=>{k.target===k.currentTarget&&t()},v=o.find(k=>k.id===m);return e?ve.createElement(rk,{onClick:w},ve.createElement(ok,null,ve.createElement(ik,null,ve.createElement(sk,null,"Link Figma Frames"),ve.createElement("div",{style:{display:"flex",gap:"8px",alignItems:"center"}},ve.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"),ve.createElement(ak,{onClick:t},"\xD7"))),ve.createElement(lk,null,l.error&&ve.createElement(mk,null,l.error),!l.error&&ve.createElement(ve.Fragment,null,o.length>0&&ve.createElement(Ik,null,ve.createElement(Fk,null,"Story:"),ve.createElement(Ek,{value:m,onChange:k=>x(k.target.value)},o.map(k=>ve.createElement("option",{key:k.id,value:k.id},k.name,k.mappingsCount?` (${k.mappingsCount} linked)`:""))),v?.mappingsCount?ve.createElement(Ak,{hasMapping:!0},v.mappingsCount," frames linked"):null),ve.createElement(gk,null,ve.createElement(Xl,null,ve.createElement("input",{type:"checkbox",checked:l.showComponentSets,onChange:k=>l.setShowComponentSets(k.target.checked)}),"Component Sets"),ve.createElement(Xl,null,ve.createElement("input",{type:"checkbox",checked:l.showFrames,onChange:k=>l.setShowFrames(k.target.checked)}),"Frames"),ve.createElement(Xl,null,ve.createElement("input",{type:"checkbox",checked:l.showComponents,onChange:k=>l.setShowComponents(k.target.checked)}),"Components"),l.availablePages.length>1&&ve.createElement(Ni,{isActive:!!l.figmaPage,value:l.figmaPage,onChange:k=>l.setFigmaPage(k.target.value),style:{marginLeft:"auto"}},ve.createElement("option",{value:""},"All pages"),l.availablePages.map(k=>ve.createElement("option",{key:k,value:k},k)))),l.filterSuggestion&&ve.createElement(Pk,null,ve.createElement(Lk,null,"AI suggests:"),ve.createElement(Mk,null,Object.entries(l.filterSuggestion.suggestedFilters).map(([k,f])=>`${k}=${f}`).join(", ")),ve.createElement(Bk,{onClick:l.applySuggestedFilters},"Apply"),ve.createElement(Dk,{onClick:l.dismissFilterSuggestion},"Dismiss")),l.filterSuggestionLoading&&ve.createElement(Rk,null,"Matching story args to Figma filters..."),l.availableFilters.length>0&&ve.createElement(Jl,null,ve.createElement(ra,null,"Filters:"),l.availableFilters.map(({property:k,values:f})=>{let F=l.variantFilters.find(S=>S.property===k);return ve.createElement(Ni,{key:k,isActive:!!F?.value,value:F?.value||"",onChange:S=>l.handleFilterChange(k,S.target.value)},ve.createElement("option",{value:""},k),f.map(S=>ve.createElement("option",{key:S,value:S},k,"=",S)))}),l.variantFilters.some(k=>k.value)&&ve.createElement(Zl,{onClick:l.clearFilters},"Clear All")),ve.createElement(ck,{type:"text",placeholder:"Search frames...",value:l.search,onChange:k=>l.setSearch(k.target.value),autoFocus:!0}),a&&R.length>0&&ve.createElement(zk,null,ve.createElement(Nk,{onClick:P},g.size===R.length?"Deselect All":"Select All Visible"),ve.createElement(Ok,null,g.size>0?`${g.size} selected of `:"Showing ",R.length," frames")),l.isLoading&&ve.createElement(Bm,null,Array.from({length:6}).map((k,f)=>ve.createElement(Tk,{key:f},ve.createElement("div",{style:{width:"100%",aspectRatio:"4 / 3"}},ve.createElement(Ql,{width:"100%",height:"100%"})),ve.createElement("div",{style:{padding:"12px",display:"flex",flexDirection:"column",gap:"8px"}},ve.createElement(Ql,{width:"80%",height:"16px"}),ve.createElement(Ql,{width:"50%",height:"12px"}))))),!l.isLoading&&l.filteredFrames.length===0&&ve.createElement(fk,null,l.search?"No frames match your search":"No frames found in this Figma file"),!l.isLoading&&l.filteredFrames.length>0&&ve.createElement(Bm,null,l.filteredFrames.map(k=>ve.createElement(oa,{key:k.id,frame:k,thumbnail:l.thumbnails[k.id],thumbnails:l.thumbnails,variantThumbnails:l.variantThumbnails[k.id],variantChildren:l.variantChildren[k.id],variantFailed:l.variantFailed[k.id],isLoadingVariants:l.loadingVariants.has(k.id),isExpanded:l.expandedSets.has(k.id),isNew:l.recentlyAdded.has(k.name),onToggleExpand:l.toggleExpanded,onSelect:_,multiSelect:a,selectedFrames:g,variantFilters:l.variantFilters,variantPage:E[k.id]||1,onShowMore:D})),l.hasMore&&ve.createElement(g$,{onClick:l.loadMore,disabled:l.loadingMore},l.loadingMore?"Loading...":`Show more (${l.totalFrames-l.frames.length} remaining)`)))),a&&ve.createElement(_k,null,ve.createElement($k,{disabled:g.size===0,onClick:z},"Link ",g.size," Selected")))):null};ke();lt();var m$=Zt.div({position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4}),h$=Zt.div(({theme:e})=>({width:"90vw",maxWidth:"1100px",height:"75vh",backgroundColor:e.background.content,borderRadius:"12px",display:"flex",flexDirection:"column",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.3)",overflow:"hidden"})),x$=Zt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app})),y$=Zt.div({display:"flex",alignItems:"center",gap:"20px"}),b$=Zt.h2(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.defaultText,margin:0,display:"flex",alignItems:"center",gap:"8px"})),S$=Zt.div({display:"flex",gap:"4px"}),SC=Zt(mo)(({theme:e,active:t})=>({padding:"8px 16px",borderBottom:"none",borderRadius:"6px",backgroundColor:t?e.background.hoverable:"transparent","&:hover":{backgroundColor:e.background.hoverable}})),w$=Zt(kn)({width:"32px",height:"32px",fontSize:"20px",borderRadius:"6px"}),v$=Zt.div({flex:1,overflow:"hidden",display:"flex",flexDirection:"column"}),k$=Zt.div(({theme:e})=>({padding:"12px 20px",borderTop:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app,display:"flex",alignItems:"center",justifyContent:"space-between"})),C$=Zt.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,display:"flex",gap:"16px"})),T$=Zt.div({display:"flex",flexDirection:"column",flex:1,alignItems:"center",justifyContent:"center",backgroundColor:"rgba(255, 255, 255, 0.95)",padding:"40px"}),I$=Zt.div({display:"flex",flexDirection:"column",alignItems:"center",gap:"20px",maxWidth:"400px"}),F$=Zt.div(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText,textAlign:"center"})),E$=Zt.div(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark,textAlign:"center"})),A$=Zt.div(({theme:e})=>({width:"100%",height:"8px",backgroundColor:e.appBorderColor,borderRadius:"4px",overflow:"hidden"})),P$=Zt.div(({theme:e})=>({width:"100%",height:"100%",backgroundColor:e.color.secondary,borderRadius:"4px",opacity:.6})),L$=Zt.button(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",padding:"6px 14px",backgroundColor:e.color.defaultText,color:"white",border:"none",borderRadius:"6px",fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,cursor:"pointer",transition:"opacity 0.15s","&:hover":{opacity:.85},"&:disabled":{opacity:.5,cursor:"not-allowed"}})),wC=Zt.span(({theme:e,type:t})=>({display:"flex",alignItems:"center",gap:"6px","& .dot":{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:t==="mapped"?e.color.positive:t==="unmapped"?e.color.mediumlight:"transparent"}})),vC=({isOpen:e,onClose:t,projectId:n})=>{let[r,o]=$i("map"),[i,s]=$i([]),[a,u]=$i(!0),[c,l]=$i(null),[p,g]=$i(!1),[d,m]=$i(null),C=hC({projectId:n}),{refreshMappings:T}=nt(),{featureFlags:E}=ce(),I=et.useMemo(()=>C.results?.mappings.map(b=>b.storyId)||[],[C.results]),D=bC(I),R=Mo(async()=>{u(!0);try{let b=await fetch("/index.json");if(!b.ok)throw new Error("Failed to fetch index.json");let A=await b.json(),L=A.entries||A.stories||{},B=Object.entries(L).filter(([,h])=>h.type==="story").map(([h,j])=>({id:h,name:j.name||h.split("--").pop()||h,title:j.title||"",importPath:j.importPath,componentTitle:j.title?.split("/").slice(0,-1).join("/")||j.title,figmaMapping:null}));try{let h=G(),j=localStorage.getItem("uicopilot_session_token"),H=await ne(`${h}/api/mappings?projectId=${n}&_t=${Date.now()}`,{headers:{Authorization:`Bearer ${j}`}});if(H.ok){let M=await H.json(),X=new Map((M.mappings||[]).map(Z=>[Z.storyId,Z]));B.forEach(Z=>{let me=X.get(Z.id);me&&me.figmaNodeId&&(Z.figmaMapping={figmaNodeId:me.figmaNodeId,figmaFrameName:me.name||me.figmaFrameName||""})})}}catch(h){console.warn("[StoryMappingAssistant] Failed to fetch mappings (stories still loaded):",h)}s(B);let N=B.find(h=>!h.figmaMapping);N?l(N.id):B.length>0&&l(B[0].id)}catch(b){console.error("[StoryMappingAssistant] Error fetching stories:",b)}finally{u(!1)}},[n]);f$(()=>{e&&R()},[e,R]);let _=Mo((b,A,L)=>{s(h=>h.map(j=>j.id===b?{...j,figmaMapping:{figmaNodeId:A,figmaFrameName:L}}:j));let B=i.findIndex(h=>h.id===b),N=i.find((h,j)=>j>B&&!h.figmaMapping);N&&l(N.id)},[i]),P=Mo(b=>{s(A=>A.map(L=>L.id===b?{...L,figmaMapping:null}:L))},[]),z=Mo(b=>{l(b),o("map")},[]),x=Mo(()=>{let b=i.filter(A=>A.figmaMapping).map(A=>A.id);C.collectAndMap(b)},[i,C]),w=Mo(()=>{let b=i.filter(A=>A.figmaMapping).map(A=>A.id);g(!1),C.rerun(b)},[i,C]),v=Mo(async b=>{await C.applyMappings(b),g(!1),C.reset(),R(),T()},[C,R,T]),k=Mo(()=>{g(!1),C.reset()},[C]);et.useEffect(()=>{C.results&&g(!0)},[C.results]);let f=b=>{b.target===b.currentTarget&&t()};if(!e)return null;let F=i.filter(b=>b.figmaMapping).length,S=i.length;return et.createElement(et.Fragment,null,et.createElement(m$,{onClick:f},et.createElement(h$,{onClick:b=>b.stopPropagation()},et.createElement(x$,null,et.createElement(y$,null,et.createElement(b$,null,et.createElement("span",null,"\u{1F517}"),"Link Stories to Figma"),et.createElement(S$,null,et.createElement(SC,{active:r==="map",onClick:()=>o("map")},"Map Stories"),et.createElement(SC,{active:r==="view",onClick:()=>o("view")},"View All Mappings"))),et.createElement("div",{style:{display:"flex",alignItems:"center",gap:"12px"}},E.enableAutoMap&&!p&&!C.isCollecting&&!C.isMapping&&et.createElement(L$,{onClick:x,disabled:a||i.length===0},et.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2"},et.createElement("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),et.createElement("path",{d:"M2 17l10 5 10-5"}),et.createElement("path",{d:"M2 12l10 5 10-5"})),"Auto-Map All"),et.createElement(w$,{onClick:t},"\xD7"))),et.createElement(v$,null,(C.isCollecting||C.isMapping)&&et.createElement(T$,null,et.createElement(I$,null,et.createElement(A$,null,et.createElement(P$,null)),et.createElement(F$,null,"Auto-mapping stories to Figma"),et.createElement(E$,null,C.progress),et.createElement(Tr,{onClick:C.cancel,variant:"ghost"},"Cancel"))),p&&C.results&&et.createElement(mC,{results:C.results,stories:i,onApply:v,onCancel:k,onRerun:w,isApplying:C.isApplying,isRerunning:C.isCollecting||C.isMapping,source:C.source,resolveThumbnail:b=>C.results?.thumbnailUrls?.[b],resolveStoryScreenshot:b=>D.screenshots[b],isCapturingScreenshots:D.isCapturing,onBrowse:b=>m(b)}),!p&&!C.isCollecting&&!C.isMapping&&(r==="map"?et.createElement(Qk,{stories:i,loading:a,selectedStoryId:c,onSelectStory:l,onStoryMapped:_,projectId:n}):et.createElement(tC,{stories:i,loading:a,onLink:z,onUnlink:P,projectId:n}))),et.createElement(k$,null,et.createElement(C$,null,et.createElement("span",null,"Total: ",S," stories"),et.createElement(wC,{type:"mapped"},et.createElement("span",{className:"dot"}),F," mapped"),et.createElement(wC,{type:"unmapped"},et.createElement("span",{className:"dot"}),S-F," unmapped"))))),et.createElement(_i,{isOpen:!!d,onClose:()=>m(null),onSelect:()=>m(null),projectId:n,initialSearch:d||void 0}))};lt();var kC=Xn.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}})),B$=Xn.div(({theme:e})=>({width:"20px",height:"20px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,"& svg":{width:"16px",height:"16px"}})),D$=Xn.div({display:"flex",alignItems:"center",gap:"12px",flex:1}),R$=Xn.div({display:"flex",alignItems:"center",gap:"8px"}),z$=Xn.div(({theme:e})=>({width:"60px",height:"4px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),N$=Xn.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"})),O$=Xn.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"})),_$=Xn.span(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText})),$$=Xn(lu)({padding:"4px 10px",fontSize:"12px",fontWeight:600,marginLeft:"auto"}),U$=Xn(lu)(({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)"}})),j$=Xn.span(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,fontStyle:"italic"})),H$=Xn.div(({theme:e})=>({width:"14px",height:"14px",border:`2px solid ${e.appBorderColor}`,borderTopColor:ae,borderRadius:"50%",animation:"figma-mapping-spin 0.8s linear infinite","@keyframes figma-mapping-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),W$=Xn.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),CC=()=>{let[e,t]=cc(!1),[n,r]=cc({totalStories:0,mappedStories:0,loading:!0}),{selectedProjectId:o}=Je(),{sessionToken:i}=we();M$(()=>{o&&i?s():r({totalStories:0,mappedStories:0,loading:!1})},[o,i]);let s=async()=>{r(_=>({..._,loading:!0}));try{let _=await fetch("/index.json");if(!_.ok)throw new Error("Failed to fetch Storybook index");let P=await _.json(),z=P.entries||P.stories||{},x=Object.keys(z).filter(F=>z[F].type==="story").length,w=Object.keys(z).filter(F=>z[F].type==="story"),v=G(),k=await ne(`${v}/api/mappings?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}}),f=0;if(k.ok){let F=await k.json(),S=F.mappings||F||[];if(Array.isArray(S)){let b=new Set(S.map(A=>A.storyId).filter(Boolean));f=w.filter(A=>b.has(A)).length}else{let b=await ne(`${v}/api/mappings/stats?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}});if(b.ok){let A=await b.json();f=Math.min(A.mappedStoriesCount||0,x)}}}r({totalStories:x,mappedStories:f,loading:!1})}catch(_){console.error("[FigmaMappingsSection] Error fetching stats:",_),r(P=>({...P,loading:!1}))}},[a,u]=cc(!1),[c,l]=cc(!1),p=async()=>{!o||!i||l(!0)},g=async()=>{l(!1),u(!0);try{let _=G(),P=await ne(`${_}/api/mappings?projectId=${o}`,{headers:{Authorization:`Bearer ${i}`}});if(!P.ok)throw new Error("Failed to fetch mappings");let x=(await P.json()).mappings||[];await Promise.all(x.map(w=>ne(`${_}/api/mappings?id=${encodeURIComponent(w.id)}`,{method:"DELETE",headers:{Authorization:`Bearer ${i}`}}))),s()}catch(_){console.error("[FigmaMappingsSection] Unlink all failed:",_)}finally{u(!1)}},d=()=>t(!0),m=()=>{t(!1),o&&i&&s()};if(!o)return vt.createElement(kC,null,vt.createElement(j$,null,"Select a project to link Figma designs"));let{totalStories:C,loading:T}=n,E=Math.min(n.mappedStories,C),I=E===0?"none":E>=C?"complete":"partial",D=C>0?Math.min(100,Math.round(E/C*100)):0,R=I==="none"?"Link designs":"Manage";return vt.createElement(vt.Fragment,null,vt.createElement(kC,null,vt.createElement(B$,null,vt.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},vt.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"}),vt.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"}),vt.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),vt.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"}),vt.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"}))),vt.createElement(D$,null,vt.createElement(_$,null,"Figma Mappings"),vt.createElement(R$,null,T?vt.createElement(vt.Fragment,null,vt.createElement(H$,null),vt.createElement(W$,null,"Loading...")):vt.createElement(vt.Fragment,null,vt.createElement(z$,null,vt.createElement(N$,{percent:D,state:I})),vt.createElement(O$,{state:I},`${E}/${C}`)))),E>0&&vt.createElement(U$,{onClick:p,disabled:T||a},a?"Unlinking...":"Unlink All"),vt.createElement($$,{onClick:d,disabled:T},R)),e&&vt.createElement(vC,{isOpen:e,onClose:m,projectId:o}),vt.createElement(Nr,{isOpen:c,title:"Unlink All Mappings",message:`Unlink all ${n.mappedStories} Figma mappings?`,confirmLabel:"Unlink All",variant:"danger",onConfirm:g,onCancel:()=>l(!1)}))};import le,{useState as Ui,useEffect as uc,useCallback as TC,useRef as th}from"react";import{styled as Qn}from"storybook/theming";ke();je();lt();var nh=Qn.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.background.content,borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px",fontSize:"12px"})),rh=Qn.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),oh=Qn.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),Ene=Qn(Br)({padding:"5px 12px",fontSize:"12px"}),ih=Qn.div(({theme:e})=>({display:"flex",gap:"16px",color:e.color.mediumdark,marginBottom:"4px"})),pc=Qn.span(({theme:e})=>({whiteSpace:"nowrap","& strong":{color:e.color.defaultText,fontWeight:600}})),V$=Qn.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})),G$=Qn.div(({theme:e})=>({marginTop:"6px",padding:"6px 8px",backgroundColor:e.background.hoverable,borderRadius:"4px",color:e.color.mediumdark,lineHeight:"1.4"})),sh=Qn.span(({theme:e,type:t})=>({fontWeight:500,color:t==="added"?e.color.positive:t==="removed"?e.color.negative:e.color.warning})),q$=Qn.span(({theme:e})=>({color:e.color.mediumdark,fontSize:"12px"})),dc=Qn.div(({theme:e})=>({width:"100%",height:"8px",backgroundColor:e.appBorderColor,borderRadius:"4px",overflow:"hidden",marginTop:"10px"})),gc=Qn.div(({theme:e,percent:t})=>({width:`${t}%`,height:"100%",backgroundColor:e.color.secondary,borderRadius:"3px",transition:"width 0.5s ease"})),Bo=Qn.div(({theme:e})=>({display:"flex",justifyContent:"space-between",marginTop:"6px",fontSize:"12px",fontWeight:500,color:e.color.defaultText})),IC=new Set,FC=()=>{let{userRole:e,featureFlags:t}=ce(),[n,r]=Ui(null),[o,i]=Ui(!0),[s,a]=Ui(!1),[u,c]=Ui(!1),[l,p]=Ui(!1),[g,d]=Ui(!1),{selectedProjectId:m,projects:C}=Je(),{sessionToken:T}=we(),E=th(null),I=th(null),D=th(null),R=TC(()=>{E.current&&(clearInterval(E.current),E.current=null),I.current&&(clearInterval(I.current),I.current=null),D.current&&(clearTimeout(D.current),D.current=null)},[]);uc(()=>R,[R]);let _=TC(async()=>{if(!(!m||!T))try{let S=G(),b=await ne(`${S}/api/figma/cache-status?projectId=${m}`,{headers:{Authorization:`Bearer ${T}`}});if(b.ok){let A=await b.json();r(A)}}catch(S){console.error("[FigmaCacheSection] Error:",S)}finally{i(!1)}},[m,T]);uc(()=>{_()},[_]),uc(()=>{if(o||s||!n||n.structureStatus!=="none"||!m||IC.has(m))return;let S=C.find(A=>A.id===m);(S?.figmaFileUrl||S?.figmaFileId)&&(IC.add(m),P())},[o,s,n?.structureStatus,m,C]),uc(()=>{let S=n?.thumbnailProgress?.status,b=n?.enrichmentProgress?.status,A=n?.thumbnailProgress?.cached??0,L=n?.thumbnailProgress?.total??0,B=S==="in-progress"||S==="pending"||L>0&&A<L,N=b==="in-progress"||b==="pending",h=!n?.thumbnailProgress&&n?.structureStatus==="cached";if(!(B||N||h)||!n||n.structureStatus==="none")return;let H=setInterval(()=>{_()},3e3);return()=>{clearInterval(H)}},[n?.thumbnailProgress?.status,n?.thumbnailProgress?.cached,n?.thumbnailProgress?.total,n?.enrichmentProgress?.status,n?.structureStatus,_]);let P=async()=>{if(!(!m||!T)){a(!0);try{let S=G();await ne(`${S}/api/figma/frames?projectId=${m}&type=COMPONENT_SET&page=1&limit=1&refresh=true`,{headers:{Authorization:`Bearer ${T}`}},6e4),await new Promise(b=>setTimeout(b,1e3)),await _(),setTimeout(async()=>{await _()},3e3)}catch(S){console.error("[FigmaCacheSection] Reload error:",S)}finally{a(!1)}}},z=async()=>{if(!(!m||!T)){c(!0);try{let S=G(),b=await ne(`${S}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${T}`},body:JSON.stringify({projectId:m})});console.log("[FigmaCacheSection] Cache invalidate response:",b.status),await ne(`${S}/api/figma/frames/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${T}`},body:JSON.stringify({projectId:m})}).catch(()=>{}),r({structureStatus:"none",structureCachedAt:null,componentSetCount:0,componentCount:0,pageCount:0,pages:[],cacheDiff:null,thumbnailProgress:null,enrichmentProgress:null})}catch(S){console.error("[FigmaCacheSection] Clear cache error:",S)}finally{c(!1)}}},x=async()=>{if(!(!m||!T)){R(),p(!0);try{let S=G();await ne(`${S}/api/figma/enrich`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${T}`},body:JSON.stringify({projectId:m})}),E.current=setInterval(async()=>{await _()},3e3),I.current=setInterval(()=>{(n?.enrichmentProgress?.status==="complete"||n?.enrichmentProgress?.status==="error")&&(R(),p(!1),_())},3e3),D.current=setTimeout(()=>{R(),p(!1)},6e5)}catch(S){console.error("[FigmaCacheSection] Enrich error:",S),R(),p(!1)}}},w=async()=>{if(!(!m||!T)){d(!0);try{let S=G();await ne(`${S}/api/figma/cancel`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${T}`},body:JSON.stringify({projectId:m})}),await _()}catch(S){console.error("[FigmaCacheSection] Cancel error:",S)}finally{d(!1),p(!1),a(!1)}}},v=n?.thumbnailProgress?.status==="in-progress"||n?.enrichmentProgress?.status==="in-progress";if(!m)return null;if(o)return le.createElement(nh,null,le.createElement(rh,null,le.createElement(oh,null,"Figma Cache")),le.createElement(ih,null,le.createElement(pc,null,"Loading cache status\u2026")),le.createElement(dc,null,le.createElement(gc,{percent:100,style:{opacity:.3}})));if(!n||n.structureStatus==="none")return le.createElement(nh,null,le.createElement(rh,null,le.createElement(oh,null,"Figma Cache"),le.createElement(Tr,{loading:s,onClick:P,loadingText:"Loading..."},"\u21BB Load")),s?le.createElement(le.Fragment,null,le.createElement(dc,null,le.createElement(gc,{percent:30,style:{animation:"none",width:"100%",opacity:.3}})),le.createElement(Bo,null,le.createElement("span",null,"Downloading structure from Figma... this may take 30-60 seconds"))):le.createElement(ih,null,le.createElement(pc,null,"No cache \u2014 click Load to fetch from Figma")));let k=S=>{let b=Date.now()-new Date(S).getTime(),A=Math.floor(b/6e4);if(A<1)return"just now";if(A<60)return`${A}m ago`;let L=Math.floor(A/60);return L<24?`${L}h ago`:`${Math.floor(L/24)}d ago`},f=n.cacheDiff,F=f&&(f.added.length>0||f.removed.length>0||f.renamed.length>0);return le.createElement(nh,null,le.createElement(rh,null,le.createElement(oh,null,"Figma Cache"," ",le.createElement(V$,{status:n.structureStatus},n.structureStatus)),le.createElement("div",{style:{display:"flex",gap:"6px"}},e==="admin"&&le.createElement(Tr,{loading:l,onClick:x,loadingText:"Enriching..."},"Enrich"),le.createElement(Tr,{loading:u,onClick:z,variant:"ghost",loadingText:"Clearing..."},"Clear"),le.createElement(Tr,{loading:s,onClick:P,loadingText:"Reloading..."},"\u21BB Reload"),v&&le.createElement(Tr,{loading:g,onClick:w,variant:"ghost",loadingText:"Cancelling..."},"\u2715 Cancel"))),s&&le.createElement(Bo,null,le.createElement("span",null,"Downloading structure from Figma...")),le.createElement(ih,null,le.createElement(pc,null,le.createElement("strong",null,n.componentSetCount)," component sets"),le.createElement(pc,null,le.createElement("strong",null,n.pageCount)," pages"),n.structureCachedAt&&le.createElement(q$,null,"Updated ",k(n.structureCachedAt))),F&&le.createElement(G$,null,"Since last reload:"," ",f.added.length>0&&le.createElement(sh,{type:"added"},"+",f.added.length," added"),f.added.length>0&&f.removed.length>0&&" \xB7 ",f.removed.length>0&&le.createElement(sh,{type:"removed"},"\u2212",f.removed.length," removed"),(f.added.length>0||f.removed.length>0)&&f.renamed.length>0&&" \xB7 ",f.renamed.length>0&&le.createElement(sh,{type:"renamed"},f.renamed.length," renamed")),n.thumbnailProgress&&n.thumbnailProgress.status==="in-progress"&&le.createElement(le.Fragment,null,le.createElement(dc,null,le.createElement(gc,{percent:n.thumbnailProgress.total>0?Math.round(n.thumbnailProgress.cached/n.thumbnailProgress.total*100):0})),le.createElement(Bo,null,le.createElement("span",null,"Variant thumbnails: caching to CDN\u2026",n.thumbnailProgress.currentName&&le.createElement(le.Fragment,null," ",n.thumbnailProgress.currentName)),le.createElement("span",null,n.thumbnailProgress.cached," of ",n.thumbnailProgress.total," variants"))),n.thumbnailProgress&&n.thumbnailProgress.status==="complete"&&le.createElement(Bo,null,le.createElement("span",null,"Variant thumbnails: ",n.thumbnailProgress.cached," of ",n.thumbnailProgress.total," cached to CDN \u2713")),(!n.thumbnailProgress||n.thumbnailProgress.status==="pending"&&n.thumbnailProgress.cached===0)&&le.createElement(Bo,null,le.createElement("span",null,"Variant thumbnails: not yet cached",n.thumbnailProgress?.total?` (${n.thumbnailProgress.total} components)`:""," \u2014 click Reload to generate")),n.thumbnailProgress&&n.thumbnailProgress.status==="pending"&&n.thumbnailProgress.cached>0&&le.createElement(Bo,null,le.createElement("span",null,"Variant thumbnails: ",n.thumbnailProgress.cached," of ",n.thumbnailProgress.total," cached to CDN (partial)")),n.enrichmentProgress&&n.enrichmentProgress.status==="in-progress"&&le.createElement(le.Fragment,null,le.createElement(dc,null,le.createElement(gc,{percent:n.enrichmentProgress.total>0?Math.round(n.enrichmentProgress.enriched/n.enrichmentProgress.total*100):0})),le.createElement(Bo,null,le.createElement("span",null,"AI descriptions: generating\u2026",n.enrichmentProgress.currentName&&le.createElement(le.Fragment,null," ",n.enrichmentProgress.currentName)),le.createElement("span",null,n.enrichmentProgress.enriched," of ",n.enrichmentProgress.total," component sets"))),n.enrichmentProgress&&n.enrichmentProgress.status==="complete"&&le.createElement(le.Fragment,null,le.createElement(Bo,null,le.createElement("span",null,"AI descriptions: ",n.enrichmentProgress.enriched," of ",n.enrichmentProgress.total," component sets \u2713"))),n.enrichmentProgress&&n.enrichmentProgress.status==="processing"&&t.showCosts&&n.enrichmentProgress.costUsd!=null&&n.enrichmentProgress.costUsd>0&&le.createElement("div",{style:{marginTop:"6px"}},le.createElement(ic,{inputTokens:n.enrichmentProgress.inputTokens||0,outputTokens:n.enrichmentProgress.outputTokens||0,costUsd:n.enrichmentProgress.costUsd,compact:!0})))};import ht,{useState as ji}from"react";import{styled as _r}from"storybook/theming";ke();je();lt();var ah=_r.div({padding:"12px 16px"}),Y$=_r.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),EC=_r.label(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),AC=_r.button(({theme:e})=>({background:"none",border:"none",fontSize:"12px",color:ae,cursor:"pointer",padding:0,"&:hover":{textDecoration:"underline"}})),K$=_r.div({display:"flex",gap:"8px",alignItems:"center"}),X$=_r.input(({theme:e})=>({flex:1,padding:"8px 12px",fontSize:"13px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.input.background,color:e.input.color,outline:"none",fontFamily:"monospace","&:focus":{borderColor:ae,boxShadow:`0 0 0 1px ${ae}`},"&::placeholder":{color:e.color.mediumlight,fontFamily:"inherit"}})),PC=_r.span(({variant:e})=>({fontSize:"12px",color:e==="success"?"#16a34a":e==="error"?"#dc2626":"#6b7280",marginTop:"6px",display:"block",lineHeight:1.4})),Q$=_r.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,marginTop:"8px",lineHeight:1.5,"& a":{color:ae,textDecoration:"none","&:hover":{textDecoration:"underline"}},"& ol":{margin:"4px 0 0 16px",padding:0},"& li":{marginBottom:"2px"}})),J$=_r.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})),Z$=_r.button(({theme:e})=>({background:"none",border:"none",fontSize:"11px",color:"#dc2626",cursor:"pointer",marginLeft:"auto","&:hover":{textDecoration:"underline"}})),LC=({onConnected:e})=>{let{sessionToken:t}=we(),[n,r]=ji(!1),[o,i]=ji(""),[s,a]=ji(!1),[u,c]=ji(null),[l,p]=ji(null),[g,d]=ji(!1),m=async()=>{if(!(!o.trim()||!t)){a(!0),c(null);try{let C=G(),T=await ne(`${C}/api/figma/pat`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({token:o.trim()})}),E=await T.json();if(!T.ok){c({type:"error",message:E.error||"Failed to save token"});return}p(E.figmaUser?.handle||E.figmaUser?.email||"Connected"),c({type:"success",message:`Connected as ${E.figmaUser?.handle||"Figma user"}`}),i(""),e?.()}catch{c({type:"error",message:"Failed to connect. Check your token and try again."})}finally{a(!1)}}};return l?ht.createElement(ah,null,ht.createElement(EC,null,"Figma Personal Access Token"),ht.createElement(J$,null,ht.createElement("span",null,"\u2713 Connected as ",ht.createElement("strong",null,l)),ht.createElement(Z$,{onClick:()=>{p(null),c(null)}},"Change token"))):n?ht.createElement(ah,null,ht.createElement(Y$,null,ht.createElement(EC,null,"Figma Personal Access Token"),ht.createElement(AC,{onClick:()=>d(!g)},g?"Hide instructions":"How to generate")),g&&ht.createElement(Q$,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(K$,null,ht.createElement(X$,{type:"password",value:o,onChange:C=>i(C.target.value),placeholder:"figd_...",onKeyDown:C=>{C.key==="Enter"&&o.trim()&&m()}}),ht.createElement(qt,{onClick:m,disabled:!o.trim()||s},s?"Verifying...":"Save & Verify")),u&&ht.createElement(PC,{variant:u.type},u.message),ht.createElement(PC,{variant:"info"},"Read-only access. Your token is stored securely and never shared.")):ht.createElement(ah,null,ht.createElement(AC,{onClick:()=>r(!0)},"Or use a Personal Access Token \u2192"))};ke();je();lt();var t4=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"})),ch=Ir.div(({theme:e})=>({border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",marginBottom:"16px",backgroundColor:e.background.content})),n4=Ir.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",padding:"10px 16px",backgroundColor:e.background.hoverable,borderBottom:`1px solid ${e.appBorderColor}`})),r4=Ir.div({width:"16px",height:"16px",display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}),o4=Ir.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,flex:1})),uh=Ir.div({"& > *":{border:"none",borderRadius:0,marginBottom:0,borderBottom:"1px solid rgba(0,0,0,0.06)","&:last-child":{borderBottom:"none"}}}),i4=Ir.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.base==="dark"?"rgba(0, 204, 102, 0.2)":"rgba(0, 204, 102, 0.1)",border:`1px solid ${e.color.positive}`,borderRadius:"8px",margin:"12px 16px",display:"flex",alignItems:"center",justifyContent:"space-between"})),s4=Ir.div({display:"flex",alignItems:"center",gap:"8px"}),a4=Ir(vn)(({theme:e})=>({backgroundColor:`${e.base==="dark"?"rgba(197, 48, 48, 0.15)":"rgba(254, 178, 178, 0.3)"} !important`,color:`${e.color.negative} !important`,border:`1px solid ${e.color.negative} !important`,padding:"6px 12px !important",fontSize:"12px !important"})),l4=Ir.div({padding:"20px 16px",display:"flex",flexDirection:"column",gap:"12px"}),Yne=Ir.button({display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",width:"100%",padding:"8px 16px",backgroundColor:"#A259FF",color:"#fff",border:"none",borderRadius:"6px",fontSize:"13px",fontWeight:600,cursor:"pointer","&:hover":{backgroundColor:"#8a3de8"}}),c4=Ir.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}})),BC=({hideHeader:e=!1})=>{let{sessionToken:t}=we(),[n,r]=lh(!1),[o,i]=lh(null),[s,a]=lh(!1);e4(()=>{if(!t)return;let p=G();ne(`${p}/api/figma/connection-status`,{headers:{Authorization:`Bearer ${t}`}}).then(g=>g.json()).then(g=>i(!!g.connected)).catch(()=>i(!1))},[t]);let u=MC(()=>{let g=`${G()}/addon/auth`;window.open(g,"figma-oauth","width=600,height=700,left=200,top=100")},[]),c=MC(async()=>{try{r(!0);let p=G(),g=await ne(`${p}/api/figma/disconnect`,{method:"POST",headers:{Authorization:`Bearer ${t}`}});(g.ok||g.status===404)&&i(!1)}catch{}finally{r(!1)}},[t]),l=e?null:bt.createElement(n4,null,bt.createElement(r4,null,t4),bt.createElement(o4,null,"Figma Integration"));return o===null?bt.createElement(ch,null,l,bt.createElement(uh,null,bt.createElement("div",{style:{padding:"16px",fontSize:"13px",color:"#9ca3af"}},"Checking Figma connection..."))):o===!1?bt.createElement(ch,null,l,bt.createElement(uh,null,bt.createElement(l4,null,bt.createElement(qt,{onClick:u,style:{width:"100%"}},"Connect with Figma"),bt.createElement(c4,null,"or"),bt.createElement(LC,{onConnected:()=>i(!0)})))):bt.createElement(ch,null,l,bt.createElement(i4,null,bt.createElement(s4,null,bt.createElement("span",{style:{fontSize:"18px"}},"\u2713"),bt.createElement("span",{style:{fontSize:"13px",fontWeight:600,color:"#00cc66"}},"Connected to Figma")),bt.createElement(a4,{onClick:()=>a(!0),disabled:n},n?"Disconnecting...":"Disconnect")),bt.createElement(Nr,{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(uh,null,bt.createElement(nk,null),bt.createElement(CC,null),bt.createElement(FC,null)))};ke();var u4=pr.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"}),p4=pr.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"})),d4=pr.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})),g4=pr.h2(({theme:e})=>({margin:0,fontSize:"16px",fontWeight:600,color:e.color.defaultText})),f4=pr(kn)({fontSize:"18px",padding:"2px 8px",lineHeight:1,background:"transparent",border:"none"}),m4=pr.div({display:"flex",flexDirection:"column",gap:"16px",padding:"0 20px 20px"}),DC=pr.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:"14px",padding:"16px",borderRadius:"12px",border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content})),RC=pr.div({display:"flex",alignItems:"center",gap:"10px"}),zC=pr.h3(({theme:e})=>({margin:0,fontSize:"14px",fontWeight:600,color:e.color.defaultText,flex:1})),h4=pr.div({width:"28px",height:"28px",borderRadius:"7px",backgroundColor:ae,color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",fontWeight:700,letterSpacing:"0.3px",flexShrink:0}),x4=pr.div({width:"22px",height:"22px",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center","& svg":{width:"22px",height:"22px"}}),NC=pr.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"}})),OC=({onClose:e})=>{let{isConnected:t}=we(),{selectedProjectId:n}=Je();return Pt.createElement(u4,{onClick:e},Pt.createElement(p4,{onClick:r=>r.stopPropagation()},Pt.createElement(d4,null,Pt.createElement(g4,null,"Settings"),Pt.createElement(f4,{onClick:e,title:"Close settings"},"\xD7")),Pt.createElement(m4,null,Pt.createElement(DC,null,Pt.createElement(RC,null,Pt.createElement(h4,null,"UI"),Pt.createElement(zC,null,"UI Parity")),Pt.createElement(NC,null,Pt.createElement(Qv,null),t&&Pt.createElement(ek,null))),t&&n&&Pt.createElement(DC,null,Pt.createElement(RC,null,Pt.createElement(x4,null,Pt.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Pt.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"}),Pt.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"}),Pt.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),Pt.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"}),Pt.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"}))),Pt.createElement(zC,null,"Figma Integration")),Pt.createElement(NC,null,Pt.createElement(BC,{hideHeader:!0}))))))};import gt,{useEffect as YC,useMemo as W4,useState as V4,useRef as G4}from"react";import{styled as $n,keyframes as q4}from"storybook/theming";ke();ke();import Kt,{useState as y4}from"react";import{styled as _n}from"storybook/theming";var ro=[{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 b4=_n.div({display:"flex",alignItems:"center",gap:"8px",width:"100%"}),S4=_n.div({display:"inline-flex",flexWrap:"nowrap",gap:"4px",alignItems:"center"}),w4=_n.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"}}),v4=_n.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}})),k4=_n.div({position:"relative",display:"inline-block"}),C4=_n.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}})),T4=_n.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"})),ph=_n.div(({theme:e})=>({borderBottom:`1px solid ${e.appBorderColor}`,"&:last-child":{borderBottom:"none"}})),dh=_n.div(({theme:e})=>({padding:"8px 12px",fontSize:"10px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px",backgroundColor:e.background.app})),I4=_n.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}})),F4=_n.input({cursor:"pointer",flexShrink:0,"&:disabled":{cursor:"not-allowed"}}),E4=_n.div({flex:1,minWidth:0}),A4=_n.div({fontSize:"12px",fontWeight:500,marginBottom:"2px"}),P4=_n.div(({theme:e})=>({fontSize:"10px",color:e.textMutedColor,lineHeight:"1.2"})),L4=5,_C=()=>{let{selectedModels:e,toggleModel:t,isReviewing:n}=ce(),[r,o]=y4(!1),i=ro.filter(d=>d.provider==="anthropic"&&!e.includes(d.id)),s=ro.filter(d=>d.provider==="openai"&&!e.includes(d.id)),a=ro.filter(d=>d.provider==="google"&&!e.includes(d.id)),u=ro.filter(d=>e.includes(d.id)),c=e.length<L4,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))},g=d=>{let m=e.includes(d.id),C=m&&e.length===1,T=n||C||!m&&!c;return Kt.createElement(I4,{key:d.id,disabled:T,onClick:()=>p(d.id)},Kt.createElement(F4,{type:"checkbox",checked:m,disabled:T,onChange:()=>{},onClick:E=>E.stopPropagation()}),Kt.createElement(E4,null,Kt.createElement(A4,null,d.name),d.description&&Kt.createElement(P4,null,d.description)))};return Kt.createElement(b4,null,Kt.createElement(k4,null,Kt.createElement(C4,{disabled:n,isOpen:r,onClick:()=>o(!r)},Kt.createElement("span",null,"Select model"),Kt.createElement("span",null,r?"\u25B2":"\u25BC")),r&&Kt.createElement(T4,null,Kt.createElement(ph,null,Kt.createElement(dh,null,"Anthropic"),i.map(g)),Kt.createElement(ph,null,Kt.createElement(dh,null,"OpenAI"),s.map(g)),Kt.createElement(ph,null,Kt.createElement(dh,null,"Google"),a.map(g)))),Kt.createElement(S4,null,u.map(d=>Kt.createElement(w4,{key:d.id,disabled:n,provider:d.provider},d.name,e.length>1&&Kt.createElement(v4,{disabled:n,onClick:m=>l(d.id,m),title:"Remove model"},"\xD7")))))};import Re,{useState as M4,useEffect as B4}from"react";import{styled as en,keyframes as Hi}from"storybook/theming";ke();var D4=Hi`
45
45
  0%, 100% {
46
46
  opacity: 1;
47
47
  transform: scale(1);
@@ -50,20 +50,20 @@ ${st}`).join(`
50
50
  opacity: 0.4;
51
51
  transform: scale(0.8);
52
52
  }
53
- `,n4=Ni`
53
+ `,R4=Hi`
54
54
  0% { transform: rotate(0deg); }
55
55
  100% { transform: rotate(360deg); }
56
- `,PC=Ni`
56
+ `,jC=Hi`
57
57
  0% { opacity: 0; transform: translateY(2px); }
58
58
  100% { opacity: 1; transform: translateY(0); }
59
- `,r4=Ni`
59
+ `,z4=Hi`
60
60
  0%, 100% {
61
61
  opacity: 1;
62
62
  }
63
63
  50% {
64
64
  opacity: 0.6;
65
65
  }
66
- `,o4=Ni`
66
+ `,N4=Hi`
67
67
  0% {
68
68
  transform: translateY(0) rotate(0deg) scale(1);
69
69
  opacity: 1;
@@ -75,59 +75,59 @@ ${st}`).join(`
75
75
  transform: translateY(60px) rotate(720deg) scale(0.5);
76
76
  opacity: 0;
77
77
  }
78
- `;var Ine=jt.div({display:"flex",alignItems:"center",gap:"6px",flexWrap:"wrap"}),oh=jt.div({display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"}),Fne=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:`${PC} 0.3s ease-out`})),i4=Ni`
78
+ `;var wre=en.div({display:"flex",alignItems:"center",gap:"6px",flexWrap:"wrap"}),gh=en.div({display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"}),vre=en.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.6}px`,padding:`${e.layoutMargin*.4}px ${e.layoutMargin}px`,borderRadius:e.appBorderRadius,backgroundColor:e.background.hoverable||"#f3f4f6",border:`1px solid ${e.appBorderColor}`,fontSize:e.typography.size.s1,fontWeight:e.typography.weight.regular,color:e.textMutedColor,animation:`${jC} 0.3s ease-out`})),O4=Hi`
79
79
  from { transform: rotate(0deg); }
80
80
  to { transform: rotate(360deg); }
81
- `,Ene=jt.div(({theme:e})=>({width:"12px",height:"12px",borderRadius:"50%",border:"2px solid transparent",borderTopColor:e.textMutedColor,animation:`${i4} 0.8s linear infinite`,flexShrink:0})),EC=jt.span({display:"inline-flex",alignItems:"center",gap:"6px",padding:"4px 12px",borderRadius:"16px",backgroundColor:"#fee2e2",fontSize:"12px",fontWeight:700,color:"#dc2626",whiteSpace:"nowrap"}),s4=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"}),Ane=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:`${o4} 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"})),AC=jt.span(({color:e="#6b7280"})=>({fontSize:"12px",color:e})),na=jt.span(({color:e})=>({fontWeight:700,color:e})),a4=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}})),Pne=jt.span(({theme:e})=>({color:e.color.mediumlight,fontSize:"12px"})),Lne=jt.span(({color:e=le})=>({display:"inline-block",fontSize:"12px",color:e,animation:`${t4} 1.2s ease-in-out infinite`,marginRight:"4px"})),Mne=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:`${r4} 1.5s ease-in-out infinite`}:{}})),Bne=jt.span(({theme:e})=>({fontSize:"12px",fontWeight:400,color:e.color.mediumdark})),Dne=jt.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark,fontWeight:400})),l4=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"}})),c4=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)"}}}),u4=jt.span({display:"inline-flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",animation:`${n4} 1.2s linear infinite`,flexShrink:0}),p4=({color:e=le})=>ke.createElement(u4,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})}))),Rne=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:`${PC} 0.3s ease-out`}));function d4(e){let[t,n]=Z$(0);return e4(()=>{if(!e){n(0);return}let r=setInterval(()=>{n(o=>o+1)},1e3);return()=>clearInterval(r)},[e]),t}var LC=({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=d4(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(),P=g=>g>=80?"score-high":g>=50?"score-medium":"score-low",M=g=>g>=80?"high":g>=50?"medium":"low";if(e)return ke.createElement(oh,null,ke.createElement("span",{style:{fontSize:"12px",color:"#9ca3af"}},d,"s \xB7 Esc to stop"));if(t)return ke.createElement(oh,null,ke.createElement(EC,null,ke.createElement("span",null,"\u2298"),r," issue",r!==1?"s":""),ke.createElement(zi,null,"|"),ke.createElement(ta,null,ke.createElement(p4,{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(oh,null,r===0?ke.createElement(s4,null,ke.createElement("span",null,"\u2713"),"Perfect!"):ke.createElement(EC,null,ke.createElement("span",null,"\u2298"),r," issue",r!==1?"s":""),ke.createElement(a4,{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(AC,{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(AC,{color:"#6b7280"},"\u23F1"),ke.createElement(na,{color:"#6b7280"},f,"s"))),ke.createElement(zi,null,"|"),ke.createElement(l4,{onClick:m,disabled:w,isExporting:w,title:"Download design review report as PDF"},w?ke.createElement(ke.Fragment,null,ke.createElement(c4,null),"Exporting..."):ke.createElement(ke.Fragment,null,"\u2193 Report")))}return null};var x4=Cn.div({display:"flex",flexDirection:"column",gap:"12px",marginBottom:"16px"}),Wne=Cn.div({display:"flex",gap:"8px",alignItems:"center"}),y4=h4({from:{transform:"rotate(0deg)"},to:{transform:"rotate(360deg)"}}),b4=Cn.span({display:"inline-block",width:"16px",height:"16px",borderRadius:"50%",border:"2px solid rgba(255, 255, 255, 0.35)",borderTopColor:"#ffffff",animation:`${y4} 0.8s linear infinite`,marginRight:"8px",verticalAlign:"middle"}),S4=Cn.span({display:"inline-flex",alignItems:"center",marginRight:"8px","& svg":{width:"16px",height:"16px"}}),w4=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"})),v4=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)`}}}),k4=Cn.div(({theme:e})=>({marginTop:"8px",fontSize:"12px",color:e.color.warning||"#f59e0b",display:"flex",alignItems:"center",gap:"6px"})),C4=Cn.div({marginLeft:"auto",display:"flex",flexDirection:"column",gap:"4px"}),T4=Cn.label(({theme:e})=>({fontSize:"10px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px"})),I4=Cn(En)({width:"auto",minWidth:"200px"}),F4=Cn.div({display:"flex",gap:"16px",alignItems:"center",marginTop:"4px"}),MC=Cn.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",color:e.color.defaultText,cursor:"pointer",userSelect:"none"})),BC=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})),DC=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)"})),RC=Cn.input({position:"absolute",opacity:0,width:0,height:0}),E4=()=>{let[e,t]=g4(0),n=m4();zC(()=>(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)},ih=()=>{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:P,usePromptCache:M,setUsePromptCache:g,isValidating:x,validationUsage:b,isGenerating:E,isApplying:h,streamingStatus:T,featureFlags:I,userRole:v,roleOverride:A,isReviewing:L}=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,B=N?.visualSimilarity,J=(N?.costUsd||0)+(b?.costUsd||0),Z=(N?.inputTokens||0)+(b?.inputTokens||0),oe=(N?.outputTokens||0)+(b?.outputTokens||0),pe=f4(()=>{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]);zC(()=>{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(x4,null,I.enableModelSelection&&ft.createElement(FC,null),ft.createElement(F4,null,ft.createElement(MC,{title:"Compare text content between Figma design and Storybook component"},ft.createElement(RC,{type:"checkbox",checked:O,onChange:fe=>P(fe.target.checked)}),ft.createElement(BC,{checked:O},ft.createElement(DC,{checked:O})),"Compare text"),I.showCosts&&ft.createElement(MC,{title:"Cache prompt for 5 min to reduce costs on repeat reviews (dev optimization)"},ft.createElement(RC,{type:"checkbox",checked:M,onChange:fe=>g(fe.target.checked)}),ft.createElement(BC,{checked:M},ft.createElement(DC,{checked:M})),"Cache prompt")),ft.createElement(w4,null,ft.createElement(v4,{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(b4,null),"Reviewing",ft.createElement(E4,null)):ft.createElement(ft.Fragment,null,ft.createElement(S4,null,ft.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},ft.createElement("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),ft.createElement("circle",{cx:"12",cy:"12",r:"3"}))),"Review")),L?null:x||N?ft.createElement(LC,{isReviewing:!1,isValidating:x,streamingStatus:T,issueCount:j,score:G,visualSimilarity:B,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(C4,null,ft.createElement(T4,null,"Review History"),ft.createElement(I4,{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(k4,null,'\u26A0\uFE0F Figma mapping required. Use "Map to Figma" button to link this story to a Figma frame before reviewing.'))};import qne,{useState as Yne}from"react";import{styled as NC}from"storybook/theming";var Qne=NC.div(({theme:e})=>({display:"flex",borderBottom:`1px solid ${e.appBorderColor}`,marginBottom:"12px",gap:"4px"})),Jne=NC(io)({padding:"8px 12px",fontSize:"12px"});import tre,{useState as nre}from"react";import{styled as sh}from"storybook/theming";we();Ue();De();pt();var cre=sh.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px",backgroundColor:e.background.app,border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",fontSize:"13px"})),ure=sh(Er)({padding:"6px 12px",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px"}),pre=sh.span(({theme:e})=>({color:e.textMutedColor,fontSize:"12px",flex:1}));import gre from"react";import{styled as A4}from"storybook/theming";var xre=A4.div(({theme:e})=>({border:`2px dashed ${e.appBorderColor}`,borderRadius:"8px",padding:"40px",textAlign:"center",marginBottom:"20px",backgroundColor:e.background.app}));we();import Sre from"react";import{styled as Rr}from"storybook/theming";var kre=Rr.div(({theme:e})=>({marginBottom:"16px",border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",backgroundColor:e.background.content})),Cre=Rr.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",backgroundColor:e.background.app,borderBottom:`1px solid ${e.appBorderColor}`})),Tre=Rr.div({display:"flex",alignItems:"center",gap:"8px",flex:1}),Ire=Rr.div(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),Fre=Rr.div(({theme:e})=>({flex:1,height:"4px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden",marginLeft:"12px"})),Ere=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"})),Are=Rr.span(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontWeight:500,minWidth:"40px",textAlign:"right"})),Pre=Rr.div(({theme:e})=>({padding:"16px",backgroundColor:e.background.app,textAlign:"center"})),Lre=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)"}}})),Mre=Rr.span(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontStyle:"italic"}));we();import Rre,{useState as zre}from"react";import{styled as zr}from"storybook/theming";var _re=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)`}}),$re=zr.div({display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",userSelect:"none"}),Ure=zr.div({display:"flex",alignItems:"center",gap:"8px"}),jre=zr.span({fontSize:"12px",opacity:.7}),Hre=zr.span({fontSize:"13px",fontWeight:500}),Wre=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})),Vre=zr.div({marginTop:"12px",fontSize:"11px"}),Gre=zr.div({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px",marginBottom:"8px"}),qre=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"})),Yre=zr.span({fontSize:"12px"});De();Ue();import Xt from"react";import{styled as Qi}from"storybook/theming";import Tr,{useEffect as hW}from"react";import{styled as ba}from"storybook/theming";we();import ni,{useState as V5}from"react";import{styled as Wi}from"storybook/theming";var OC={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 _C(e,t){let n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}var P4=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,L4=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,M4={};function sc(e,t){return((t||M4).jsx?L4:P4).test(e)}var B4=/[ \t\n\f\r]/g;function ah(e){return typeof e=="object"?e.type==="text"?$C(e.value):!1:$C(e)}function $C(e){return e.replace(B4,"")===""}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 lh(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 D4=0,He=Ko(),Nt=Ko(),ac=Ko(),Y=Ko(),St=Ko(),To=Ko(),_n=Ko();function Ko(){return 2**++D4}var ch=Object.keys(oa),Xo=class extends sn{constructor(t,n,r,o){let i=-1;if(super(t,n),UC(this,"space",o),typeof r=="number")for(;++i<ch.length;){let s=ch[i];UC(this,ch[i],(r&oa[s])===oa[s])}}};Xo.prototype.defined=!0;function UC(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 uh=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 jC=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 HC=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 ph=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 dh=ur({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:cc});var fh=ur({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}});var gh={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 R4=/[A-Z]/g,WC=/-[a-z]/g,z4=/^data[-\w.:]+$/i;function mh(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"&&z4.test(t)){if(t.charAt(4)==="-"){let i=t.slice(5).replace(WC,O4);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{let i=t.slice(4);if(!WC.test(i)){let s=i.replace(R4,N4);s.charAt(0)!=="-"&&(s="-"+s),t="data"+s}}o=Xo}return new o(r,t)}function N4(e){return"-"+e.toLowerCase()}function O4(e){return e.charAt(1).toUpperCase()}var VC=lh([uh,jC,ph,dh,fh],"html"),uc=lh([uh,HC,ph,dh,fh],"svg");function GC(e){return e.join(" ").trim()}var a1=La(r1(),1);var dc=o1("end"),Oi=o1("start");function o1(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 yh(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?i1(e.position):"start"in e||"end"in e?i1(e):"line"in e||"column"in e?bh(e):""}function bh(e){return s1(e&&e.line)+":"+s1(e&&e.column)}function i1(e){return bh(e&&e.start)+"-"+bh(e&&e.end)}function s1(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 Sh={}.hasOwnProperty,uU=new Map,pU=/[A-Z]/g,dU=new Set(["table","tbody","thead","tfoot","tr"]),fU=new Set(["td","th"]),l1="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function wh(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=wU(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=SU(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:VC,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=c1(o,e,void 0);return i&&typeof i!="string"?i:o.create(e,o.Fragment,{children:i||void 0},void 0)}function c1(e,t,n){if(t.type==="element")return gU(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return mU(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return xU(e,t,n);if(t.type==="mdxjsEsm")return hU(e,t);if(t.type==="root")return yU(e,t,n);if(t.type==="text")return bU(e,t)}function gU(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=p1(e,t.tagName,!1),s=vU(e,t),a=kh(e,t);return dU.has(t.tagName)&&(a=a.filter(function(u){return typeof u=="string"?!ah(u):!0})),u1(e,s,i,t),vh(s,a),e.ancestors.pop(),e.schema=r,e.create(t,i,s,n)}function mU(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 hU(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);sa(e,t.position)}function xU(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:p1(e,t.name,!0),s=kU(e,t),a=kh(e,t);return u1(e,s,i,t),vh(s,a),e.ancestors.pop(),e.schema=r,e.create(t,i,s,n)}function yU(e,t,n){let r={};return vh(r,kh(e,t)),e.create(t,e.Fragment,r,n)}function bU(e,t){return t.value}function u1(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function vh(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function SU(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 wU(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 vU(e,t){let n={},r,o;for(o in t.properties)if(o!=="children"&&Sh.call(t.properties,o)){let i=CU(e,o,t.properties[o]);if(i){let[s,a]=i;e.tableCellAlignToStyle&&s==="align"&&typeof a=="string"&&fU.has(t.tagName)?r=a:n[s]=a}}if(r){let i=n.style||(n.style={});i[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function kU(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 kh(e,t){let n=[],r=-1,o=e.passKeys?new Map:uU;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=c1(e,i,s);a!==void 0&&n.push(a)}return n}function CU(e,t,n){let r=mh(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?_C(n):GC(n)),r.property==="style"){let o=typeof n=="object"?n:TU(e,String(n));return e.stylePropertyNameCase==="css"&&(o=IU(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&r.space?gh[r.property]||r.property:r.attribute,n]}}function TU(e,t){try{return(0,a1.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=l1+"#cannot-parse-style-attribute",o}}function p1(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 Sh.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=l1+"#cannot-handle-mdx-estrees-without-createevaluater",n}function IU(e){let t={},n;for(n in e)Sh.call(e,n)&&(t[FU(n)]=e[n]);return t}function FU(e){let t=e.replace(pU,EU);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function EU(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 z5,jsx as N5,jsxs as O5}from"react/jsx-runtime";import{useEffect as spe,useState as ape}from"react";var AU={};function Ch(e,t){let n=t||AU,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,o=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return f1(e,r,o)}function f1(e,t,n){if(PU(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 d1(e.children,t,n)}return Array.isArray(e)?d1(e,t,n):""}function d1(e,t,n){let r=[],o=-1;for(;++o<e.length;)r[o]=f1(e[o],t,n);return r.join("")}function PU(e){return!!(e&&typeof e=="object")}var g1=document.createElement("i");function _i(e){let t="&"+e+";";g1.innerHTML=t;let n=g1.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 m1={}.hasOwnProperty;function h1(e){let t={},n=-1;for(;++n<e.length;)LU(t,e[n]);return t}function LU(e,t){let n;for(n in t){let o=(m1.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],s;if(i)for(s in i){m1.call(o,s)||(o[s]=[]);let a=i[s];MU(o[s],Array.isArray(a)?a:a?[a]:[])}}}function MU(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]/),x1=Fo(/[#-'*+\--9=?A-Z^-~]/);function la(e){return e!==null&&(e<32||e===127)}var ca=Fo(/\d/),y1=Fo(/[\dA-Fa-f]/),b1=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 S1=Fo(/\p{P}|\p{S}/u),w1=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 v1={tokenize:BU};function BU(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 C1={tokenize:DU},k1={tokenize:RU};function DU(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,P;for(;O--;)if(t.events[O][0]==="exit"&&t.events[O][1].type==="chunkFlow"){P=t.events[O][1].end;break}F(r);let M=R;for(;M<t.events.length;)t.events[M][1].end={...P},M++;return dn(t.events,O+1,0,t.events.slice(R)),t.events.length=M,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(k1,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(k1,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 P=o.events.length;for(;P--;)if(o.events[P][1].start.offset<s&&(!o.events[P][1].end||o.events[P][1].end.offset>s))return;let M=t.events.length,g=M,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),P=M;P<t.events.length;)t.events[P][1].end={...b},P++;dn(t.events,g+1,0,t.events.slice(M)),t.events.length=P}}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 RU(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 Th(e){if(e===null||Wt(e)||w1(e))return 1;if(S1(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:zU,tokenize:NU};function zU(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};T1(p,-u),T1(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 NU(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,o=Th(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=Th(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 T1(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var Ih={name:"autolink",tokenize:OU};function OU(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):x1(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:_U};function _U(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:UU},exit:jU,name:"blockQuote",tokenize:$U};function $U(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 UU(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 jU(e){e.exit("blockQuote")}var mc={name:"characterEscape",tokenize:HU};function HU(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 b1(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}var hc={name:"characterReference",tokenize:WU};function WU(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=y1,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 I1={partial:!0,tokenize:GU},xc={concrete:!0,name:"codeFenced",tokenize:VU};function VU(e,t,n){let r=this,o={partial:!0,tokenize:O},i=0,s=0,a;return u;function u(P){return c(P)}function c(P){let M=r.events[r.events.length-1];return i=M&&M[1].type==="linePrefix"?M[2].sliceSerialize(M[1],!0).length:0,a=P,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),l(P)}function l(P){return P===a?(s++,e.consume(P),l):s<3?n(P):(e.exit("codeFencedFenceSequence"),_e(P)?We(e,p,"whitespace")(P):p(P))}function p(P){return P===null||ue(P)?(e.exit("codeFencedFence"),r.interrupt?t(P):e.check(I1,w,R)(P)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(P))}function f(P){return P===null||ue(P)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(P)):_e(P)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),We(e,d,"whitespace")(P)):P===96&&P===a?n(P):(e.consume(P),f)}function d(P){return P===null||ue(P)?p(P):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(P))}function m(P){return P===null||ue(P)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(P)):P===96&&P===a?n(P):(e.consume(P),m)}function w(P){return e.attempt(o,R,k)(P)}function k(P){return e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),F}function F(P){return i>0&&_e(P)?We(e,C,"linePrefix",i+1)(P):C(P)}function C(P){return P===null||ue(P)?e.check(I1,w,R)(P):(e.enter("codeFlowValue"),z(P))}function z(P){return P===null||ue(P)?(e.exit("codeFlowValue"),C(P)):(e.consume(P),z)}function R(P){return e.exit("codeFenced"),t(P)}function O(P,M,g){let x=0;return b;function b(v){return P.enter("lineEnding"),P.consume(v),P.exit("lineEnding"),E}function E(v){return P.enter("codeFencedFence"),_e(v)?We(P,h,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(v):h(v)}function h(v){return v===a?(P.enter("codeFencedFenceSequence"),T(v)):g(v)}function T(v){return v===a?(x++,P.consume(v),T):x>=s?(P.exit("codeFencedFenceSequence"),_e(v)?We(P,I,"whitespace")(v):I(v)):g(v)}function I(v){return v===null||ue(v)?(P.exit("codeFencedFence"),M(v)):g(v)}}}function GU(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:YU},qU={partial:!0,tokenize:KU};function YU(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(qU,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 KU(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 Fh={name:"codeText",previous:QU,resolve:XU,tokenize:JU};function XU(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 QU(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function JU(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,ZU(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 ZU(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 Eh={resolve:t3,tokenize:n3},e3={partial:!0,tokenize:r3};function t3(e){return bc(e),e}function n3(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(e3,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 r3(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 Ah={name:"definition",tokenize:i3},o3={partial:!0,tokenize:s3};function i3(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(o3,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 s3(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 Ph={name:"hardBreakEscape",tokenize:a3};function a3(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 Lh={name:"headingAtx",resolve:l3,tokenize:c3};function l3(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 c3(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 F1=["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"],Mh=["pre","script","style","textarea"];var Bh={concrete:!0,name:"htmlFlow",resolveTo:d3,tokenize:f3},u3={partial:!0,tokenize:m3},p3={partial:!0,tokenize:g3};function d3(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 f3(e,t,n){let r=this,o,i,s,a,u;return c;function c(B){return l(B)}function l(B){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(B),p}function p(B){return B===33?(e.consume(B),f):B===47?(e.consume(B),i=!0,w):B===63?(e.consume(B),o=3,r.interrupt?t:S):Xn(B)?(e.consume(B),s=String.fromCharCode(B),k):n(B)}function f(B){return B===45?(e.consume(B),o=2,d):B===91?(e.consume(B),o=5,a=0,m):Xn(B)?(e.consume(B),o=4,r.interrupt?t:S):n(B)}function d(B){return B===45?(e.consume(B),r.interrupt?t:S):n(B)}function m(B){let J="CDATA[";return B===J.charCodeAt(a++)?(e.consume(B),a===J.length?r.interrupt?t:h:m):n(B)}function w(B){return Xn(B)?(e.consume(B),s=String.fromCharCode(B),k):n(B)}function k(B){if(B===null||B===47||B===62||Wt(B)){let J=B===47,Z=s.toLowerCase();return!J&&!i&&Mh.includes(Z)?(o=1,r.interrupt?t(B):h(B)):F1.includes(s.toLowerCase())?(o=6,J?(e.consume(B),F):r.interrupt?t(B):h(B)):(o=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(B):i?C(B):z(B))}return B===45||an(B)?(e.consume(B),s+=String.fromCharCode(B),k):n(B)}function F(B){return B===62?(e.consume(B),r.interrupt?t:h):n(B)}function C(B){return _e(B)?(e.consume(B),C):b(B)}function z(B){return B===47?(e.consume(B),b):B===58||B===95||Xn(B)?(e.consume(B),R):_e(B)?(e.consume(B),z):b(B)}function R(B){return B===45||B===46||B===58||B===95||an(B)?(e.consume(B),R):O(B)}function O(B){return B===61?(e.consume(B),P):_e(B)?(e.consume(B),O):z(B)}function P(B){return B===null||B===60||B===61||B===62||B===96?n(B):B===34||B===39?(e.consume(B),u=B,M):_e(B)?(e.consume(B),P):g(B)}function M(B){return B===u?(e.consume(B),u=null,x):B===null||ue(B)?n(B):(e.consume(B),M)}function g(B){return B===null||B===34||B===39||B===47||B===60||B===61||B===62||B===96||Wt(B)?O(B):(e.consume(B),g)}function x(B){return B===47||B===62||_e(B)?z(B):n(B)}function b(B){return B===62?(e.consume(B),E):n(B)}function E(B){return B===null||ue(B)?h(B):_e(B)?(e.consume(B),E):n(B)}function h(B){return B===45&&o===2?(e.consume(B),A):B===60&&o===1?(e.consume(B),L):B===62&&o===4?(e.consume(B),j):B===63&&o===3?(e.consume(B),S):B===93&&o===5?(e.consume(B),N):ue(B)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(u3,G,T)(B)):B===null||ue(B)?(e.exit("htmlFlowData"),T(B)):(e.consume(B),h)}function T(B){return e.check(p3,I,G)(B)}function I(B){return e.enter("lineEnding"),e.consume(B),e.exit("lineEnding"),v}function v(B){return B===null||ue(B)?T(B):(e.enter("htmlFlowData"),h(B))}function A(B){return B===45?(e.consume(B),S):h(B)}function L(B){return B===47?(e.consume(B),s="",D):h(B)}function D(B){if(B===62){let J=s.toLowerCase();return Mh.includes(J)?(e.consume(B),j):h(B)}return Xn(B)&&s.length<8?(e.consume(B),s+=String.fromCharCode(B),D):h(B)}function N(B){return B===93?(e.consume(B),S):h(B)}function S(B){return B===62?(e.consume(B),j):B===45&&o===2?(e.consume(B),S):h(B)}function j(B){return B===null||ue(B)?(e.exit("htmlFlowData"),G(B)):(e.consume(B),j)}function G(B){return e.exit("htmlFlow"),t(B)}}function g3(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 m3(e,t,n){return r;function r(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(Eo,t,n)}}var Dh={name:"htmlText",tokenize:h3};function h3(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,L(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,L(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,L(S)):(e.consume(S),C)}function z(S){return S===null?n(S):S===63?(e.consume(S),R):ue(S)?(s=z,L(S)):(e.consume(S),z)}function R(S){return S===62?A(S):z(S)}function O(S){return Xn(S)?(e.consume(S),P):n(S)}function P(S){return S===45||an(S)?(e.consume(S),P):M(S)}function M(S){return ue(S)?(s=M,L(S)):_e(S)?(e.consume(S),M):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,L(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,L(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,L(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,L(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 L(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:S3,resolveTo:w3,tokenize:v3},x3={tokenize:k3},y3={tokenize:C3},b3={tokenize:T3};function S3(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 w3(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 v3(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(x3,l,s?l:p)(f):f===91?e.attempt(y3,l,s?c:p)(f):s?l(f):p(f)}function c(f){return e.attempt(b3,l,p)(f)}function l(f){return t(f)}function p(f){return i._balanced=!0,n(f)}}function k3(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 C3(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 T3(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 Rh={name:"labelStartImage",resolveAll:Zo.resolveAll,tokenize:I3};function I3(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 zh={name:"labelStartLink",resolveAll:Zo.resolveAll,tokenize:F3};function F3(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:E3};function E3(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:A3};function A3(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:B3},exit:R3,name:"list",tokenize:M3},P3={partial:!0,tokenize:z3},L3={partial:!0,tokenize:D3};function M3(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(P3,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 B3(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(L3,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 D3(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 R3(e){e.exit(this.containerState.type)}function z3(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:N3,tokenize:O3};function N3(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 O3(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 E1={tokenize:_3};function _3(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(Eh,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 A1={resolveAll:B1()},P1=M1("string"),L1=M1("text");function M1(e){return{resolveAll:B1(e==="text"?$3: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 B1(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 $3(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 Nh={};xe(Nh,{attentionMarkers:()=>Y3,contentInitial:()=>j3,disable:()=>K3,document:()=>U3,flow:()=>W3,flowInitial:()=>H3,insideSpan:()=>q3,string:()=>V3,text:()=>G3});var U3={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},j3={91:Ah},H3={[-2]:pa,[-1]:pa,32:pa},W3={35:Lh,42:ei,45:[kc,ei],60:Bh,61:kc,95:ei,96:xc,126:xc},V3={38:hc,92:mc},G3={[-5]:fa,[-4]:fa,[-3]:fa,33:Rh,38:hc,42:ua,60:[Ih,Dh],91:zh,92:[Ph,mc],93:Zo,95:ua,96:Fh},q3={null:[ua,A1]},Y3={null:[42,95]},K3={null:[]};function D1(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(M),check:x(g),consume:R,enter:O,exit:P,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 Q3(w(T),I)}function w(T){return X3(s,T)}function k(){let{_bufferIndex:T,_index:I,line:v,column:A,offset:L}=r;return{_bufferIndex:T,_index:I,line:v,column:A,offset:L}}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 P(T){let I=a.pop();return I.end=k(),l.events.push(["exit",I,l]),I}function M(T,I){b(T,I.from)}function g(T,I){I.restore()}function x(T,I){return v;function v(A,L,D){let N,S,j,G;return Array.isArray(A)?J(A):"tokenize"in A?J([A]):B(A);function B(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),L}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,L=Array.from(a);return{from:A,restore:D};function D(){r=T,l.previous=I,l.currentConstruct=v,l.events.length=A,a=L,h()}}function h(){r.line in o&&r.column<2&&(r.column=o[r.line],r.offset+=o[r.line]-1)}}function X3(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 Q3(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
+ `,kre=en.div(({theme:e})=>({width:"12px",height:"12px",borderRadius:"50%",border:"2px solid transparent",borderTopColor:e.textMutedColor,animation:`${O4} 0.8s linear infinite`,flexShrink:0})),$C=en.span(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:`${e.layoutMargin*.5}px`,padding:`${e.layoutMargin*.3}px ${e.layoutMargin*.9}px`,borderRadius:e.appBorderRadius*2,backgroundColor:e.base==="dark"?"rgba(220, 38, 38, 0.18)":"#fee2e2",fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:e.color.negative||"#dc2626",whiteSpace:"nowrap"})),_4=en.span(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:`${e.layoutMargin*.5}px`,padding:`${e.layoutMargin*.3}px ${e.layoutMargin*.9}px`,borderRadius:e.appBorderRadius*2,backgroundColor:e.base==="dark"?"rgba(22, 163, 74, 0.18)":"#dcfce7",fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:e.color.positive||"#16a34a",whiteSpace:"nowrap",position:"relative",overflow:"visible"})),Cre=en.span(({delay:e,left:t,color:n,size:r})=>({position:"absolute",top:"-10px",left:`${t}%`,width:`${r}px`,height:`${r}px`,backgroundColor:n,borderRadius:r>6?"50%":"2px",animation:`${N4} 2.5s ease-out ${e}s forwards`,pointerEvents:"none",zIndex:1e3}));var aa=en.span(({theme:e})=>({color:e.color.mediumlight,fontSize:"14px",fontWeight:300})),la=en.span(({theme:e,color:t})=>({display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"12px",fontWeight:500,color:t??e.color.mediumdark,whiteSpace:"nowrap"})),UC=en.span(({theme:e,color:t})=>({fontSize:"12px",color:t??e.color.mediumdark})),ca=en.span(({color:e})=>({fontWeight:700,color:e})),$4=en.div(({tint:e,theme:t})=>({display:"inline-flex",alignItems:"center",gap:`${t.layoutMargin*.6}px`,padding:`${t.layoutMargin*.3}px ${t.layoutMargin}px`,borderRadius:t.appBorderRadius*2,backgroundColor:`${e}1a`,border:`1px solid ${e}33`,"& .score-label":{fontSize:t.typography.size.s1,color:t.textMutedColor},"& .score-value":{fontFamily:t.typography.fonts.mono,fontSize:t.typography.size.s2,fontWeight:t.typography.weight.bold,color:e,lineHeight:1},"& .score-dot":{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:e}})),Tre=en.span(({theme:e})=>({color:e.color.mediumlight,fontSize:"12px"})),Ire=en.span(({color:e=ae})=>({display:"inline-block",fontSize:"12px",color:e,animation:`${D4} 1.2s ease-in-out infinite`,marginRight:"4px"})),Fre=en.span(({theme:e,variant:t="muted"})=>({fontSize:"12px",fontWeight:700,color:(()=>{switch(t){case"issues":return ae;case"score-high":return"#16a34a";case"score-medium":return"#ca8a04";case"score-low":return"#dc2626";case"cost":return"#7c3aed";case"tokens":return e.color.mediumdark;case"analyzing":return ae;case"verifying":return"#7c3aed";default:return e.color.mediumdark}})(),whiteSpace:"nowrap",...t==="analyzing"||t==="verifying"?{animation:`${z4} 1.5s ease-in-out infinite`}:{}})),Ere=en.span(({theme:e})=>({fontSize:"12px",fontWeight:400,color:e.color.mediumdark})),Are=en.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark,fontWeight:400})),U4=en.span({display:"inline-flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",animation:`${R4} 1.2s linear infinite`,flexShrink:0}),j4=({color:e=ae})=>Re.createElement(U4,null,Re.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 Re.createElement("line",{key:n,x1:i,y1:s,x2:a,y2:u,stroke:e,strokeWidth:2,strokeLinecap:"round",opacity:.3+n/8*.7})}))),Pre=en.span(({color:e="#6b7280"})=>({fontSize:"12px",fontWeight:500,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',color:e,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",animation:`${jC} 0.3s ease-out`}));function H4(e){let[t,n]=M4(0);return B4(()=>{if(!e){n(0);return}let r=setInterval(()=>{n(o=>o+1)},1e3);return()=>clearInterval(r)},[e]),t}var HC=({isReviewing:e,isValidating:t,streamingStatus:n,issueCount:r=0,score:o,visualSimilarity:i,costUsd:s,inputTokens:a,outputTokens:u,showTimer:c=!0,cacheCreationTokens:l,cacheReadTokens:p,durationSeconds:g})=>{let d=H4(e||t),{featureFlags:m}=ce(),C=m.showCosts,T=3.65,E=P=>P<.01?`$${P.toFixed(4)}`:P<.1?`$${P.toFixed(3)}`:`$${P.toFixed(2)}`,I=P=>{let z=P*T;return z<.01?`\u20AA${z.toFixed(4)}`:z<.1?`\u20AA${z.toFixed(3)}`:`\u20AA${z.toFixed(2)}`},D=P=>P>=1e3?`${(P/1e3).toFixed(1)}K`:P.toString(),R=P=>P>=80?"score-high":P>=50?"score-medium":"score-low",_=P=>P>=80?"high":P>=50?"medium":"low";if(e)return Re.createElement(gh,null,Re.createElement("span",{style:{fontSize:"12px",color:"#9ca3af"}},d,"s \xB7 Esc to stop"));if(t)return Re.createElement(gh,null,Re.createElement($C,null,Re.createElement("span",null,"\u2298"),r," issue",r!==1?"s":""),Re.createElement(aa,null,"|"),Re.createElement(la,null,Re.createElement(j4,{color:"#7c3aed"}),Re.createElement(ca,{color:"#7c3aed"},"Verifying...")),c&&Re.createElement(Re.Fragment,null,Re.createElement(aa,null,"|"),Re.createElement(la,null,Re.createElement("span",{style:{color:"#6b7280"}},d,"s"))));if(r>0||o!==void 0){let P=(a||0)+(u||0),z=(p||0)>0,x=z&&a?Math.round(p/a*100):0,w=Math.max(o??0,i??0),v=f=>f>=80?"#16a34a":f>=50?"#ca8a04":"#dc2626",k=f=>f>=100?"\u25CF":f>=50?"\u25D0":"\u25CB";return Re.createElement(gh,null,r===0?Re.createElement(_4,null,Re.createElement("span",null,"\u2713"),"Perfect!"):Re.createElement($C,null,Re.createElement("span",null,"\u2298"),r," issue",r!==1?"s":""),Re.createElement($4,{tint:v(w),title:`MQM compliance: ${o??0}% | Visual similarity: ${i??0}%`},Re.createElement("span",{className:"score-dot"}),Re.createElement("span",{className:"score-label"},"Score"),Re.createElement("span",{className:"score-value"},w)),C&&s!==void 0&&s>0&&Re.createElement(Re.Fragment,null,Re.createElement(aa,null,"|"),Re.createElement(la,null,Re.createElement(ca,{color:"#16a34a"},E(s)),Re.createElement("span",{style:{color:"#6b7280"}},"/"),Re.createElement(ca,{color:"#16a34a"},I(s)))),C&&P>0&&Re.createElement(Re.Fragment,null,Re.createElement(aa,null,"|"),Re.createElement(la,{title:`Input: ${a?.toLocaleString()||0} \xB7 Output: ${u?.toLocaleString()||0}${z?` \xB7 Cached: ${p?.toLocaleString()}`:""}`},Re.createElement(UC,{color:"#7c3aed"},"#"),Re.createElement(ca,{color:"#7c3aed"},D(P)),Re.createElement("span",{style:{color:"#6b7280"}},"tokens"),z&&Re.createElement("span",{style:{color:"#16a34a",marginLeft:"4px"}},"\u26A1",x,"%"))),g!==void 0&&g>0&&Re.createElement(Re.Fragment,null,Re.createElement(aa,null,"|"),Re.createElement(la,null,Re.createElement(UC,{color:"#6b7280"},"\u23F1"),Re.createElement(ca,{color:"#6b7280"},g,"s"))))}return null};var Y4=$n.div({display:"flex",flexDirection:"column",gap:"12px",marginBottom:"16px"}),_re=$n.div({display:"flex",gap:"8px",alignItems:"center"}),K4=q4({from:{transform:"rotate(0deg)"},to:{transform:"rotate(360deg)"}}),X4=$n.span({display:"inline-block",width:"16px",height:"16px",borderRadius:"50%",border:"2px solid rgba(255, 255, 255, 0.35)",borderTopColor:"#ffffff",animation:`${K4} 0.8s linear infinite`,marginRight:"8px",verticalAlign:"middle"}),Q4=$n.span({display:"inline-flex",alignItems:"center",marginRight:"8px","& svg":{width:"16px",height:"16px"}}),J4=$n.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin}px`,padding:`${e.layoutMargin*.8}px ${e.layoutMargin*1.2}px`,borderRadius:e.appBorderRadius*2,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content,boxShadow:"0 1px 2px rgba(0, 0, 0, 0.03)",flexWrap:"wrap"})),Z4=$n.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:_a},o=t==="purple"||t==="yellow"?"124, 58, 237":"255, 107, 53";return{width:"auto",backgroundColor:r[t],color:e.color.inverseText,border:"none",padding:`${e.layoutMargin*.7}px ${e.layoutMargin*1.4}px`,fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,borderRadius:e.appBorderRadius,cursor:n?"not-allowed":"pointer",opacity:n?.6:1,whiteSpace:"nowrap",transition:"all 0.2s",boxShadow:n?"none":`0 2px 6px rgba(${o}, 0.3)`,flexShrink:0,"&:hover":{opacity:n?.6:.9,transform:n?"none":"translateY(-1px)",boxShadow:n?"none":`0 4px 10px rgba(${o}, 0.4)`}}}),eU=$n.div(({theme:e})=>({marginTop:"8px",fontSize:"12px",color:e.color.warning||"#f59e0b",display:"flex",alignItems:"center",gap:"6px"})),tU=$n.div({marginLeft:"auto",display:"flex",flexDirection:"row",alignItems:"center",gap:"8px",minWidth:0}),nU=$n(mn)({width:"auto",minWidth:"180px",maxWidth:"260px"}),rU=$n.div({display:"flex",gap:"16px",alignItems:"center",marginTop:"4px"}),WC=$n.label(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",color:e.color.defaultText,cursor:"pointer",userSelect:"none"})),VC=$n.div(({theme:e,checked:t})=>({width:"32px",height:"18px",borderRadius:"9px",backgroundColor:t?_a:e.appBorderColor||"#d1d5db",position:"relative",transition:"background-color 0.2s ease",flexShrink:0})),GC=$n.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)"})),qC=$n.input({position:"absolute",opacity:0,width:0,height:0}),oU=()=>{let[e,t]=V4(0),n=G4();YC(()=>(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 gt.createElement("span",{style:{fontFamily:"ui-monospace, monospace",fontSize:"12px",opacity:.8,fontVariantNumeric:"tabular-nums"}},i)},fh=()=>{let{sessionToken:e}=Os(),{usageData:t}=we(),{selectedProjectId:n}=Zr(),{currentMapping:r,hasMapping:o}=Zo(),{loadingMapping:i,currentStoryId:s}=nt(),{startReview:a,cancelReview:u,isReviewing:c}=cm(),{isLoadingScreenshots:l}=Qo(),{storybookImageUrl:p,figmaImageUrl:g,currentReviewId:d,reviewHistory:m,setReviewDetailTab:C,setReviewResults:T,setFigmaImageUrl:E,setStorybookImageUrl:I,setFullPrompt:D,setFullResponse:R,includeTextComparison:_,setIncludeTextComparison:P,usePromptCache:z,setUsePromptCache:x,isValidating:w,validationUsage:v,isGenerating:k,isApplying:f,streamingStatus:F,featureFlags:S,userRole:b,roleOverride:A,isReviewing:L}=ce(),B=t?.reviewCredits??Math.floor(t?.creditBalance??0),N=m.find(ge=>ge.id===d),j=(N?.issues||[]).filter(ge=>!ge.dismissed).length,H=N?.complianceScore,M=N?.visualSimilarity,X=(N?.costUsd||0)+(v?.costUsd||0),Z=(N?.inputTokens||0)+(v?.inputTokens||0),me=(N?.outputTokens||0)+(v?.outputTokens||0),xe=W4(()=>{let ge=s?m.filter(fe=>fe.storyId===s):m,tt=ge.filter(fe=>!fe.parentReviewId).sort((fe,se)=>new Date(se.createdAt).getTime()-new Date(fe.createdAt).getTime()),he=ge.filter(fe=>fe.parentReviewId),ie=[];for(let fe of tt){ie.push(fe);let se=he.filter(O=>O.parentReviewId===fe.id).sort((O,U)=>(O.iterationNumber||0)-(U.iterationNumber||0));ie.push(...se)}let Y=he.filter(fe=>!tt.some(se=>se.id===fe.parentReviewId));return ie.push(...Y),ie},[m,s]);YC(()=>{if(!c)return;let ge=tt=>{tt.key==="Escape"&&(tt.preventDefault(),u())};return window.addEventListener("keydown",ge),()=>window.removeEventListener("keydown",ge)},[c,u]);let oe=o&&r?.figmaNodeId,Ye=k||f,be=B>0,Ce=!!(e&&n&&!c&&!l&&!Ye&&s&&p&&oe&&g&&be),te=async(ge=!1)=>{if(!s){console.error("[ReviewActions] No story selected");return}try{C("chat"),await a({isIteration:ge,parentReviewId:ge?d:void 0})}catch(tt){console.error("[ReviewActions] Review error:",tt)}},Le=()=>te(!1),Ee=ge=>{let tt=ge.target.value;if(tt){let he=m.find(ie=>ie.id===tt);he&&(T({id:he.id,componentId:he.componentId,storyId:he.storyId,modelId:he.modelId,complianceScore:he.complianceScore,issuesCount:he.issuesCount,issues:he.issues,createdAt:new Date(he.createdAt),visualSimilarity:he.visualSimilarity,timestamp:new Date(he.createdAt).toISOString(),costUsd:he.costUsd,inputTokens:he.inputTokens,outputTokens:he.outputTokens,cacheCreationTokens:he.cacheCreationTokens,cacheReadTokens:he.cacheReadTokens,reviewDurationMs:he.reviewDurationMs}),he.figmaImageData&&E(he.figmaImageData),he.storybookImageData&&I(he.storybookImageData),(A??b)==="admin"&&(D(he.aiPrompt||""),R(he.aiResponse||"")),C("issues"))}},pe=ge=>{let tt=new Date(ge),ie=new Date().getTime()-tt.getTime(),Y=Math.floor(ie/6e4),fe=Math.floor(ie/36e5),se=Math.floor(ie/864e5);return Y<1?"Just now":Y<60?`${Y}m ago`:fe<24?`${fe}h ago`:se<7?`${se}d ago`:tt.toLocaleDateString()},At=ge=>ge?ge.includes("haiku")?"Haiku":ge.includes("sonnet")?"Sonnet":ge.includes("opus")?"Opus":ge.includes("gpt-4o-mini")?"GPT-4o mini":ge.includes("gpt-4o")?"GPT-4o":ge.includes("gpt-4")?"GPT-4":ge.includes("o3")?"o3":ge.includes("o1")?"o1":ge.split("-")[0]||"":"",tn=ge=>{let tt=ge.split("--"),he=tt[tt.length-1]||ge;return he.charAt(0).toUpperCase()+he.slice(1)},Pr=(A??b)==="admin";return gt.createElement("div",null,gt.createElement(Y4,null,S.enableModelSelection&&gt.createElement(_C,null),Pr&&gt.createElement(rU,null,gt.createElement(WC,{title:"Compare text content between Figma design and Storybook component"},gt.createElement(qC,{type:"checkbox",checked:_,onChange:ge=>P(ge.target.checked)}),gt.createElement(VC,{checked:_},gt.createElement(GC,{checked:_})),"Compare text"),S.showCosts&&gt.createElement(WC,{title:"Cache prompt for 5 min to reduce costs on repeat reviews (dev optimization)"},gt.createElement(qC,{type:"checkbox",checked:z,onChange:ge=>x(ge.target.checked)}),gt.createElement(VC,{checked:z},gt.createElement(GC,{checked:z})),"Cache prompt")),gt.createElement(J4,null,gt.createElement(Z4,{variant:c?"yellow":"purple",disabled:c?!1:!Ce,onClick:c?u:Le,title:c?"Click to stop review":e?n?s?oe?l?"Loading screenshots...":Ye?"Wait for fixes to complete...":p?g?be?"Review this component implementation":"No credits available":"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 Parity first"},c?gt.createElement(gt.Fragment,null,gt.createElement(X4,null),"Reviewing",gt.createElement(oU,null)):gt.createElement(gt.Fragment,null,gt.createElement(Q4,null,gt.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},gt.createElement("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),gt.createElement("circle",{cx:"12",cy:"12",r:"3"}))),"Review")),L?null:w||N?gt.createElement(HC,{isReviewing:!1,isValidating:w,streamingStatus:F,issueCount:j,score:H,visualSimilarity:M,costUsd:X||N?.costUsd,inputTokens:Z||N?.inputTokens,outputTokens:me||N?.outputTokens,cacheCreationTokens:N?.cacheCreationTokens,cacheReadTokens:N?.cacheReadTokens,durationSeconds:N?.reviewDurationMs?Math.round(N.reviewDurationMs/1e3):void 0}):null,xe.length>0&&gt.createElement(tU,null,gt.createElement(nU,{value:d||"",onChange:Ee,title:"Review history"},gt.createElement("option",{value:""},"Select a review..."),xe.map(ge=>{let tt=!!ge.parentReviewId,he=tt?" \u21B3 ":"\u25CF ",ie=tt&&ge.iterationNumber?`Iter ${ge.iterationNumber} - `:"",Y=ge.issuesCount??ge.issues?.length??0,fe=ge.complianceScore??"--",se=At(ge.modelId);return gt.createElement("option",{key:ge.id,value:ge.id},he,ie,pe(ge.createdAt)," - ",Y," issues (",fe,"%)",se?` \xB7 ${se}`:"",ge.storyId?` \xB7 ${tn(ge.storyId)}`:"")}))))),!oe&&!i&&gt.createElement(eU,null,'\u26A0\uFE0F Figma mapping required. Use "Map to Figma" button to link this story to a Figma frame before reviewing.'))};import jre,{useState as Hre}from"react";import{styled as KC}from"storybook/theming";var Gre=KC.div(({theme:e})=>({display:"flex",borderBottom:`1px solid ${e.appBorderColor}`,marginBottom:"12px",gap:"4px"})),qre=KC(mo)({padding:"8px 12px",fontSize:"12px"});import Xre,{useState as Qre}from"react";import{styled as mh}from"storybook/theming";ke();je();Ne();lt();var ooe=mh.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"12px",backgroundColor:e.background.app,border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",fontSize:"13px"})),ioe=mh(Br)({padding:"6px 12px",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px"}),soe=mh.span(({theme:e})=>({color:e.textMutedColor,fontSize:"12px",flex:1}));import coe from"react";import{styled as iU}from"storybook/theming";var doe=iU.div(({theme:e})=>({border:`2px dashed ${e.appBorderColor}`,borderRadius:"8px",padding:"40px",textAlign:"center",marginBottom:"20px",backgroundColor:e.background.app}));ke();import moe from"react";import{styled as $r}from"storybook/theming";var yoe=$r.div(({theme:e})=>({marginBottom:"16px",border:`1px solid ${e.appBorderColor}`,borderRadius:"8px",overflow:"hidden",backgroundColor:e.background.content})),boe=$r.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",backgroundColor:e.background.app,borderBottom:`1px solid ${e.appBorderColor}`})),Soe=$r.div({display:"flex",alignItems:"center",gap:"8px",flex:1}),woe=$r.div(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),voe=$r.div(({theme:e})=>({flex:1,height:"4px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden",marginLeft:"12px"})),koe=$r.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"})),Coe=$r.span(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontWeight:500,minWidth:"40px",textAlign:"right"})),Toe=$r.div(({theme:e})=>({padding:"16px",backgroundColor:e.background.app,textAlign:"center"})),Ioe=$r.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)"}}})),Foe=$r.span(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontStyle:"italic"}));ke();import Poe,{useState as Loe}from"react";import{styled as Ur}from"storybook/theming";var Doe=Ur.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)`}}),Roe=Ur.div({display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",userSelect:"none"}),zoe=Ur.div({display:"flex",alignItems:"center",gap:"8px"}),Noe=Ur.span({fontSize:"12px",opacity:.7}),Ooe=Ur.span({fontSize:"13px",fontWeight:500}),_oe=Ur.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})),$oe=Ur.div({marginTop:"12px",fontSize:"11px"}),Uoe=Ur.div({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px",marginBottom:"8px"}),joe=Ur.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"})),Hoe=Ur.span({fontSize:"12px"});Ne();je();import Xt from"react";import{styled as rs}from"storybook/theming";import Ar,{useEffect as G8}from"react";import{styled as Ia}from"storybook/theming";ke();import ci,{useState as w6}from"react";import{styled as Xi}from"storybook/theming";var XC={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 QC(e,t){let n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}var sU=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,aU=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,lU={};function fc(e,t){return((t||lU).jsx?aU:sU).test(e)}var cU=/[ \t\n\f\r]/g;function hh(e){return typeof e=="object"?e.type==="text"?JC(e.value):!1:JC(e)}function JC(e){return e.replace(cU,"")===""}var oo=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};oo.prototype.normal={};oo.prototype.property={};oo.prototype.space=void 0;function xh(e,t){let n={},r={};for(let o of e)Object.assign(n,o.property),Object.assign(r,o.normal);return new oo(n,r,t)}function ua(e){return e.toLowerCase()}var ln=class{constructor(t,n){this.attribute=n,this.property=t}};ln.prototype.attribute="";ln.prototype.booleanish=!1;ln.prototype.boolean=!1;ln.prototype.commaOrSpaceSeparated=!1;ln.prototype.commaSeparated=!1;ln.prototype.defined=!1;ln.prototype.mustUseProperty=!1;ln.prototype.number=!1;ln.prototype.overloadedBoolean=!1;ln.prototype.property="";ln.prototype.spaceSeparated=!1;ln.prototype.space=void 0;var pa={};Se(pa,{boolean:()=>Ge,booleanish:()=>Ot,commaOrSpaceSeparated:()=>Un,commaSeparated:()=>Do,number:()=>K,overloadedBoolean:()=>mc,spaceSeparated:()=>St});var uU=0,Ge=ni(),Ot=ni(),mc=ni(),K=ni(),St=ni(),Do=ni(),Un=ni();function ni(){return 2**++uU}var yh=Object.keys(pa),ri=class extends ln{constructor(t,n,r,o){let i=-1;if(super(t,n),ZC(this,"space",o),typeof r=="number")for(;++i<yh.length;){let s=yh[i];ZC(this,yh[i],(r&pa[s])===pa[s])}}};ri.prototype.defined=!0;function ZC(e,t,n){n&&(e[t]=n)}function dr(e){let t={},n={};for(let[r,o]of Object.entries(e.properties)){let i=new ri(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[ua(r)]=r,n[ua(i.attribute)]=r}return new oo(t,n,e.space)}var bh=dr({properties:{ariaActiveDescendant:null,ariaAtomic:Ot,ariaAutoComplete:null,ariaBusy:Ot,ariaChecked:Ot,ariaColCount:K,ariaColIndex:K,ariaColSpan:K,ariaControls:St,ariaCurrent:null,ariaDescribedBy:St,ariaDetails:null,ariaDisabled:Ot,ariaDropEffect:St,ariaErrorMessage:null,ariaExpanded:Ot,ariaFlowTo:St,ariaGrabbed:Ot,ariaHasPopup:null,ariaHidden:Ot,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:St,ariaLevel:K,ariaLive:null,ariaModal:Ot,ariaMultiLine:Ot,ariaMultiSelectable:Ot,ariaOrientation:null,ariaOwns:St,ariaPlaceholder:null,ariaPosInSet:K,ariaPressed:Ot,ariaReadOnly:Ot,ariaRelevant:null,ariaRequired:Ot,ariaRoleDescription:St,ariaRowCount:K,ariaRowIndex:K,ariaRowSpan:K,ariaSelected:Ot,ariaSetSize:K,ariaSort:null,ariaValueMax:K,ariaValueMin:K,ariaValueNow:K,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function hc(e,t){return t in e?e[t]:t}function xc(e,t){return hc(e,t.toLowerCase())}var e1=dr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Do,acceptCharset:St,accessKey:St,action:null,allow:null,allowFullScreen:Ge,allowPaymentRequest:Ge,allowUserMedia:Ge,alt:null,as:null,async:Ge,autoCapitalize:null,autoComplete:St,autoFocus:Ge,autoPlay:Ge,blocking:St,capture:null,charSet:null,checked:Ge,cite:null,className:St,cols:K,colSpan:null,content:null,contentEditable:Ot,controls:Ge,controlsList:St,coords:K|Do,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ge,defer:Ge,dir:null,dirName:null,disabled:Ge,download:mc,draggable:Ot,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ge,formTarget:null,headers:St,height:K,hidden:mc,high:K,href:null,hrefLang:null,htmlFor:St,httpEquiv:St,id:null,imageSizes:null,imageSrcSet:null,inert:Ge,inputMode:null,integrity:null,is:null,isMap:Ge,itemId:null,itemProp:St,itemRef:St,itemScope:Ge,itemType:St,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ge,low:K,manifest:null,max:null,maxLength:K,media:null,method:null,min:null,minLength:K,multiple:Ge,muted:Ge,name:null,nonce:null,noModule:Ge,noValidate:Ge,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Ge,optimum:K,pattern:null,ping:St,placeholder:null,playsInline:Ge,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ge,referrerPolicy:null,rel:St,required:Ge,reversed:Ge,rows:K,rowSpan:K,sandbox:St,scope:null,scoped:Ge,seamless:Ge,selected:Ge,shadowRootClonable:Ge,shadowRootDelegatesFocus:Ge,shadowRootMode:null,shape:null,size:K,sizes:null,slot:null,span:K,spellCheck:Ot,src:null,srcDoc:null,srcLang:null,srcSet:null,start:K,step:null,style:null,tabIndex:K,target:null,title:null,translate:null,type:null,typeMustMatch:Ge,useMap:null,value:Ot,width:K,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:St,axis:null,background:null,bgColor:null,border:K,borderColor:null,bottomMargin:K,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ge,declare:Ge,event:null,face:null,frame:null,frameBorder:null,hSpace:K,leftMargin:K,link:null,longDesc:null,lowSrc:null,marginHeight:K,marginWidth:K,noResize:Ge,noHref:Ge,noShade:Ge,noWrap:Ge,object:null,profile:null,prompt:null,rev:null,rightMargin:K,rules:null,scheme:null,scrolling:Ot,standby:null,summary:null,text:null,topMargin:K,valueType:null,version:null,vAlign:null,vLink:null,vSpace:K,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ge,disableRemotePlayback:Ge,prefix:null,property:null,results:K,security:null,unselectable:null},space:"html",transform:xc});var t1=dr({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:Un,accentHeight:K,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:K,amplitude:K,arabicForm:null,ascent:K,attributeName:null,attributeType:null,azimuth:K,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:K,by:null,calcMode:null,capHeight:K,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:K,diffuseConstant:K,direction:null,display:null,dur:null,divisor:K,dominantBaseline:null,download:Ge,dx:null,dy:null,edgeMode:null,editable:null,elevation:K,enableBackground:null,end:null,event:null,exponent:K,externalResourcesRequired:null,fill:null,fillOpacity:K,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:Do,g2:Do,glyphName:Do,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:K,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:K,horizOriginX:K,horizOriginY:K,id:null,ideographic:K,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:K,k:K,k1:K,k2:K,k3:K,k4:K,kernelMatrix:Un,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:K,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:K,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:K,overlineThickness:K,paintOrder:null,panose1:null,path:null,pathLength:K,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:St,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:K,pointsAtY:K,pointsAtZ:K,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Un,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Un,rev:Un,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Un,requiredFeatures:Un,requiredFonts:Un,requiredFormats:Un,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:K,specularExponent:K,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:K,strikethroughThickness:K,string:null,stroke:null,strokeDashArray:Un,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:K,strokeOpacity:K,strokeWidth:null,style:null,surfaceScale:K,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Un,tabIndex:K,tableValues:null,target:null,targetX:K,targetY:K,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Un,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:K,underlineThickness:K,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:K,values:null,vAlphabetic:K,vMathematical:K,vectorEffect:null,vHanging:K,vIdeographic:K,version:null,vertAdvY:K,vertOriginX:K,vertOriginY:K,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:K,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:hc});var Sh=dr({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 wh=dr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:xc});var vh=dr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}});var kh={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 pU=/[A-Z]/g,n1=/-[a-z]/g,dU=/^data[-\w.:]+$/i;function Ch(e,t){let n=ua(t),r=t,o=ln;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&dU.test(t)){if(t.charAt(4)==="-"){let i=t.slice(5).replace(n1,fU);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{let i=t.slice(4);if(!n1.test(i)){let s=i.replace(pU,gU);s.charAt(0)!=="-"&&(s="-"+s),t="data"+s}}o=ri}return new o(r,t)}function gU(e){return"-"+e.toLowerCase()}function fU(e){return e.charAt(1).toUpperCase()}var r1=xh([bh,e1,Sh,wh,vh],"html"),yc=xh([bh,t1,Sh,wh,vh],"svg");function o1(e){return e.join(" ").trim()}var b1=Oa(m1(),1);var Sc=h1("end"),Wi=h1("start");function h1(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 Fh(e){let t=Wi(e),n=Sc(e);if(t&&n)return{start:t,end:n}}function Ro(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?x1(e.position):"start"in e||"end"in e?x1(e):"line"in e||"column"in e?Eh(e):""}function Eh(e){return y1(e&&e.line)+":"+y1(e&&e.column)}function x1(e){return Eh(e&&e.start)+"-"+Eh(e&&e.end)}function y1(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=Ro(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 Ah={}.hasOwnProperty,$U=new Map,UU=/[A-Z]/g,jU=new Set(["table","tbody","thead","tfoot","tr"]),HU=new Set(["td","th"]),S1="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Ph(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=QU(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=XU(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"?yc:r1,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=w1(o,e,void 0);return i&&typeof i!="string"?i:o.create(e,o.Fragment,{children:i||void 0},void 0)}function w1(e,t,n){if(t.type==="element")return WU(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return VU(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return qU(e,t,n);if(t.type==="mdxjsEsm")return GU(e,t);if(t.type==="root")return YU(e,t,n);if(t.type==="text")return KU(e,t)}function WU(e,t,n){let r=e.schema,o=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(o=yc,e.schema=o),e.ancestors.push(t);let i=k1(e,t.tagName,!1),s=JU(e,t),a=Mh(e,t);return jU.has(t.tagName)&&(a=a.filter(function(u){return typeof u=="string"?!hh(u):!0})),v1(e,s,i,t),Lh(s,a),e.ancestors.pop(),e.schema=r,e.create(t,i,s,n)}function VU(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)}ga(e,t.position)}function GU(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ga(e,t.position)}function qU(e,t,n){let r=e.schema,o=r;t.name==="svg"&&r.space==="html"&&(o=yc,e.schema=o),e.ancestors.push(t);let i=t.name===null?e.Fragment:k1(e,t.name,!0),s=ZU(e,t),a=Mh(e,t);return v1(e,s,i,t),Lh(s,a),e.ancestors.pop(),e.schema=r,e.create(t,i,s,n)}function YU(e,t,n){let r={};return Lh(r,Mh(e,t)),e.create(t,e.Fragment,r,n)}function KU(e,t){return t.value}function v1(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Lh(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function XU(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 QU(e,t){return n;function n(r,o,i,s){let a=Array.isArray(i.children),u=Wi(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 JU(e,t){let n={},r,o;for(o in t.properties)if(o!=="children"&&Ah.call(t.properties,o)){let i=e3(e,o,t.properties[o]);if(i){let[s,a]=i;e.tableCellAlignToStyle&&s==="align"&&typeof a=="string"&&HU.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 ZU(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 ga(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 ga(e,t.position);else i=r.value===null?!0:r.value;n[o]=i}return n}function Mh(e,t){let n=[],r=-1,o=e.passKeys?new Map:$U;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=w1(e,i,s);a!==void 0&&n.push(a)}return n}function e3(e,t,n){let r=Ch(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?QC(n):o1(n)),r.property==="style"){let o=typeof n=="object"?n:t3(e,String(n));return e.stylePropertyNameCase==="css"&&(o=n3(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&r.space?kh[r.property]||r.property:r.attribute,n]}}function t3(e,t){try{return(0,b1.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=S1+"#cannot-parse-style-attribute",o}}function k1(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=fc(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=fc(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){let o=r.value;return Ah.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(r);ga(e)}function ga(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=S1+"#cannot-handle-mdx-estrees-without-createevaluater",n}function n3(e){let t={},n;for(n in e)Ah.call(e,n)&&(t[r3(n)]=e[n]);return t}function r3(e){let t=e.replace(UU,o3);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function o3(e){return"-"+e.toLowerCase()}var fa={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 d6,jsx as g6,jsxs as f6}from"react/jsx-runtime";import{useEffect as tde,useState as nde}from"react";var i3={};function Bh(e,t){let n=t||i3,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,o=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return T1(e,r,o)}function T1(e,t,n){if(s3(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 C1(e.children,t,n)}return Array.isArray(e)?C1(e,t,n):""}function C1(e,t,n){let r=[],o=-1;for(;++o<e.length;)r[o]=T1(e[o],t,n);return r.join("")}function s3(e){return!!(e&&typeof e=="object")}var I1=document.createElement("i");function Vi(e){let t="&"+e+";";I1.innerHTML=t;let n=I1.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function gn(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 In(e,t){return e.length>0?(gn(e,e.length,0,t),e):t}var F1={}.hasOwnProperty;function E1(e){let t={},n=-1;for(;++n<e.length;)a3(t,e[n]);return t}function a3(e,t){let n;for(n in t){let o=(F1.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],s;if(i)for(s in i){F1.call(o,s)||(o[s]=[]);let a=i[s];l3(o[s],Array.isArray(a)?a:a?[a]:[])}}}function l3(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);gn(e,0,0,r)}function wc(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 io(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}var Jn=zo(/[A-Za-z]/),cn=zo(/[\dA-Za-z]/),A1=zo(/[#-'*+\--9=?A-Z^-~]/);function ma(e){return e!==null&&(e<32||e===127)}var ha=zo(/\d/),P1=zo(/[\dA-Fa-f]/),L1=zo(/[!-/:-@[-`{-~]/);function ue(e){return e!==null&&e<-2}function Wt(e){return e!==null&&(e<0||e===32)}function He(e){return e===-2||e===-1||e===32}var M1=zo(/\p{P}|\p{S}/u),B1=zo(/\s/);function zo(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function gr(e){let t=[],n=-1,r=0,o=0;for(;++n<e.length;){let i=e.charCodeAt(n),s="";if(i===37&&cn(e.charCodeAt(n+1))&&cn(e.charCodeAt(n+2)))o=2;else if(i<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(i))||(s=String.fromCharCode(i));else if(i>55295&&i<57344){let a=e.charCodeAt(n+1);i<56320&&a>56319&&a<57344?(s=String.fromCharCode(i,a),o=1):s="\uFFFD"}else s=String.fromCharCode(i);s&&(t.push(e.slice(r,n),encodeURIComponent(s)),r=n+o+1,s=""),o&&(n+=o,o=0)}return t.join("")+e.slice(r)}function qe(e,t,n,r){let o=r?r-1:Number.POSITIVE_INFINITY,i=0;return s;function s(u){return He(u)?(e.enter(n),a(u)):t(u)}function a(u){return He(u)&&i++<o?(e.consume(u),a):(e.exit(n),t(u))}}var D1={tokenize:c3};function c3(e){let t=e.attempt(this.parser.constructs.contentInitial,r,o),n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),qe(e,t,"linePrefix")}function o(a){return e.enter("paragraph"),i(a)}function i(a){let u=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=u),n=u,s(a)}function s(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return ue(a)?(e.consume(a),e.exit("chunkText"),i):(e.consume(a),s)}}var z1={tokenize:u3},R1={tokenize:p3};function u3(e){let t=this,n=[],r=0,o,i,s;return a;function a(D){if(r<n.length){let R=n[r];return t.containerState=R[1],e.attempt(R[0].continuation,u,c)(D)}return c(D)}function u(D){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,o&&I();let R=t.events.length,_=R,P;for(;_--;)if(t.events[_][0]==="exit"&&t.events[_][1].type==="chunkFlow"){P=t.events[_][1].end;break}E(r);let z=R;for(;z<t.events.length;)t.events[z][1].end={...P},z++;return gn(t.events,_+1,0,t.events.slice(R)),t.events.length=z,c(D)}return a(D)}function c(D){if(r===n.length){if(!o)return g(D);if(o.currentConstruct&&o.currentConstruct.concrete)return m(D);t.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(R1,l,p)(D)}function l(D){return o&&I(),E(r),g(D)}function p(D){return t.parser.lazy[t.now().line]=r!==n.length,s=t.now().offset,m(D)}function g(D){return t.containerState={},e.attempt(R1,d,m)(D)}function d(D){return r++,n.push([t.currentConstruct,t.containerState]),g(D)}function m(D){if(D===null){o&&I(),E(0),e.consume(D);return}return o=o||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:i}),C(D)}function C(D){if(D===null){T(e.exit("chunkFlow"),!0),E(0),e.consume(D);return}return ue(D)?(e.consume(D),T(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(D),C)}function T(D,R){let _=t.sliceStream(D);if(R&&_.push(null),D.previous=i,i&&(i.next=D),i=D,o.defineSkip(D.start),o.write(_),t.parser.lazy[D.start.line]){let P=o.events.length;for(;P--;)if(o.events[P][1].start.offset<s&&(!o.events[P][1].end||o.events[P][1].end.offset>s))return;let z=t.events.length,x=z,w,v;for(;x--;)if(t.events[x][0]==="exit"&&t.events[x][1].type==="chunkFlow"){if(w){v=t.events[x][1].end;break}w=!0}for(E(r),P=z;P<t.events.length;)t.events[P][1].end={...v},P++;gn(t.events,x+1,0,t.events.slice(z)),t.events.length=P}}function E(D){let R=n.length;for(;R-- >D;){let _=n[R];t.containerState=_[1],_[0].exit.call(t,e)}n.length=D}function I(){o.write([null]),i=void 0,o=void 0,t.containerState._closeFlow=void 0}}function p3(e,t,n){return qe(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Dh(e){if(e===null||Wt(e)||B1(e))return 1;if(M1(e))return 2}function Gi(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 xa={name:"attention",resolveAll:d3,tokenize:g3};function d3(e,t){let n=-1,r,o,i,s,a,u,c,l;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let p={...e[r][1].end},g={...e[n][1].start};N1(p,-u),N1(g,u),s={type:u>1?"strongSequence":"emphasisSequence",start:p,end:{...e[r][1].end}},a={type:u>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:g},i={type:u>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},o={type:u>1?"strong":"emphasis",start:{...s.start},end:{...a.end}},e[r][1].end={...s.start},e[n][1].start={...a.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=In(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=In(c,[["enter",o,t],["enter",s,t],["exit",s,t],["enter",i,t]]),c=In(c,Gi(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=In(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=In(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):l=0,gn(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 g3(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,o=Dh(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=Dh(u),p=!l||l===2&&o||n.includes(u),g=!o||o===2&&l||n.includes(r);return c._open=!!(i===42?p:p&&(o||!g)),c._close=!!(i===42?g:g&&(l||!p)),t(u)}}function N1(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var Rh={name:"autolink",tokenize:f3};function f3(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 Jn(d)?(e.consume(d),s):d===64?n(d):c(d)}function s(d){return d===43||d===45||d===46||cn(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||cn(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||ma(d)?n(d):(e.consume(d),u)}function c(d){return d===64?(e.consume(d),l):A1(d)?(e.consume(d),c):n(d)}function l(d){return cn(d)?p(d):n(d)}function p(d){return d===46?(e.consume(d),r=0,l):d===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(d),e.exit("autolinkMarker"),e.exit("autolink"),t):g(d)}function g(d){if((d===45||cn(d))&&r++<63){let m=d===45?g:p;return e.consume(d),m}return n(d)}}var No={partial:!0,tokenize:m3};function m3(e,t,n){return r;function r(i){return He(i)?qe(e,o,"linePrefix")(i):o(i)}function o(i){return i===null||ue(i)?t(i):n(i)}}var vc={continuation:{tokenize:x3},exit:y3,name:"blockQuote",tokenize:h3};function h3(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 He(s)?(e.enter("blockQuotePrefixWhitespace"),e.consume(s),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(s))}}function x3(e,t,n){let r=this;return o;function o(s){return He(s)?qe(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s):i(s)}function i(s){return e.attempt(vc,t,n)(s)}}function y3(e){e.exit("blockQuote")}var kc={name:"characterEscape",tokenize:b3};function b3(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 L1(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}var Cc={name:"characterReference",tokenize:S3};function S3(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=cn,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=P1,l):(e.enter("characterReferenceValue"),i=7,s=ha,l(p))}function l(p){if(p===59&&o){let g=e.exit("characterReferenceValue");return s===cn&&!Vi(r.sliceSerialize(g))?n(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return s(p)&&o++<i?(e.consume(p),l):n(p)}}var O1={partial:!0,tokenize:v3},Tc={concrete:!0,name:"codeFenced",tokenize:w3};function w3(e,t,n){let r=this,o={partial:!0,tokenize:_},i=0,s=0,a;return u;function u(P){return c(P)}function c(P){let z=r.events[r.events.length-1];return i=z&&z[1].type==="linePrefix"?z[2].sliceSerialize(z[1],!0).length:0,a=P,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),l(P)}function l(P){return P===a?(s++,e.consume(P),l):s<3?n(P):(e.exit("codeFencedFenceSequence"),He(P)?qe(e,p,"whitespace")(P):p(P))}function p(P){return P===null||ue(P)?(e.exit("codeFencedFence"),r.interrupt?t(P):e.check(O1,C,R)(P)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),g(P))}function g(P){return P===null||ue(P)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(P)):He(P)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),qe(e,d,"whitespace")(P)):P===96&&P===a?n(P):(e.consume(P),g)}function d(P){return P===null||ue(P)?p(P):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(P))}function m(P){return P===null||ue(P)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(P)):P===96&&P===a?n(P):(e.consume(P),m)}function C(P){return e.attempt(o,R,T)(P)}function T(P){return e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),E}function E(P){return i>0&&He(P)?qe(e,I,"linePrefix",i+1)(P):I(P)}function I(P){return P===null||ue(P)?e.check(O1,C,R)(P):(e.enter("codeFlowValue"),D(P))}function D(P){return P===null||ue(P)?(e.exit("codeFlowValue"),I(P)):(e.consume(P),D)}function R(P){return e.exit("codeFenced"),t(P)}function _(P,z,x){let w=0;return v;function v(b){return P.enter("lineEnding"),P.consume(b),P.exit("lineEnding"),k}function k(b){return P.enter("codeFencedFence"),He(b)?qe(P,f,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(b):f(b)}function f(b){return b===a?(P.enter("codeFencedFenceSequence"),F(b)):x(b)}function F(b){return b===a?(w++,P.consume(b),F):w>=s?(P.exit("codeFencedFenceSequence"),He(b)?qe(P,S,"whitespace")(b):S(b)):x(b)}function S(b){return b===null||ue(b)?(P.exit("codeFencedFence"),z(b)):x(b)}}}function v3(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 ya={name:"codeIndented",tokenize:C3},k3={partial:!0,tokenize:T3};function C3(e,t,n){let r=this;return o;function o(c){return e.enter("codeIndented"),qe(e,i,"linePrefix",5)(c)}function i(c){let l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?s(c):n(c)}function s(c){return c===null?u(c):ue(c)?e.attempt(k3,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 T3(e,t,n){let r=this;return o;function o(s){return r.parser.lazy[r.now().line]?n(s):ue(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),o):qe(e,i,"linePrefix",5)(s)}function i(s){let a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(s):ue(s)?o(s):n(s)}}var zh={name:"codeText",previous:F3,resolve:I3,tokenize:E3};function I3(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 F3(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function E3(e,t,n){let r=this,o=0,i,s;return a;function a(g){return e.enter("codeText"),e.enter("codeTextSequence"),u(g)}function u(g){return g===96?(e.consume(g),o++,u):(e.exit("codeTextSequence"),c(g))}function c(g){return g===null?n(g):g===32?(e.enter("space"),e.consume(g),e.exit("space"),c):g===96?(s=e.enter("codeTextSequence"),i=0,p(g)):ue(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),c):(e.enter("codeTextData"),l(g))}function l(g){return g===null||g===32||g===96||ue(g)?(e.exit("codeTextData"),c(g)):(e.consume(g),l)}function p(g){return g===96?(e.consume(g),i++,p):i===o?(e.exit("codeTextSequence"),e.exit("codeText"),t(g)):(s.type="codeTextData",l(g))}}var Ic=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&&ba(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),ba(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),ba(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);ba(this.right,n.reverse())}else{let n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);ba(this.left,n.reverse())}}};function ba(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 Fc(e){let t={},n=-1,r,o,i,s,a,u,c,l=new Ic(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,A3(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 gn(e,0,Number.POSITIVE_INFINITY,l.slice(0)),!c}function A3(e,t){let n=e.get(t)[1],r=e.get(t)[2],o=t-1,i=[],s=n._tokenizer;s||(s=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(s._contentTypeTextTrailing=!0));let a=s.events,u=[],c={},l,p,g=-1,d=n,m=0,C=0,T=[C];for(;d;){for(;e.get(++o)[1]!==d;);i.push(o),d._tokenizer||(l=r.sliceStream(d),d.next||l.push(null),p&&s.defineSkip(d.start),d._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(l),d._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),p=d,d=d.next}for(d=n;++g<a.length;)a[g][0]==="exit"&&a[g-1][0]==="enter"&&a[g][1].type===a[g-1][1].type&&a[g][1].start.line!==a[g][1].end.line&&(C=g+1,T.push(C),d._tokenizer=void 0,d.previous=void 0,d=d.next);for(s.events=[],d?(d._tokenizer=void 0,d.previous=void 0):T.pop(),g=T.length;g--;){let E=a.slice(T[g],T[g+1]),I=i.pop();u.push([I,I+E.length-1]),e.splice(I,2,E)}for(u.reverse(),g=-1;++g<u.length;)c[m+u[g][0]]=m+u[g][1],m+=u[g][1]-u[g][0]-1;return c}var Nh={resolve:L3,tokenize:M3},P3={partial:!0,tokenize:B3};function L3(e){return Fc(e),e}function M3(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(P3,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 B3(e,t,n){let r=this;return o;function o(s){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),qe(e,i,"linePrefix")}function i(s){if(s===null||ue(s))return n(s);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(s):e.interrupt(r.parser.constructs.flow,n,t)(s)}}function Ec(e,t,n,r,o,i,s,a,u){let c=u||Number.POSITIVE_INFINITY,l=0;return p;function p(E){return E===60?(e.enter(r),e.enter(o),e.enter(i),e.consume(E),e.exit(i),g):E===null||E===32||E===41||ma(E)?n(E):(e.enter(r),e.enter(s),e.enter(a),e.enter("chunkString",{contentType:"string"}),C(E))}function g(E){return E===62?(e.enter(i),e.consume(E),e.exit(i),e.exit(o),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),d(E))}function d(E){return E===62?(e.exit("chunkString"),e.exit(a),g(E)):E===null||E===60||ue(E)?n(E):(e.consume(E),E===92?m:d)}function m(E){return E===60||E===62||E===92?(e.consume(E),d):d(E)}function C(E){return!l&&(E===null||E===41||Wt(E))?(e.exit("chunkString"),e.exit(a),e.exit(s),e.exit(r),t(E)):l<c&&E===40?(e.consume(E),l++,C):E===41?(e.consume(E),l--,C):E===null||E===32||E===40||ma(E)?n(E):(e.consume(E),E===92?T:C)}function T(E){return E===40||E===41||E===92?(e.consume(E),C):C(E)}}function Ac(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=!He(d)),d===92?g:p)}function g(d){return d===91||d===92||d===93?(e.consume(d),a++,p):p(d)}}function Pc(e,t,n,r,o,i){let s;return a;function a(g){return g===34||g===39||g===40?(e.enter(r),e.enter(o),e.consume(g),e.exit(o),s=g===40?41:g,u):n(g)}function u(g){return g===s?(e.enter(o),e.consume(g),e.exit(o),e.exit(r),t):(e.enter(i),c(g))}function c(g){return g===s?(e.exit(i),u(s)):g===null?n(g):ue(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),qe(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),l(g))}function l(g){return g===s||g===null||ue(g)?(e.exit("chunkString"),c(g)):(e.consume(g),g===92?p:l)}function p(g){return g===s||g===92?(e.consume(g),l):l(g)}}function ii(e,t){let n;return r;function r(o){return ue(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n=!0,r):He(o)?qe(e,r,n?"linePrefix":"lineSuffix")(o):t(o)}}var Oh={name:"definition",tokenize:R3},D3={partial:!0,tokenize:z3};function R3(e,t,n){let r=this,o;return i;function i(d){return e.enter("definition"),s(d)}function s(d){return Ac.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(d)}function a(d){return o=io(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)?ii(e,c)(d):c(d)}function c(d){return Ec(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(d)}function l(d){return e.attempt(D3,p,p)(d)}function p(d){return He(d)?qe(e,g,"whitespace")(d):g(d)}function g(d){return d===null||ue(d)?(e.exit("definition"),r.parser.defined.push(o),t(d)):n(d)}}function z3(e,t,n){return r;function r(a){return Wt(a)?ii(e,o)(a):n(a)}function o(a){return Pc(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function i(a){return He(a)?qe(e,s,"whitespace")(a):s(a)}function s(a){return a===null||ue(a)?t(a):n(a)}}var _h={name:"hardBreakEscape",tokenize:N3};function N3(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 $h={name:"headingAtx",resolve:O3,tokenize:_3};function O3(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"},gn(e,r,n-r+1,[["enter",o,t],["enter",i,t],["exit",i,t],["exit",o,t]])),e}function _3(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)):He(l)?qe(e,a,"whitespace")(l):(e.enter("atxHeadingText"),c(l))}function u(l){return l===35?(e.consume(l),u):(e.exit("atxHeadingSequence"),a(l))}function c(l){return l===null||l===35||Wt(l)?(e.exit("atxHeadingText"),a(l)):(e.consume(l),c)}}var _1=["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"],Uh=["pre","script","style","textarea"];var jh={concrete:!0,name:"htmlFlow",resolveTo:j3,tokenize:H3},$3={partial:!0,tokenize:V3},U3={partial:!0,tokenize:W3};function j3(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 H3(e,t,n){let r=this,o,i,s,a,u;return c;function c(M){return l(M)}function l(M){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(M),p}function p(M){return M===33?(e.consume(M),g):M===47?(e.consume(M),i=!0,C):M===63?(e.consume(M),o=3,r.interrupt?t:h):Jn(M)?(e.consume(M),s=String.fromCharCode(M),T):n(M)}function g(M){return M===45?(e.consume(M),o=2,d):M===91?(e.consume(M),o=5,a=0,m):Jn(M)?(e.consume(M),o=4,r.interrupt?t:h):n(M)}function d(M){return M===45?(e.consume(M),r.interrupt?t:h):n(M)}function m(M){let X="CDATA[";return M===X.charCodeAt(a++)?(e.consume(M),a===X.length?r.interrupt?t:f:m):n(M)}function C(M){return Jn(M)?(e.consume(M),s=String.fromCharCode(M),T):n(M)}function T(M){if(M===null||M===47||M===62||Wt(M)){let X=M===47,Z=s.toLowerCase();return!X&&!i&&Uh.includes(Z)?(o=1,r.interrupt?t(M):f(M)):_1.includes(s.toLowerCase())?(o=6,X?(e.consume(M),E):r.interrupt?t(M):f(M)):(o=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(M):i?I(M):D(M))}return M===45||cn(M)?(e.consume(M),s+=String.fromCharCode(M),T):n(M)}function E(M){return M===62?(e.consume(M),r.interrupt?t:f):n(M)}function I(M){return He(M)?(e.consume(M),I):v(M)}function D(M){return M===47?(e.consume(M),v):M===58||M===95||Jn(M)?(e.consume(M),R):He(M)?(e.consume(M),D):v(M)}function R(M){return M===45||M===46||M===58||M===95||cn(M)?(e.consume(M),R):_(M)}function _(M){return M===61?(e.consume(M),P):He(M)?(e.consume(M),_):D(M)}function P(M){return M===null||M===60||M===61||M===62||M===96?n(M):M===34||M===39?(e.consume(M),u=M,z):He(M)?(e.consume(M),P):x(M)}function z(M){return M===u?(e.consume(M),u=null,w):M===null||ue(M)?n(M):(e.consume(M),z)}function x(M){return M===null||M===34||M===39||M===47||M===60||M===61||M===62||M===96||Wt(M)?_(M):(e.consume(M),x)}function w(M){return M===47||M===62||He(M)?D(M):n(M)}function v(M){return M===62?(e.consume(M),k):n(M)}function k(M){return M===null||ue(M)?f(M):He(M)?(e.consume(M),k):n(M)}function f(M){return M===45&&o===2?(e.consume(M),A):M===60&&o===1?(e.consume(M),L):M===62&&o===4?(e.consume(M),j):M===63&&o===3?(e.consume(M),h):M===93&&o===5?(e.consume(M),N):ue(M)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check($3,H,F)(M)):M===null||ue(M)?(e.exit("htmlFlowData"),F(M)):(e.consume(M),f)}function F(M){return e.check(U3,S,H)(M)}function S(M){return e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),b}function b(M){return M===null||ue(M)?F(M):(e.enter("htmlFlowData"),f(M))}function A(M){return M===45?(e.consume(M),h):f(M)}function L(M){return M===47?(e.consume(M),s="",B):f(M)}function B(M){if(M===62){let X=s.toLowerCase();return Uh.includes(X)?(e.consume(M),j):f(M)}return Jn(M)&&s.length<8?(e.consume(M),s+=String.fromCharCode(M),B):f(M)}function N(M){return M===93?(e.consume(M),h):f(M)}function h(M){return M===62?(e.consume(M),j):M===45&&o===2?(e.consume(M),h):f(M)}function j(M){return M===null||ue(M)?(e.exit("htmlFlowData"),H(M)):(e.consume(M),j)}function H(M){return e.exit("htmlFlow"),t(M)}}function W3(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 V3(e,t,n){return r;function r(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(No,t,n)}}var Hh={name:"htmlText",tokenize:G3};function G3(e,t,n){let r=this,o,i,s;return a;function a(h){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(h),u}function u(h){return h===33?(e.consume(h),c):h===47?(e.consume(h),_):h===63?(e.consume(h),D):Jn(h)?(e.consume(h),x):n(h)}function c(h){return h===45?(e.consume(h),l):h===91?(e.consume(h),i=0,m):Jn(h)?(e.consume(h),I):n(h)}function l(h){return h===45?(e.consume(h),d):n(h)}function p(h){return h===null?n(h):h===45?(e.consume(h),g):ue(h)?(s=p,L(h)):(e.consume(h),p)}function g(h){return h===45?(e.consume(h),d):p(h)}function d(h){return h===62?A(h):h===45?g(h):p(h)}function m(h){let j="CDATA[";return h===j.charCodeAt(i++)?(e.consume(h),i===j.length?C:m):n(h)}function C(h){return h===null?n(h):h===93?(e.consume(h),T):ue(h)?(s=C,L(h)):(e.consume(h),C)}function T(h){return h===93?(e.consume(h),E):C(h)}function E(h){return h===62?A(h):h===93?(e.consume(h),E):C(h)}function I(h){return h===null||h===62?A(h):ue(h)?(s=I,L(h)):(e.consume(h),I)}function D(h){return h===null?n(h):h===63?(e.consume(h),R):ue(h)?(s=D,L(h)):(e.consume(h),D)}function R(h){return h===62?A(h):D(h)}function _(h){return Jn(h)?(e.consume(h),P):n(h)}function P(h){return h===45||cn(h)?(e.consume(h),P):z(h)}function z(h){return ue(h)?(s=z,L(h)):He(h)?(e.consume(h),z):A(h)}function x(h){return h===45||cn(h)?(e.consume(h),x):h===47||h===62||Wt(h)?w(h):n(h)}function w(h){return h===47?(e.consume(h),A):h===58||h===95||Jn(h)?(e.consume(h),v):ue(h)?(s=w,L(h)):He(h)?(e.consume(h),w):A(h)}function v(h){return h===45||h===46||h===58||h===95||cn(h)?(e.consume(h),v):k(h)}function k(h){return h===61?(e.consume(h),f):ue(h)?(s=k,L(h)):He(h)?(e.consume(h),k):w(h)}function f(h){return h===null||h===60||h===61||h===62||h===96?n(h):h===34||h===39?(e.consume(h),o=h,F):ue(h)?(s=f,L(h)):He(h)?(e.consume(h),f):(e.consume(h),S)}function F(h){return h===o?(e.consume(h),o=void 0,b):h===null?n(h):ue(h)?(s=F,L(h)):(e.consume(h),F)}function S(h){return h===null||h===34||h===39||h===60||h===61||h===96?n(h):h===47||h===62||Wt(h)?w(h):(e.consume(h),S)}function b(h){return h===47||h===62||Wt(h)?w(h):n(h)}function A(h){return h===62?(e.consume(h),e.exit("htmlTextData"),e.exit("htmlText"),t):n(h)}function L(h){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),B}function B(h){return He(h)?qe(e,N,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(h):N(h)}function N(h){return e.enter("htmlTextData"),s(h)}}var si={name:"labelEnd",resolveAll:X3,resolveTo:Q3,tokenize:J3},q3={tokenize:Z3},Y3={tokenize:e5},K3={tokenize:t5};function X3(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&&gn(e,0,e.length,n),e}function Q3(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=In(a,e.slice(i+1,i+r+3)),a=In(a,[["enter",l,t]]),a=In(a,Gi(t.parser.constructs.insideSpan.null,e.slice(i+r+4,s-3),t)),a=In(a,[["exit",l,t],e[s-2],e[s-1],["exit",c,t]]),a=In(a,e.slice(s+1)),a=In(a,[["exit",u,t]]),gn(e,i,e.length,a),e}function J3(e,t,n){let r=this,o=r.events.length,i,s;for(;o--;)if((r.events[o][1].type==="labelImage"||r.events[o][1].type==="labelLink")&&!r.events[o][1]._balanced){i=r.events[o][1];break}return a;function a(g){return i?i._inactive?p(g):(s=r.parser.defined.includes(io(r.sliceSerialize({start:i.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(g),e.exit("labelMarker"),e.exit("labelEnd"),u):n(g)}function u(g){return g===40?e.attempt(q3,l,s?l:p)(g):g===91?e.attempt(Y3,l,s?c:p)(g):s?l(g):p(g)}function c(g){return e.attempt(K3,l,p)(g)}function l(g){return t(g)}function p(g){return i._balanced=!0,n(g)}}function Z3(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)?ii(e,i)(p):i(p)}function i(p){return p===41?l(p):Ec(e,s,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function s(p){return Wt(p)?ii(e,u)(p):l(p)}function a(p){return n(p)}function u(p){return p===34||p===39||p===40?Pc(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):l(p)}function c(p){return Wt(p)?ii(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 e5(e,t,n){let r=this;return o;function o(a){return Ac.call(r,e,i,s,"reference","referenceMarker","referenceString")(a)}function i(a){return r.parser.defined.includes(io(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function s(a){return n(a)}}function t5(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 Wh={name:"labelStartImage",resolveAll:si.resolveAll,tokenize:n5};function n5(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 Vh={name:"labelStartLink",resolveAll:si.resolveAll,tokenize:r5};function r5(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 Sa={name:"lineEnding",tokenize:o5};function o5(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),qe(e,t,"linePrefix")}}var ai={name:"thematicBreak",tokenize:i5};function i5(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"),He(c)?qe(e,a,"whitespace")(c):a(c))}}var bn={continuation:{tokenize:c5},exit:p5,name:"list",tokenize:l5},s5={partial:!0,tokenize:d5},a5={partial:!0,tokenize:u5};function l5(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:ha(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(ai,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 ha(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(No,r.interrupt?n:l,e.attempt(s5,g,p))}function l(d){return r.containerState.initialBlankLine=!0,i++,g(d)}function p(d){return He(d)?(e.enter("listItemPrefixWhitespace"),e.consume(d),e.exit("listItemPrefixWhitespace"),g):n(d)}function g(d){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(d)}}function c5(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(No,o,i);function o(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,qe(e,t,"listItemIndent",r.containerState.size+1)(a)}function i(a){return r.containerState.furtherBlankLines||!He(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(a5,t,s)(a))}function s(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,qe(e,e.attempt(bn,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function u5(e,t,n){let r=this;return qe(e,o,"listItemIndent",r.containerState.size+1);function o(i){let s=r.events[r.events.length-1];return s&&s[1].type==="listItemIndent"&&s[2].sliceSerialize(s[1],!0).length===r.containerState.size?t(i):n(i)}}function p5(e){e.exit(this.containerState.type)}function d5(e,t,n){let r=this;return qe(e,o,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(i){let s=r.events[r.events.length-1];return!He(i)&&s&&s[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}var Lc={name:"setextUnderline",resolveTo:g5,tokenize:f5};function g5(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 f5(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"),He(c)?qe(e,u,"lineSuffix")(c):u(c))}function u(c){return c===null||ue(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}var $1={tokenize:m5};function m5(e){let t=this,n=e.attempt(No,r,e.attempt(this.parser.constructs.flowInitial,o,qe(e,e.attempt(this.parser.constructs.flow,o,e.attempt(Nh,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 U1={resolveAll:V1()},j1=W1("string"),H1=W1("text");function W1(e){return{resolveAll:V1(e==="text"?h5:void 0),tokenize:t};function t(n){let r=this,o=this.parser.constructs[e],i=n.attempt(o,s,a);return s;function s(l){return c(l)?i(l):a(l)}function a(l){if(l===null){n.consume(l);return}return n.enter("data"),n.consume(l),u}function u(l){return c(l)?(n.exit("data"),i(l)):(n.consume(l),u)}function c(l){if(l===null)return!0;let p=o[l],g=-1;if(p)for(;++g<p.length;){let d=p[g];if(!d.previous||d.previous.call(r,r.previous))return!0}return!1}}}function V1(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 h5(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 Gh={};Se(Gh,{attentionMarkers:()=>C5,contentInitial:()=>y5,disable:()=>T5,document:()=>x5,flow:()=>S5,flowInitial:()=>b5,insideSpan:()=>k5,string:()=>w5,text:()=>v5});var x5={42:bn,43:bn,45:bn,48:bn,49:bn,50:bn,51:bn,52:bn,53:bn,54:bn,55:bn,56:bn,57:bn,62:vc},y5={91:Oh},b5={[-2]:ya,[-1]:ya,32:ya},S5={35:$h,42:ai,45:[Lc,ai],60:jh,61:Lc,95:ai,96:Tc,126:Tc},w5={38:Cc,92:kc},v5={[-5]:Sa,[-4]:Sa,[-3]:Sa,33:Wh,38:Cc,42:xa,60:[Rh,Hh],91:Vh,92:[_h,kc],93:si,95:xa,96:zh},k5={null:[xa,U1]},C5={null:[42,95]},T5={null:[]};function G1(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},o={},i=[],s=[],a=[],u=!0,c={attempt:w(z),check:w(x),consume:R,enter:_,exit:P,interrupt:w(x,{interrupt:!0})},l={code:null,containerState:{},defineSkip:E,events:[],now:T,parser:e,previous:null,sliceSerialize:m,sliceStream:C,write:d},p=t.tokenize.call(l,c),g;return t.resolveAll&&i.push(t),l;function d(F){return s=In(s,F),I(),s[s.length-1]!==null?[]:(v(t,0),l.events=Gi(i,l.events,l),l.events)}function m(F,S){return F5(C(F),S)}function C(F){return I5(s,F)}function T(){let{_bufferIndex:F,_index:S,line:b,column:A,offset:L}=r;return{_bufferIndex:F,_index:S,line:b,column:A,offset:L}}function E(F){o[F.line]=F.column,f()}function I(){let F;for(;r._index<s.length;){let S=s[r._index];if(typeof S=="string")for(F=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===F&&r._bufferIndex<S.length;)D(S.charCodeAt(r._bufferIndex));else D(S)}}function D(F){u=void 0,g=F,p=p(F)}function R(F){ue(F)?(r.line++,r.column=1,r.offset+=F===-3?2:1,f()):F!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===s[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=F,u=!0}function _(F,S){let b=S||{};return b.type=F,b.start=T(),l.events.push(["enter",b,l]),a.push(b),b}function P(F){let S=a.pop();return S.end=T(),l.events.push(["exit",S,l]),S}function z(F,S){v(F,S.from)}function x(F,S){S.restore()}function w(F,S){return b;function b(A,L,B){let N,h,j,H;return Array.isArray(A)?X(A):"tokenize"in A?X([A]):M(A);function M(oe){return Ye;function Ye(be){let Ce=be!==null&&oe[be],te=be!==null&&oe.null,Le=[...Array.isArray(Ce)?Ce:Ce?[Ce]:[],...Array.isArray(te)?te:te?[te]:[]];return X(Le)(be)}}function X(oe){return N=oe,h=0,oe.length===0?B:Z(oe[h])}function Z(oe){return Ye;function Ye(be){return H=k(),j=oe,oe.partial||(l.currentConstruct=oe),oe.name&&l.parser.constructs.disable.null.includes(oe.name)?xe(be):oe.tokenize.call(S?Object.assign(Object.create(l),S):l,c,me,xe)(be)}}function me(oe){return u=!0,F(j,H),L}function xe(oe){return u=!0,H.restore(),++h<N.length?Z(N[h]):B}}}function v(F,S){F.resolveAll&&!i.includes(F)&&i.push(F),F.resolve&&gn(l.events,S,l.events.length-S,F.resolve(l.events.slice(S),l)),F.resolveTo&&(l.events=F.resolveTo(l.events,l))}function k(){let F=T(),S=l.previous,b=l.currentConstruct,A=l.events.length,L=Array.from(a);return{from:A,restore:B};function B(){r=F,l.previous=S,l.currentConstruct=b,l.events.length=A,a=L,f()}}function f(){r.line in o&&r.column<2&&(r.column=o[r.line],r.offset+=o[r.line]-1)}}function I5(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 F5(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 Oh(e){let r={constructs:h1([Nh,...(e||{}).extensions||[]]),content:o(v1),defined:[],document:o(C1),flow:o(E1),lazy:{},string:o(P1),text:o(L1)};return r;function o(i){return s;function s(a){return D1(r,i,a)}}}function _h(e){for(;!bc(e););return e}var R1=/[\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(R1.lastIndex=p,c=R1.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 J3=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function z1(e){return e.replace(J3,Z3)}function Z3(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 O1={}.hasOwnProperty;function Uh(e,t,n){return typeof t!="string"&&(n=t,t=void 0),e5(n)(_h(Oh(n).document().write($h()(e,t,!0))))}function e5(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:B,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(L),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:M,setextHeadingText:P,strong:u(),thematicBreak:u()}};_1(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]];O1.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]||N1).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]||N1).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 Ch(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 P(){this.data.setextHeadingSlurpLineEnding=!0}function M(_){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 L(){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=z1(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 B(){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 _1(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?_1(e,r):t5(e,r)}}function t5(e,t){let n;for(n in t)if(O1.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 N1(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 Uh(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 U1(e,t){let n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
84
- `}]}function j1(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 H1(e,t){let n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function W1(e,t){let n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function V1(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 G1(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 q1(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 Y1(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 K1(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 X1(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 Q1(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 J1(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 Z1(e,t,n){let r=e.all(t),o=n?n5(n):eT(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:`
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 qh(e){let r={constructs:E1([Gh,...(e||{}).extensions||[]]),content:o(D1),defined:[],document:o(z1),flow:o($1),lazy:{},string:o(j1),text:o(H1)};return r;function o(i){return s;function s(a){return G1(r,i,a)}}}function Yh(e){for(;!Fc(e););return e}var q1=/[\0\t\n\r]/g;function Kh(){let e=1,t="",n=!0,r;return o;function o(i,s,a){let u=[],c,l,p,g,d;for(i=t+(typeof i=="string"?i.toString():new TextDecoder(s||void 0).decode(i)),p=0,t="",n&&(i.charCodeAt(0)===65279&&p++,n=void 0);p<i.length;){if(q1.lastIndex=p,c=q1.exec(i),g=c&&c.index!==void 0?c.index:i.length,d=i.charCodeAt(g),!c){t=i.slice(p);break}if(d===10&&p===g&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),p<g&&(u.push(i.slice(p,g)),e+=g-p),d){case 0:{u.push(65533),e++;break}case 9:{for(l=Math.ceil(e/4)*4,u.push(-2);e++<l;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}p=g+1}return a&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}var E5=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Y1(e){return e.replace(E5,A5)}function A5(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let o=n.charCodeAt(1),i=o===120||o===88;return wc(n.slice(i?2:1),i?16:10)}return Vi(n)||e}var X1={}.hasOwnProperty;function Xh(e,t,n){return typeof t!="string"&&(n=t,t=void 0),P5(n)(Yh(qh(n).document().write(Kh()(e,t,!0))))}function P5(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(ge),autolinkProtocol:w,autolinkEmail:w,atxHeading:i(pe),blockQuote:i(be),characterEscape:w,characterReference:w,codeFenced:i(Ce),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:i(Ce,s),codeText:i(te,s),codeTextData:w,data:w,codeFlowValue:w,definition:i(Le),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:i(Ee),hardBreakEscape:i(At),hardBreakTrailing:i(At),htmlFlow:i(tn,s),htmlFlowData:w,htmlText:i(tn,s),htmlTextData:w,image:i(Pr),label:s,link:i(ge),listItem:i(he),listItemValue:g,listOrdered:i(tt,p),listUnordered:i(tt),paragraph:i(ie),reference:M,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:i(pe),strong:i(Y),thematicBreak:i(se)},exit:{atxHeading:u(),atxHeadingSequence:_,autolink:u(),autolinkEmail:Ye,autolinkProtocol:oe,blockQuote:u(),characterEscapeValue:v,characterReferenceMarkerHexadecimal:Z,characterReferenceMarkerNumeric:Z,characterReferenceValue:me,characterReference:xe,codeFenced:u(T),codeFencedFence:C,codeFencedFenceInfo:d,codeFencedFenceMeta:m,codeFlowValue:v,codeIndented:u(E),codeText:u(b),codeTextData:v,data:v,definition:u(),definitionDestinationString:R,definitionLabelString:I,definitionTitleString:D,emphasis:u(),hardBreakEscape:u(f),hardBreakTrailing:u(f),htmlFlow:u(F),htmlFlowData:v,htmlText:u(S),htmlTextData:v,image:u(L),label:N,labelText:B,lineEnding:k,link:u(A),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:X,resourceDestinationString:h,resourceTitleString:j,resource:H,setextHeading:u(x),setextHeadingLineSequence:z,setextHeadingText:P,strong:u(),thematicBreak:u()}};Q1(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(O){let U={type:"root",children:[]},W={stack:[U],tokenStack:[],config:t,enter:a,exit:c,buffer:s,resume:l,data:n},Me=[],_e=-1;for(;++_e<O.length;)if(O[_e][1].type==="listOrdered"||O[_e][1].type==="listUnordered")if(O[_e][0]==="enter")Me.push(_e);else{let xt=Me.pop();_e=o(O,xt,_e)}for(_e=-1;++_e<O.length;){let xt=t[O[_e][0]];X1.call(xt,O[_e][1].type)&&xt[O[_e][1].type].call(Object.assign({sliceSerialize:O[_e][2].sliceSerialize},W),O[_e][1])}if(W.tokenStack.length>0){let xt=W.tokenStack[W.tokenStack.length-1];(xt[1]||K1).call(W,void 0,xt[0])}for(U.position={start:Oo(O.length>0?O[0][1].start:{line:1,column:1,offset:0}),end:Oo(O.length>0?O[O.length-2][1].end:{line:1,column:1,offset:0})},_e=-1;++_e<t.transforms.length;)U=t.transforms[_e](U)||U;return U}function o(O,U,W){let Me=U-1,_e=-1,xt=!1,Hn,Zn,Fn,po;for(;++Me<=W;){let Sn=O[Me];switch(Sn[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Sn[0]==="enter"?_e++:_e--,po=void 0;break}case"lineEndingBlank":{Sn[0]==="enter"&&(Hn&&!po&&!_e&&!Fn&&(Fn=Me),po=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:po=void 0}if(!_e&&Sn[0]==="enter"&&Sn[1].type==="listItemPrefix"||_e===-1&&Sn[0]==="exit"&&(Sn[1].type==="listUnordered"||Sn[1].type==="listOrdered")){if(Hn){let Lr=Me;for(Zn=void 0;Lr--;){let nn=O[Lr];if(nn[1].type==="lineEnding"||nn[1].type==="lineEndingBlank"){if(nn[0]==="exit")continue;Zn&&(O[Zn][1].type="lineEndingBlank",xt=!0),nn[1].type="lineEnding",Zn=Lr}else if(!(nn[1].type==="linePrefix"||nn[1].type==="blockQuotePrefix"||nn[1].type==="blockQuotePrefixWhitespace"||nn[1].type==="blockQuoteMarker"||nn[1].type==="listItemIndent"))break}Fn&&(!Zn||Fn<Zn)&&(Hn._spread=!0),Hn.end=Object.assign({},Zn?O[Zn][1].start:Sn[1].end),O.splice(Zn||Me,0,["exit",Hn,Sn[2]]),Me++,W++}if(Sn[1].type==="listItemPrefix"){let Lr={type:"listItem",_spread:!1,start:Object.assign({},Sn[1].start),end:void 0};Hn=Lr,O.splice(Me,0,["enter",Lr,Sn[2]]),Me++,W++,Fn=void 0,po=!0}}}return O[U][1]._spread=xt,W}function i(O,U){return W;function W(Me){a.call(this,O(Me),Me),U&&U.call(this,Me)}}function s(){this.stack.push({type:"fragment",children:[]})}function a(O,U,W){this.stack[this.stack.length-1].children.push(O),this.stack.push(O),this.tokenStack.push([U,W||void 0]),O.position={start:Oo(U.start),end:void 0}}function u(O){return U;function U(W){O&&O.call(this,W),c.call(this,W)}}function c(O,U){let W=this.stack.pop(),Me=this.tokenStack.pop();if(Me)Me[0].type!==O.type&&(U?U.call(this,O,Me[0]):(Me[1]||K1).call(this,O,Me[0]));else throw new Error("Cannot close `"+O.type+"` ("+Ro({start:O.start,end:O.end})+"): it\u2019s not open");W.position.end=Oo(O.end)}function l(){return Bh(this.stack.pop())}function p(){this.data.expectingFirstListItemValue=!0}function g(O){if(this.data.expectingFirstListItemValue){let U=this.stack[this.stack.length-2];U.start=Number.parseInt(this.sliceSerialize(O),10),this.data.expectingFirstListItemValue=void 0}}function d(){let O=this.resume(),U=this.stack[this.stack.length-1];U.lang=O}function m(){let O=this.resume(),U=this.stack[this.stack.length-1];U.meta=O}function C(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function T(){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 E(){let O=this.resume(),U=this.stack[this.stack.length-1];U.value=O.replace(/(\r?\n|\r)$/g,"")}function I(O){let U=this.resume(),W=this.stack[this.stack.length-1];W.label=U,W.identifier=io(this.sliceSerialize(O)).toLowerCase()}function D(){let O=this.resume(),U=this.stack[this.stack.length-1];U.title=O}function R(){let O=this.resume(),U=this.stack[this.stack.length-1];U.url=O}function _(O){let U=this.stack[this.stack.length-1];if(!U.depth){let W=this.sliceSerialize(O).length;U.depth=W}}function P(){this.data.setextHeadingSlurpLineEnding=!0}function z(O){let U=this.stack[this.stack.length-1];U.depth=this.sliceSerialize(O).codePointAt(0)===61?1:2}function x(){this.data.setextHeadingSlurpLineEnding=void 0}function w(O){let W=this.stack[this.stack.length-1].children,Me=W[W.length-1];(!Me||Me.type!=="text")&&(Me=fe(),Me.position={start:Oo(O.start),end:void 0},W.push(Me)),this.stack.push(Me)}function v(O){let U=this.stack.pop();U.value+=this.sliceSerialize(O),U.position.end=Oo(O.end)}function k(O){let U=this.stack[this.stack.length-1];if(this.data.atHardBreak){let W=U.children[U.children.length-1];W.position.end=Oo(O.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(U.type)&&(w.call(this,O),v.call(this,O))}function f(){this.data.atHardBreak=!0}function F(){let O=this.resume(),U=this.stack[this.stack.length-1];U.value=O}function S(){let O=this.resume(),U=this.stack[this.stack.length-1];U.value=O}function b(){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 L(){let O=this.stack[this.stack.length-1];if(this.data.inReference){let U=this.data.referenceType||"shortcut";O.type+="Reference",O.referenceType=U,delete O.url,delete O.title}else delete O.identifier,delete O.label;this.data.referenceType=void 0}function B(O){let U=this.sliceSerialize(O),W=this.stack[this.stack.length-2];W.label=Y1(U),W.identifier=io(U).toLowerCase()}function N(){let O=this.stack[this.stack.length-1],U=this.resume(),W=this.stack[this.stack.length-1];if(this.data.inReference=!0,W.type==="link"){let Me=O.children;W.children=Me}else W.alt=U}function h(){let O=this.resume(),U=this.stack[this.stack.length-1];U.url=O}function j(){let O=this.resume(),U=this.stack[this.stack.length-1];U.title=O}function H(){this.data.inReference=void 0}function M(){this.data.referenceType="collapsed"}function X(O){let U=this.resume(),W=this.stack[this.stack.length-1];W.label=U,W.identifier=io(this.sliceSerialize(O)).toLowerCase(),this.data.referenceType="full"}function Z(O){this.data.characterReferenceType=O.type}function me(O){let U=this.sliceSerialize(O),W=this.data.characterReferenceType,Me;W?(Me=wc(U,W==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Me=Vi(U);let _e=this.stack[this.stack.length-1];_e.value+=Me}function xe(O){let U=this.stack.pop();U.position.end=Oo(O.end)}function oe(O){v.call(this,O);let U=this.stack[this.stack.length-1];U.url=this.sliceSerialize(O)}function Ye(O){v.call(this,O);let U=this.stack[this.stack.length-1];U.url="mailto:"+this.sliceSerialize(O)}function be(){return{type:"blockquote",children:[]}}function Ce(){return{type:"code",lang:null,meta:null,value:""}}function te(){return{type:"inlineCode",value:""}}function Le(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Ee(){return{type:"emphasis",children:[]}}function pe(){return{type:"heading",depth:0,children:[]}}function At(){return{type:"break"}}function tn(){return{type:"html",value:""}}function Pr(){return{type:"image",title:null,url:"",alt:null}}function ge(){return{type:"link",title:null,url:"",children:[]}}function tt(O){return{type:"list",ordered:O.type==="listOrdered",start:null,spread:O._spread,children:[]}}function he(O){return{type:"listItem",spread:O._spread,checked:null,children:[]}}function ie(){return{type:"paragraph",children:[]}}function Y(){return{type:"strong",children:[]}}function fe(){return{type:"text",value:""}}function se(){return{type:"thematicBreak"}}}function Oo(e){return{line:e.line,column:e.column,offset:e.offset}}function Q1(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?Q1(e,r):L5(e,r)}}function L5(e,t){let n;for(n in t)if(X1.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 K1(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Ro({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Ro({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Ro({start:t.start,end:t.end})+") is still open")}function Mc(e){let t=this;t.parser=n;function n(r){return Xh(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function J1(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 Z1(e,t){let n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
84
+ `}]}function eT(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 tT(e,t){let n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function nT(e,t){let n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function rT(e,t){let n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),o=gr(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 oT(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 iT(e,t){if(e.options.allowDangerousHtml){let n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Bc(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 sT(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Bc(e,t);let o={src:gr(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 aT(e,t){let n={src:gr(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 lT(e,t){let n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);let r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function cT(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Bc(e,t);let o={href:gr(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 uT(e,t){let n={href:gr(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 pT(e,t,n){let r=e.all(t),o=n?M5(n):dT(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 n5(e){let t=!1;if(e.type==="list"){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=eT(n[r])}return t}function eT(e){let t=e.spread;return t??e.children.length>1}function tT(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 nT(e,t){let n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function rT(e,t){let n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function oT(e,t){let n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function iT(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 sT(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 aT(e,t){let n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function cT(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),o=0,i=[];for(;r;)i.push(lT(t.slice(o,r.index),o>0,!0),r[0]),o=r.index+r[0].length,r=n.exec(t);return i.push(lT(t.slice(o),o>0,!1)),i.join("")}function lT(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 uT(e,t){let n={type:"text",value:cT(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function pT(e,t){let n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var dT={blockquote:$1,break:U1,code:j1,delete:H1,emphasis:W1,footnoteReference:V1,heading:G1,html:q1,imageReference:Y1,image:K1,inlineCode:X1,linkReference:Q1,link:J1,listItem:Z1,list:tT,paragraph:nT,root:rT,strong:oT,table:iT,tableCell:aT,tableRow:sT,text:uT,thematicBreak:pT,toml:Ic,yaml:Ic,definition:Ic,footnoteDefinition:Ic};function Ic(){}var fT=typeof self=="object"?self:globalThis,s5=(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 fT[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 fT[i](s),o)};return r},Wh=e=>s5(new Map,e)(0);var Ui="",{toString:a5}={},{keys:l5}=Object,ga=e=>{let t=typeof e;if(t!=="object"||!e)return[0,t];let n=a5.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"),c5=(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 l5(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},Vh=(e,{json:t,lossy:n}={})=>{let r=[];return c5(!(t||n),!!t,new Map,r)(e),r};var ji=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Wh(Vh(e,t)):structuredClone(e):(e,t)=>Wh(Vh(e,t));function u5(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 p5(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function yT(e){let t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||u5,r=e.options.footnoteBackLabel||p5,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:`
87
+ `});let c={type:"element",tagName:"li",properties:i,children:s};return e.patch(t,c),e.applyData(t,c)}function M5(e){let t=!1;if(e.type==="list"){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=dT(n[r])}return t}function dT(e){let t=e.spread;return t??e.children.length>1}function gT(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 fT(e,t){let n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function mT(e,t){let n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function hT(e,t){let n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function xT(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=Wi(t.children[1]),u=Sc(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 yT(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?"th":"td",s=n&&n.type==="table"?n.align:void 0,a=s?s.length:t.children.length,u=-1,c=[];for(;++u<a;){let p=t.children[u],g={},d=s?s[u]:void 0;d&&(g.align=d);let m={type:"element",tagName:i,properties:g,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 bT(e,t){let n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function wT(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),o=0,i=[];for(;r;)i.push(ST(t.slice(o,r.index),o>0,!0),r[0]),o=r.index+r[0].length,r=n.exec(t);return i.push(ST(t.slice(o),o>0,!1)),i.join("")}function ST(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 vT(e,t){let n={type:"text",value:wT(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function kT(e,t){let n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var CT={blockquote:J1,break:Z1,code:eT,delete:tT,emphasis:nT,footnoteReference:rT,heading:oT,html:iT,imageReference:sT,image:aT,inlineCode:lT,linkReference:cT,link:uT,listItem:pT,list:gT,paragraph:fT,root:mT,strong:hT,table:xT,tableCell:bT,tableRow:yT,text:vT,thematicBreak:kT,toml:Dc,yaml:Dc,definition:Dc,footnoteDefinition:Dc};function Dc(){}var TT=typeof self=="object"?self:globalThis,z5=(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 TT[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 TT[i](s),o)};return r},Zh=e=>z5(new Map,e)(0);var qi="",{toString:N5}={},{keys:O5}=Object,wa=e=>{let t=typeof e;if(t!=="object"||!e)return[0,t];let n=N5.call(e).slice(8,-1);switch(n){case"Array":return[1,qi];case"Object":return[2,qi];case"Date":return[3,qi];case"RegExp":return[4,qi];case"Map":return[5,qi];case"Set":return[6,qi];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},zc=([e,t])=>e===0&&(t==="function"||t==="symbol"),_5=(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]=wa(s);switch(a){case 0:{let l=s;switch(u){case"bigint":a=8,l=s.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+u);l=null;break;case"undefined":return o([-1],s)}return o([a,l],s)}case 1:{if(u){let g=s;return u==="DataView"?g=new Uint8Array(s.buffer):u==="ArrayBuffer"&&(g=new Uint8Array(s)),o([u,[...g]],s)}let l=[],p=o([a,l],s);for(let g of s)l.push(i(g));return p}case 2:{if(u)switch(u){case"BigInt":return o([u,s.toString()],s);case"Boolean":case"Number":case"String":return o([u,s.valueOf()],s)}if(t&&"toJSON"in s)return i(s.toJSON());let l=[],p=o([a,l],s);for(let g of O5(s))(e||!zc(wa(s[g])))&&l.push([i(g),i(s[g])]);return p}case 3:return o([a,s.toISOString()],s);case 4:{let{source:l,flags:p}=s;return o([a,{source:l,flags:p}],s)}case 5:{let l=[],p=o([a,l],s);for(let[g,d]of s)(e||!(zc(wa(g))||zc(wa(d))))&&l.push([i(g),i(d)]);return p}case 6:{let l=[],p=o([a,l],s);for(let g of s)(e||!zc(wa(g)))&&l.push(i(g));return p}}let{message:c}=s;return o([a,{name:u,message:c}],s)};return i},ex=(e,{json:t,lossy:n}={})=>{let r=[];return _5(!(t||n),!!t,new Map,r)(e),r};var Yi=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Zh(ex(e,t)):structuredClone(e):(e,t)=>Zh(ex(e,t));function $5(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 U5(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function PT(e){let t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||$5,r=e.options.footnoteBackLabel||U5,o=e.options.footnoteLabel||"Footnotes",i=e.options.footnoteLabelTagName||"h2",s=e.options.footnoteLabelProperties||{className:["sr-only"]},a=[],u=-1;for(;++u<e.footnoteOrder.length;){let c=e.footnoteById.get(e.footnoteOrder[u]);if(!c)continue;let l=e.all(c),p=String(c.identifier).toUpperCase(),g=gr(p.toLowerCase()),d=0,m=[],C=e.footnoteCounts.get(p);for(;C!==void 0&&++d<=C;){m.length>0&&m.push({type:"text",value:" "});let I=typeof n=="string"?n:n(u,d);typeof I=="string"&&(I={type:"text",value:I}),m.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+g+(d>1?"-"+d:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(u,d),className:["data-footnote-backref"]},children:Array.isArray(I)?I:[I]})}let T=l[l.length-1];if(T&&T.type==="element"&&T.tagName==="p"){let I=T.children[T.children.length-1];I&&I.type==="text"?I.value+=" ":T.children.push({type:"text",value:" "}),T.children.push(...m)}else l.push(...m);let E={type:"element",tagName:"li",properties:{id:t+"fn-"+g},children:e.wrap(l,!0)};e.patch(c,E),a.push(E)}if(a.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:i,properties:{...Yi(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 m5;if(typeof e=="function")return Pc(e);if(typeof e=="object")return Array.isArray(e)?d5(e):f5(e);if(typeof e=="string")return g5(e);throw new Error("Expected function, string, or object as test")});function d5(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 f5(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 g5(e){return Pc(t);function t(n){return n&&n.type===e}}function Pc(e){return t;function t(n,r,o){return!!(h5(n)&&e.call(this,n,typeof r=="number"?r:void 0,o||void 0))}}function m5(){return!0}function h5(e){return e!==null&&typeof e=="object"&&"type"in e}var bT=[],Gh=!0,Lc=!1,qh="skip";function Yh(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=bT,m,w,k;if((!t||i(u,c,l[l.length-1]||void 0))&&(d=x5(n(u,l)),d[0]===Lc))return d;if("children"in u&&u.children){let F=u;if(F.children&&d[0]!==qh)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 x5(e){return Array.isArray(e)?e:typeof e=="number"?[Gh,e]:e==null?bT:[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),Yh(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 Kh={}.hasOwnProperty,y5={};function wT(e,t){let n=t||y5,r=new Map,o=new Map,i=new Map,s={...dT,...n.handlers},a={all:c,applyData:S5,definitionById:r,footnoteById:o,footnoteCounts:i,footnoteOrder:[],handlers:s,one:u,options:n,patch:b5,wrap:v5};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(Kh.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||w5)(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=ST(m.value)),!Array.isArray(m)&&m.type==="element")){let w=m.children[0];w&&w.type==="text"&&(w.value=ST(w.value))}Array.isArray(m)?p.push(...m):p.push(m)}}}return p}}function b5(e,t){e.position&&(t.position=yh(e))}function S5(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 w5(e,t){let n=t.data||{},r="value"in t&&!(Kh.call(n,"hProperties")||Kh.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 v5(e,t){let n=[],r=-1;for(t&&n.push({type:"text",value:`
89
+ `}]}}var Nc=(function(e){if(e==null)return V5;if(typeof e=="function")return Oc(e);if(typeof e=="object")return Array.isArray(e)?j5(e):H5(e);if(typeof e=="string")return W5(e);throw new Error("Expected function, string, or object as test")});function j5(e){let t=[],n=-1;for(;++n<e.length;)t[n]=Nc(e[n]);return Oc(r);function r(...o){let i=-1;for(;++i<t.length;)if(t[i].apply(this,o))return!0;return!1}}function H5(e){let t=e;return Oc(n);function n(r){let o=r,i;for(i in e)if(o[i]!==t[i])return!1;return!0}}function W5(e){return Oc(t);function t(n){return n&&n.type===e}}function Oc(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 V5(){return!0}function G5(e){return e!==null&&typeof e=="object"&&"type"in e}var LT=[],tx=!0,_c=!1,nx="skip";function rx(e,t,n,r){let o;typeof t=="function"&&typeof n!="function"?(r=n,n=t):o=t;let i=Nc(o),s=r?-1:1;a(e,void 0,[])();function a(u,c,l){let p=u&&typeof u=="object"?u:{};if(typeof p.type=="string"){let d=typeof p.tagName=="string"?p.tagName:typeof p.name=="string"?p.name:void 0;Object.defineProperty(g,"name",{value:"node ("+(u.type+(d?"<"+d+">":""))+")"})}return g;function g(){let d=LT,m,C,T;if((!t||i(u,c,l[l.length-1]||void 0))&&(d=q5(n(u,l)),d[0]===_c))return d;if("children"in u&&u.children){let E=u;if(E.children&&d[0]!==nx)for(C=(r?E.children.length:-1)+s,T=l.concat(E);C>-1&&C<E.children.length;){let I=E.children[C];if(m=a(I,C,T)(),m[0]===_c)return m;C=typeof m[1]=="number"?m[1]:C+s}}return d}}}function q5(e){return Array.isArray(e)?e:typeof e=="number"?[tx,e]:e==null?LT:[e]}function va(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),rx(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 ox={}.hasOwnProperty,Y5={};function BT(e,t){let n=t||Y5,r=new Map,o=new Map,i=new Map,s={...CT,...n.handlers},a={all:c,applyData:X5,definitionById:r,footnoteById:o,footnoteCounts:i,footnoteOrder:[],handlers:s,one:u,options:n,patch:K5,wrap:J5};return va(e,function(l){if(l.type==="definition"||l.type==="footnoteDefinition"){let p=l.type==="definition"?r:o,g=String(l.identifier).toUpperCase();p.has(g)||p.set(g,l)}}),a;function u(l,p){let g=l.type,d=a.handlers[g];if(ox.call(a.handlers,g)&&d)return d(a,l,p);if(a.options.passThrough&&a.options.passThrough.includes(g)){if("children"in l){let{children:C,...T}=l,E=Yi(T);return E.children=a.all(l),E}return Yi(l)}return(a.options.unknownHandler||Q5)(a,l,p)}function c(l){let p=[];if("children"in l){let g=l.children,d=-1;for(;++d<g.length;){let m=a.one(g[d],l);if(m){if(d&&g[d-1].type==="break"&&(!Array.isArray(m)&&m.type==="text"&&(m.value=MT(m.value)),!Array.isArray(m)&&m.type==="element")){let C=m.children[0];C&&C.type==="text"&&(C.value=MT(C.value))}Array.isArray(m)?p.push(...m):p.push(m)}}}return p}}function K5(e,t){e.position&&(t.position=Fh(e))}function X5(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,Yi(i)),"children"in n&&n.children&&o!==null&&o!==void 0&&(n.children=o)}return n}function Q5(e,t){let n=t.data||{},r="value"in t&&!(ox.call(n,"hProperties")||ox.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 J5(e,t){let n=[],r=-1;for(t&&n.push({type:"text",value:`
90
90
  `});++r<e.length;)r&&n.push({type:"text",value:`
91
91
  `}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
92
- `}),n}function ST(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=wT(e,t),r=n.one(e,void 0),o=yT(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 Xh(e){if(e)throw e}var zc=La(PT(),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 Qh(){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?LT(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 LT(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:k5,dirname:C5,extname:T5,join:I5,sep:"/"};function k5(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 C5(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 T5(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 I5(...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?".":F5(n)}function F5(e){xa(e);let t=e.codePointAt(0)===47,n=E5(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function E5(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 MT={cwd:A5};function A5(){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 BT(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 P5(e)}function P5(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 Jh=["history","path","basename","stem","extname","dirname"],ti=class{constructor(t){let n;t?Hi(t)?n={path:t}:typeof t=="string"||L5(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":MT.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Jh.length;){let i=Jh[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)Jh.includes(o)||(this[o]=n[o])}get basename(){return typeof this.path=="string"?kr.basename(this.path):void 0}set basename(t){ex(t,"basename"),Zh(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){DT(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(Zh(t,"extname"),DT(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=BT(t)),ex(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){ex(t,"stem"),Zh(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 Zh(e,t){if(e&&e.includes(kr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+kr.sep+"`")}function ex(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function DT(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function L5(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var RT=(function(e){let r=this.constructor.prototype,o=r[e],i=function(){return o.apply(i,arguments)};return Object.setPrototypeOf(i,r),i});var M5={}.hasOwnProperty,ox=class e extends RT{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=Qh()}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?(rx("data",this.frozen),this.namespace[t]=n,this):M5.call(this.namespace,t)&&this.namespace[t]||void 0:t?(rx("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 tx("parse",r),r(String(n),n)}process(t,n){let r=this;return this.freeze(),tx("process",this.parser||this.Parser),nx("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);D5(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(),tx("processSync",this.parser||this.Parser),nx("processSync",this.compiler||this.Compiler),this.process(t,o),NT("processSync","process",n),r;function o(i,s){n=!0,Xh(i),r=s}}run(t,n,r){zT(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),NT("runSync","run",r),o;function i(s,a){Xh(s),o=a,r=!0}}stringify(t,n){this.freeze();let r=Rc(n),o=this.compiler||this.Compiler;return nx("stringify",o),zT(t),o(t,r)}use(t,...n){let r=this.attachers,o=this.namespace;if(rx("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]}}}},ix=new ox().freeze();function tx(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function nx(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function rx(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 zT(e){if(!ha(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function NT(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Rc(e){return B5(e)?e:new ti(e)}function B5(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function D5(e){return typeof e=="string"||R5(e)}function R5(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var _5="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",OT=[],_T={allowDangerousHtml:!0},$5=/^(https?|ircs?|mailto|xmpp)$/i,U5=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function sx(e){let t=j5(e),n=H5(e);return W5(t.runSync(t.parse(n),n),e)}function j5(e){let t=e.rehypePlugins||OT,n=e.remarkPlugins||OT,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,..._T}:_T;return ix().use(Cc).use(n).use(Bc,r).use(t)}function H5(e){let t=e.children||"",n=new ti;return typeof t=="string"?n.value=t:(""+t,void 0),n}function W5(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 U5)Object.hasOwn(t,l.from)&&(""+l.from+(l.to?"use `"+l.to+"` instead":"remove it")+_5+l.id,void 0);return n&&i&&void 0,ma(e,c),wh(e,{Fragment:z5,components:o,ignoreInvalidStyle:!0,jsx:N5,jsxs:O5,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||$5.test(e.slice(0,t))?e:""}we();var G5=Wi.div({display:"flex",flexDirection:"column",gap:"12px"}),q5=Wi.div({display:"flex",justifyContent:"space-between",alignItems:"center"}),Y5=Wi.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),K5=Wi(er)({padding:"6px 12px",fontSize:"12px"}),X5=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:OC.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}})),Q5=Wi.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),ax=()=>{let{fullPrompt:e,userRole:t,roleOverride:n}=se(),[r,o]=V5(!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(G5,null,ni.createElement(q5,null,ni.createElement(Y5,null,"Full Prompt"),ni.createElement(K5,{onClick:s,disabled:r},r?"\u2713 Copied!":"\u{1F4CB} Copy")),ni.createElement(X5,null,ni.createElement(sx,null,e))):ni.createElement(Q5,null,"No prompt available. Generate a prompt or run a review to see the full prompt here.")};import eo,{useRef as J5}from"react";import{styled as Cr}from"storybook/theming";we();var Z5=Cr.div({display:"flex",flexDirection:"column",gap:"8px"}),Ape=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"}}),e6=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})),t6=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})),Ppe=Cr.div(({theme:e})=>({fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:e.color.mediumdark,marginBottom:"6px",letterSpacing:"0.5px"})),UT=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"}})),n6=Cr.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),r6=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"})),o6=Cr.div({fontWeight:700,fontSize:"14px",marginBottom:"4px",display:"flex",alignItems:"center",gap:"6px"}),i6=Cr.div(({theme:e})=>({fontSize:"12px",opacity:.9,color:e.color.positive||"#166534"})),Lpe=Cr.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,marginTop:"8px",textAlign:"right"}));function s6(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 lx=()=>{let{streamingMessages:e,fullResponse:t,reviewHistory:n,currentReviewId:r,userRole:o,roleOverride:i}=se(),s=J5(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(n6,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(Z5,null,l&&eo.createElement(r6,null,eo.createElement(o6,null,"Component Matches Design"),eo.createElement(i6,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(e6,{ref:s},d.map((m,w)=>eo.createElement(t6,{key:w,role:m.role},m.role==="system"?eo.createElement(UT,null,m.content):eo.createElement(UT,{dangerouslySetInnerHTML:{__html:s6(m.content)}})))))};import dr from"react";import{styled as Po}from"storybook/theming";we();De();var a6=Po.div({display:"flex",flexDirection:"column",gap:"12px"}),l6=Po.div(({theme:e})=>({display:"flex",gap:"6px",borderBottom:`2px solid ${e.appBorderColor}`,overflowX:"auto",paddingBottom:"2px"})),c6=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}}}),jT=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"}}),u6=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"})),HT=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"}})),WT=Po.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),p6=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 VT(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 d6(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 GT=()=>{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(WT,null,"No models selected. Select multiple models to compare results."):dr.createElement(a6,null,dr.createElement(l6,null,a.map(l=>{let p=Qr.find(F=>F.id===l),f=c[l],m=d6(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(c6,{key:l,isActive:w,provider:p.provider,onClick:()=>n(l)},p.name,f&&m.issueCount>0&&dr.createElement(jT,{variant:"issues",value:m.issueCount},m.issueCount," issues"),f&&m.score!==null&&dr.createElement(jT,{variant:"score",value:m.score},"Score: ",m.score),k&&dr.createElement(p6,null))})),dr.createElement(u6,null,c[u]?.streamingMessages&&c[u].streamingMessages.length>0?c[u].streamingMessages.map((l,p)=>dr.createElement(HT,{key:p,dangerouslySetInnerHTML:{__html:VT(l.content)}})):c[u]?.fullResponse?dr.createElement(HT,{dangerouslySetInnerHTML:{__html:VT(c[u].fullResponse)}}):dr.createElement(WT,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 cx}from"react";De();function qT(){let{dismissIssue:e,undismissIssue:t,reviewHistory:n}=se(),{sessionToken:r}=Se(),o=cx(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=cx((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=cx(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 vH,useState as kH,useEffect as CH}from"react";import{styled as it,keyframes as TH}from"storybook/theming";import ee,{useState as gx,useRef as fj,useCallback as lI,memo as gj}from"react";import{styled as Ie}from"storybook/theming";import to,{useState as f6}from"react";import{styled as no}from"storybook/theming";var g6=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}),m6=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}`})),h6=no.h3(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.defaultText,marginTop:0,marginBottom:"12px"})),x6=no.p(({theme:e})=>({fontSize:"13px",color:e.textMutedColor,marginBottom:"16px",lineHeight:"1.5"})),y6=no.label(({theme:e})=>({display:"block",fontSize:"12px",fontWeight:600,color:e.color.defaultText,marginBottom:"6px"})),b6=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}})),S6=no.div({display:"flex",justifyContent:"flex-end",gap:"10px"}),w6=no(en)({}),v6=no(Er)({}),YT=({isOpen:e,issueTitle:t,onConfirm:n,onCancel:r})=>{let[o,i]=f6("");if(!e)return null;let s=()=>{n(o.trim()||void 0),i("")},a=()=>{i(""),r()};return to.createElement(g6,{onClick:c=>{c.target===c.currentTarget&&a()}},to.createElement(m6,null,to.createElement(h6,null,"Dismiss as False Positive"),to.createElement(x6,null,'Mark "',t,'" as a false positive. You can optionally provide a reason for dismissing this issue.'),to.createElement(y6,{htmlFor:"dismiss-reason"},"Reason (optional)"),to.createElement(b6,{id:"dismiss-reason",value:o,onChange:c=>i(c.target.value),placeholder:"e.g., This is intentional design, not an issue..."}),to.createElement(S6,null,to.createElement(v6,{onClick:a},"Cancel"),to.createElement(w6,{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"},k6=ot.div(({theme:e})=>({marginTop:6,borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content,overflow:"hidden",maxWidth:340})),C6=ot.div(({theme:e})=>({padding:"6px 10px",fontSize:11,fontWeight:500,color:e.color.defaultText,borderBottom:`1px solid ${e.appBorderColor}`})),T6=ot.div({position:"relative",backgroundColor:Me.outerBg,padding:"8px 12px 24px",fontFamily:"monospace",fontSize:11}),Jpe=ot.div({display:"flex",justifyContent:"space-between",alignItems:"center",color:Me.dash,padding:"0 8px",height:18,fontSize:11}),Zpe=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}})),ede=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%)"}})),tde=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}})),I6=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})),F6=ot.div({display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 10px",fontSize:11,color:Me.text}),E6=ot.span({fontWeight:500,fontSize:11}),nde=ot.span({color:Me.dash}),A6=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"})),P6=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%)"}})),L6=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})),M6=ot.span({position:"absolute",bottom:4,right:8,fontSize:9,color:Me.dim,fontFamily:"monospace"}),B6=ot.div({display:"flex",alignItems:"center",gap:4,fontSize:10,fontWeight:600,color:Me.ok,padding:"4px 8px 6px"}),rde=ot.div({fontSize:11,fontWeight:600,color:Me.text,padding:"4px 12px 2px",display:"flex",alignItems:"center",gap:6}),ode=ot.span({fontSize:12,color:Me.dim}),D6=ot.img({maxWidth:"100%",maxHeight:40,objectFit:"contain",borderRadius:2}),R6=ot.div({fontSize:9,color:Me.dim,marginTop:2}),z6=({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?W6(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?V6(n)??"\u2014":"\u2014"),F=p.height??(u?G6(n)??"\u2014":"\u2014");return Te.createElement(Te.Fragment,null,Te.createElement(T6,null,Te.createElement(I6,{isErr:a},Te.createElement(F6,null,Te.createElement(E6,null,"Border"),Te.createElement("span",{style:{fontSize:11,fontFamily:"monospace",color:a?Me.err:Me.dim}},w)),Te.createElement(A6,{isErr:s},Te.createElement(P6,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(L6,{isErr:u,style:{flexDirection:"column",gap:4}},l&&Te.createElement(D6,{src:l,alt:"Figma element"}),Te.createElement(R6,null,k," \xD7 ",F)))),Te.createElement(M6,null,"border-box")),Te.createElement(B6,null,"\u2192 ",n))},KT=ot.div({backgroundColor:Me.outerBg,padding:"24px 16px 16px",display:"flex",flexDirection:"column",alignItems:"center",gap:8}),N6=ot.div({position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"12px 20px"}),ux=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})),O6=ot.div({position:"absolute",border:`1.5px dashed ${Me.err}`,pointerEvents:"none",zIndex:0}),_6=ot.div({position:"absolute",border:`1.5px dashed ${Me.blue}`,pointerEvents:"none",zIndex:0}),XT=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%)"}})),ide=ot.div({fontSize:12,color:Me.text,fontWeight:500,fontFamily:'-apple-system, BlinkMacSystemFont, "Inter", sans-serif'}),$6=ot.div({display:"flex",alignItems:"center",gap:6,fontSize:10,fontFamily:"monospace"}),QT=ot.span(e=>({padding:"1px 6px",borderRadius:3,fontWeight:600,fontSize:10,color:"#fff",backgroundColor:e.variant==="err"?Me.err:Me.ok})),U6=ot.div({display:"flex",alignItems:"flex-end",justifyContent:"center",gap:16,padding:"4px 0"}),JT=ot.div({display:"flex",flexDirection:"column",alignItems:"center",gap:4}),ZT=ot.div(e=>({fontSize:9,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.3px",color:e.variant==="err"?Me.err:Me.ok})),eI=ot.div(e=>({fontSize:10,fontFamily:"monospace",fontWeight:600,color:e.variant==="err"?Me.err:Me.ok,textDecoration:e.variant==="err"?"line-through":"none"})),j6=ot.span({fontSize:16,color:Me.dim,paddingBottom:20}),tI=ot.div(e=>({fontSize:9,color:e.color,fontFamily:"monospace",textAlign:"center",marginTop:2}));function nI(e){return e>=800?"ExtraBold":e>=700?"Bold":e>=600?"Semibold":e>=500?"Medium":e>=400?"Regular":e>=300?"Light":"Thin"}var H6=({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(KT,null,Te.createElement(N6,null,Te.createElement(_6,{style:{top:-6,left:0,right:0,bottom:-6}}),Te.createElement(O6,{style:{top:2,left:8,right:8,bottom:2}}),Te.createElement(XT,{color:s?Me.err:"#7b3030",side:"left"},s?t:`${f}px`),Te.createElement(XT,{color:u?Me.err:"#7b3030",side:"right"},u?t:`${w}px`),Te.createElement(ux,{fSize:k,fWeight:String(d||600)},"Ag")),Te.createElement("div",{style:{display:"flex",gap:16,justifyContent:"center"}},Te.createElement(tI,{color:Me.err},"\u2508\u2508 font-size",s?" \u2717":""),Te.createElement(tI,{color:Me.blue},"\u2508\u2508 line-height",u?" \u2717":"")),Te.createElement($6,null,Te.createElement(QT,{variant:"err"},t),Te.createElement("span",{style:{color:Me.dim}},"\u2192"),Te.createElement(QT,{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(KT,null,Te.createElement(U6,null,Te.createElement(JT,null,Te.createElement(ZT,{variant:"err"},"Current"),Te.createElement(ux,{fSize:k,fWeight:a?F:String(d||600),style:{color:Me.err}},c?t:"Ag"),Te.createElement(eI,{variant:"err"},a&&z?`${t} (${nI(z)})`:t)),Te.createElement(j6,null,"\u2192"),Te.createElement(JT,null,Te.createElement(ZT,{variant:"ok"},"Figma"),Te.createElement(ux,{fSize:k,fWeight:a?C:String(d||600),style:{color:Me.ok}},c?n:"Ag"),Te.createElement(eI,{variant:"ok"},a&&R?`${n} (${nI(R)})`:n)))))};function W6(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 V6(e){let t=e.match(/(\d+(?:\.\d+)?)\s*[×x]\s*(\d+(?:\.\d+)?)/);return t?parseFloat(t[1]):null}function G6(e){let t=e.match(/(\d+(?:\.\d+)?)\s*[×x]\s*(\d+(?:\.\d+)?)/);return t?parseFloat(t[2]):null}var rI=new Set(["fontSize","font-size","fontWeight","font-weight","lineHeight","line-height","letterSpacing","letter-spacing","fontFamily","font-family","textContent","text-content"]);function q6(e){if(rI.has(e))return!0;let t=e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return rI.has(t)}var oI=e=>{let t=!!e.figmaContext&&Object.keys(e.figmaContext).length>0,n=q6(e.property);return Te.createElement(k6,null,Te.createElement(C6,null,"\u25BE Layer properties",t?"":" (from review)"),n?Te.createElement(H6,{...e}):Te.createElement(z6,{...e}))};import Nr from"react";import{styled as Or}from"storybook/theming";var Y6={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)"}},K6=Or.div({display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap",marginBottom:"12px"}),X6=Or.div(({theme:e,category:t})=>{let n=Y6[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}`}}),Q6=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}}}),J6=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"}}),Z6=Or.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",marginLeft:"12px",paddingLeft:"12px",borderLeft:`1px solid ${e.appBorderColor}`})),ej=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"}}),tj=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"}}),nj=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"}}),rj=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}`})),oj=Or.span(({theme:e})=>({fontSize:"11px",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',color:e.textMutedColor,marginLeft:"auto"})),ij=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},iI=({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=ij(e.detectedBy),l=o&&c.ai===o,p=r&&!l&&(c.ai||c.programmatic),f=e.generatedFix?.filePath||e.file;return Nr.createElement(K6,null,Nr.createElement(X6,{category:e.type},e.type),e.status!=="pending"&&Nr.createElement(Q6,{status:e.status},e.status),n&&t&&Nr.createElement(J6,null,t),p&&Nr.createElement(Z6,null,c.ai&&!l&&Nr.createElement(ej,null,c.ai),c.programmatic&&Nr.createElement(tj,null,"Pre-filter: ",c.programmatic)),a&&Nr.createElement(nj,{title:u},"Unreliable"),e.dismissed&&Nr.createElement(rj,null,"Dismissed"),i&&s&&f&&Nr.createElement(oj,null,f))};import $n from"react";import{styled as Lo}from"storybook/theming";var sj=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},aj=e=>e?typeof e=="string"?e:typeof e=="object"?JSON.stringify(e):String(e):"",lj=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"})),px=Lo.div({display:"flex",gap:"8px",alignItems:"baseline"}),dx=Lo.span(({theme:e})=>({color:e.textMutedColor,fontWeight:500,width:"60px",flexShrink:0,fontSize:"11px"})),fx=Lo.span(({theme:e})=>({color:e.color.defaultText,fontFamily:"inherit",fontSize:"11px",fontWeight:500})),cj=Lo(fx)(({theme:e})=>({color:e.color.negative,textDecoration:"line-through",opacity:.7})),uj=Lo(fx)(({theme:e})=>({color:e.color.positive,fontWeight:600})),pj=Lo.span(({color:e})=>({display:"inline-block",width:"14px",height:"14px",borderRadius:"3px",backgroundImage:`
92
+ `}),n}function MT(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function $c(e,t){let n=BT(e,t),r=n.one(e,void 0),o=PT(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 Uc(e,t){return e&&"run"in e?async function(n,r){let o=$c(n,{file:r,...t});await e.run(o,r)}:function(n,r){return $c(n,{file:r,...e||t})}}function ix(e){if(e)throw e}var Wc=Oa(jT(),1);function ka(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 sx(){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?HT(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 HT(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 Fr={basename:Z5,dirname:e6,extname:t6,join:n6,sep:"/"};function Z5(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Ca(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 e6(e){if(Ca(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 t6(e){Ca(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 n6(...e){let t=-1,n;for(;++t<e.length;)Ca(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":r6(n)}function r6(e){Ca(e);let t=e.codePointAt(0)===47,n=o6(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function o6(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 Ca(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}var WT={cwd:i6};function i6(){return"/"}function Ki(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function VT(e){if(typeof e=="string")e=new URL(e);else if(!Ki(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 s6(e)}function s6(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 ax=["history","path","basename","stem","extname","dirname"],li=class{constructor(t){let n;t?Ki(t)?n={path:t}:typeof t=="string"||a6(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":WT.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<ax.length;){let i=ax[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)ax.includes(o)||(this[o]=n[o])}get basename(){return typeof this.path=="string"?Fr.basename(this.path):void 0}set basename(t){cx(t,"basename"),lx(t,"basename"),this.path=Fr.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Fr.dirname(this.path):void 0}set dirname(t){GT(this.basename,"dirname"),this.path=Fr.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Fr.extname(this.path):void 0}set extname(t){if(lx(t,"extname"),GT(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=Fr.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Ki(t)&&(t=VT(t)),cx(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Fr.basename(this.path,this.extname):void 0}set stem(t){cx(t,"stem"),lx(t,"stem"),this.path=Fr.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 lx(e,t){if(e&&e.includes(Fr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Fr.sep+"`")}function cx(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function GT(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function a6(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var qT=(function(e){let r=this.constructor.prototype,o=r[e],i=function(){return o.apply(i,arguments)};return Object.setPrototypeOf(i,r),i});var l6={}.hasOwnProperty,gx=class e extends qT{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=sx()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let r=this.attachers[n];t.use(...r)}return t.data((0,Wc.default)(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(dx("data",this.frozen),this.namespace[t]=n,this):l6.call(this.namespace,t)&&this.namespace[t]||void 0:t?(dx("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=Hc(t),r=this.parser||this.Parser;return ux("parse",r),r(String(n),n)}process(t,n){let r=this;return this.freeze(),ux("process",this.parser||this.Parser),px("process",this.compiler||this.Compiler),n?o(void 0,n):new Promise(o);function o(i,s){let a=Hc(t),u=r.parse(a);r.run(u,a,function(l,p,g){if(l||!p||!g)return c(l);let d=p,m=r.stringify(d,g);u6(m)?g.value=m:g.result=m,c(l,g)});function c(l,p){l||!p?s(l):i?i(p):n(void 0,p)}}}processSync(t){let n=!1,r;return this.freeze(),ux("processSync",this.parser||this.Parser),px("processSync",this.compiler||this.Compiler),this.process(t,o),KT("processSync","process",n),r;function o(i,s){n=!0,ix(i),r=s}}run(t,n,r){YT(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=Hc(n);o.run(t,u,c);function c(l,p,g){let d=p||t;l?a(l):s?s(d):r(void 0,d,g)}}}runSync(t,n){let r=!1,o;return this.run(t,n,i),KT("runSync","run",r),o;function i(s,a){ix(s),o=a,r=!0}}stringify(t,n){this.freeze();let r=Hc(n),o=this.compiler||this.Compiler;return px("stringify",o),YT(t),o(t,r)}use(t,...n){let r=this.attachers,o=this.namespace;if(dx("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,Wc.default)(!0,o.settings,c.settings))}function a(c){let l=-1;if(c!=null)if(Array.isArray(c))for(;++l<c.length;){let p=c[l];i(p)}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function u(c,l){let p=-1,g=-1;for(;++p<r.length;)if(r[p][0]===c){g=p;break}if(g===-1)r.push([c,...l]);else if(l.length>0){let[d,...m]=l,C=r[g][1];ka(C)&&ka(d)&&(d=(0,Wc.default)(!0,C,d)),r[g]=[c,d,...m]}}}},fx=new gx().freeze();function ux(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function px(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function dx(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 YT(e){if(!ka(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function KT(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Hc(e){return c6(e)?e:new li(e)}function c6(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function u6(e){return typeof e=="string"||p6(e)}function p6(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var m6="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",XT=[],QT={allowDangerousHtml:!0},h6=/^(https?|ircs?|mailto|xmpp)$/i,x6=[{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 mx(e){let t=y6(e),n=b6(e);return S6(t.runSync(t.parse(n),n),e)}function y6(e){let t=e.rehypePlugins||XT,n=e.remarkPlugins||XT,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...QT}:QT;return fx().use(Mc).use(n).use(Uc,r).use(t)}function b6(e){let t=e.children||"",n=new li;return typeof t=="string"?n.value=t:(""+t,void 0),n}function S6(e,t){let n=t.allowedElements,r=t.allowElement,o=t.components,i=t.disallowedElements,s=t.skipHtml,a=t.unwrapDisallowed,u=t.urlTransform||JT;for(let l of x6)Object.hasOwn(t,l.from)&&(""+l.from+(l.to?"use `"+l.to+"` instead":"remove it")+m6+l.id,void 0);return n&&i&&void 0,va(e,c),Ph(e,{Fragment:d6,components:o,ignoreInvalidStyle:!0,jsx:g6,jsxs:f6,passKeys:!0,passNode:!0});function c(l,p,g){if(l.type==="raw"&&g&&typeof p=="number")return s?g.children.splice(p,1):g.children[p]={type:"text",value:l.value},p;if(l.type==="element"){let d;for(d in fa)if(Object.hasOwn(fa,d)&&Object.hasOwn(l.properties,d)){let m=l.properties[d],C=fa[d];(C===null||C.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,g)),d&&g&&typeof p=="number")return a&&l.children?g.children.splice(p,1,...l.children):g.children.splice(p,1),p}}}function JT(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||h6.test(e.slice(0,t))?e:""}ke();var v6=Xi.div({display:"flex",flexDirection:"column",gap:"12px"}),k6=Xi.div({display:"flex",justifyContent:"space-between",alignItems:"center"}),C6=Xi.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),T6=Xi(vn)({padding:"6px 12px",fontSize:"12px"}),I6=Xi.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:XC.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}})),F6=Xi.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),hx=()=>{let{fullPrompt:e,userRole:t,roleOverride:n}=ce(),[r,o]=w6(!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?ci.createElement(v6,null,ci.createElement(k6,null,ci.createElement(C6,null,"Full Prompt"),ci.createElement(T6,{onClick:s,disabled:r},r?"\u2713 Copied!":"\u{1F4CB} Copy")),ci.createElement(I6,null,ci.createElement(mx,null,e))):ci.createElement(F6,null,"No prompt available. Generate a prompt or run a review to see the full prompt here.")};import so,{useRef as E6}from"react";import{styled as Er}from"storybook/theming";ke();var A6=Er.div({display:"flex",flexDirection:"column",gap:"8px"}),Cde=Er.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"}}),P6=Er.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})),L6=Er.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})),Tde=Er.div(({theme:e})=>({fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:e.color.mediumdark,marginBottom:"6px",letterSpacing:"0.5px"})),ZT=Er.div(({theme:e})=>({whiteSpace:"pre-wrap",wordWrap:"break-word",fontFamily:'Monaco, Menlo, "Ubuntu Mono", monospace',fontSize:"10px","& .section-header":{fontSize:"11px",fontWeight:700,color:e.color.secondary,marginTop:"8px",marginBottom:"4px",display:"block"},"& .issue-header":{fontWeight:600,marginTop:"6px",marginBottom:"2px",display:"block"},"& .severity-critical":{color:e.color.negative||"#dc2626",fontWeight:700},"& .severity-major":{color:e.color.warning||ae,fontWeight:700},"& .severity-minor":{color:e.color.warning||"#ca8a04",fontWeight:700},"& .issue-type":{color:e.color.secondary,fontWeight:600},"& .source-tag":{color:e.base==="dark"?"#22d3ee":"#0891b2",backgroundColor:e.base==="dark"?"rgba(34, 211, 238, 0.2)":"#cffafe",padding:"2px 6px",borderRadius:"3px",fontSize:"10px",fontWeight:600},"& .field-label":{color:e.textMutedColor,fontWeight:600},"& .field-value":{color:e.color.defaultText},"& .score":{fontSize:"11px",fontWeight:700,color:e.color.positive||"#16a34a",display:"inline-block",padding:"1px 6px",backgroundColor:e.background.positive||"#dcfce7",borderRadius:"3px"},"& .score-low":{color:e.color.negative||"#dc2626",backgroundColor:e.background.negative||"#fee2e2"},"& .score-medium":{color:e.color.warning||ae,backgroundColor:e.background.warning||"#ffedd5"}})),M6=Er.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),B6=Er.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"})),D6=Er.div({fontWeight:700,fontSize:"14px",marginBottom:"4px",display:"flex",alignItems:"center",gap:"6px"}),R6=Er.div(({theme:e})=>({fontSize:"12px",opacity:.9,color:e.color.positive||"#166534"})),Ide=Er.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,marginTop:"8px",textAlign:"right"}));function z6(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 xx=()=>{let{streamingMessages:e,fullResponse:t,reviewHistory:n,currentReviewId:r,userRole:o,roleOverride:i}=ce(),s=E6(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")),g=p.length===0&&!!t;if(p.length===0&&!g)return so.createElement(M6,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 so.createElement(A6,null,l&&so.createElement(B6,null,so.createElement(D6,null,"Component Matches Design"),so.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.")),so.createElement(P6,{ref:s},d.map((m,C)=>so.createElement(L6,{key:C,role:m.role},m.role==="system"?so.createElement(ZT,null,m.content):so.createElement(ZT,{dangerouslySetInnerHTML:{__html:z6(m.content)}})))))};import fr from"react";import{styled as _o}from"storybook/theming";ke();Ne();var N6=_o.div({display:"flex",flexDirection:"column",gap:"12px"}),O6=_o.div(({theme:e})=>({display:"flex",gap:"6px",borderBottom:`2px solid ${e.appBorderColor}`,overflowX:"auto",paddingBottom:"2px"})),_6=_o.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}}}),eI=_o.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"}}),$6=_o.div(({theme:e})=>({padding:"12px",border:`1px solid ${e.appBorderColor}`,borderRadius:"6px",backgroundColor:e.background.app,minHeight:"200px",maxHeight:"400px",overflowY:"auto",scrollBehavior:"smooth"})),tI=_o.div(({theme:e})=>({fontSize:"12px",lineHeight:"1.5",whiteSpace:"pre-wrap",wordWrap:"break-word",fontFamily:'Monaco, Menlo, "Ubuntu Mono", monospace',color:e.color.defaultText,"& .section-header":{fontSize:"13px",fontWeight:700,color:e.color.secondary,marginTop:"12px",marginBottom:"6px",display:"block"},"& .issue-header":{fontWeight:600,marginTop:"10px",marginBottom:"4px",display:"block"},"& .severity-critical":{color:e.color.negative||"#dc2626",fontWeight:700},"& .severity-major":{color:e.color.warning||ae,fontWeight:700},"& .severity-minor":{color:e.color.warning||"#ca8a04",fontWeight:700},"& .issue-type":{color:e.color.secondary,fontWeight:600},"& .source-tag":{color:e.base==="dark"?"#22d3ee":"#0891b2",backgroundColor:e.base==="dark"?"rgba(34, 211, 238, 0.2)":"#cffafe",padding:"2px 6px",borderRadius:"3px",fontSize:"10px",fontWeight:600},"& .field-label":{color:e.textMutedColor,fontWeight:600},"& .field-value":{color:e.color.defaultText},"& .score":{fontSize:"14px",fontWeight:700,color:e.color.positive||"#16a34a",display:"inline-block",padding:"2px 8px",backgroundColor:e.background.positive||"#dcfce7",borderRadius:"4px"},"& .score-low":{color:e.color.negative||"#dc2626",backgroundColor:e.background.negative||"#fee2e2"},"& .score-medium":{color:e.color.warning||ae,backgroundColor:e.background.warning||"#ffedd5"}})),nI=_o.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),U6=_o.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 rI(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 j6(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 oI=()=>{let{multiModelResults:e,isReviewing:t,setActiveModelId:n,selectedModels:r,userRole:o,roleOverride:i}=ce();if((i??o)!=="admin")return null;fr.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?fr.createElement(nI,null,"No models selected. Select multiple models to compare results."):fr.createElement(N6,null,fr.createElement(O6,null,a.map(l=>{let p=ro.find(E=>E.id===l),g=c[l],m=j6(t&&g?.streamingMessages&&g.streamingMessages.length>0?g.streamingMessages[0].content||"":g?.fullResponse?g.fullResponse:""),C=l===u;if(!p)return null;let T=t&&!g?.completed;return fr.createElement(_6,{key:l,isActive:C,provider:p.provider,onClick:()=>n(l)},p.name,g&&m.issueCount>0&&fr.createElement(eI,{variant:"issues",value:m.issueCount},m.issueCount," issues"),g&&m.score!==null&&fr.createElement(eI,{variant:"score",value:m.score},"Score: ",m.score),T&&fr.createElement(U6,null))})),fr.createElement($6,null,c[u]?.streamingMessages&&c[u].streamingMessages.length>0?c[u].streamingMessages.map((l,p)=>fr.createElement(tI,{key:p,dangerouslySetInnerHTML:{__html:rI(l.content)}})):c[u]?.fullResponse?fr.createElement(tI,{dangerouslySetInnerHTML:{__html:rI(c[u].fullResponse)}}):fr.createElement(nI,null,t?`Waiting for ${ro.find(l=>l.id===u)?.name}...`:`No response yet for ${ro.find(l=>l.id===u)?.name}`)))};import We from"react";import{styled as kt}from"storybook/theming";ke();Rs();ke();import{useCallback as yx}from"react";Ne();function iI(){let{dismissIssue:e,undismissIssue:t,reviewHistory:n}=ce(),{sessionToken:r}=we(),o=yx(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=yx((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}Gl(c,!0,u,"user",r).then(l=>{l.success||y.warn("[useIssuePersistence] Dismiss server sync failed:",l.error)})},[e,o,r]),s=yx(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}Gl(u,!1,void 0,"user",r).then(c=>{c.success||y.warn("[useIssuePersistence] Undismiss server sync failed:",c.error)})},[t,o,r]);return{dismissAndSync:i,undismissAndSync:s}}import q,{useMemo as JH,useState as ZH,useEffect as e8}from"react";import{styled as it,keyframes as t8}from"storybook/theming";import ee,{useState as kx,useRef as Hj,useCallback as SI,memo as Wj}from"react";import{styled as Pe}from"storybook/theming";import ao,{useState as H6}from"react";import{styled as lo}from"storybook/theming";var W6=lo.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}),V6=lo.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=lo.h3(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.defaultText,marginTop:0,marginBottom:"12px"})),q6=lo.p(({theme:e})=>({fontSize:"13px",color:e.textMutedColor,marginBottom:"16px",lineHeight:"1.5"})),Y6=lo.label(({theme:e})=>({display:"block",fontSize:"12px",fontWeight:600,color:e.color.defaultText,marginBottom:"6px"})),K6=lo.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:ae,boxShadow:`0 0 0 3px ${e.base==="dark"?"rgba(124, 58, 237, 0.2)":"rgba(124, 58, 237, 0.1)"}`},"&::placeholder":{color:e.textMutedColor}})),X6=lo.div({display:"flex",justifyContent:"flex-end",gap:"10px"}),Q6=lo(qt)({}),J6=lo(Br)({}),sI=({isOpen:e,issueTitle:t,onConfirm:n,onCancel:r})=>{let[o,i]=H6("");if(!e)return null;let s=()=>{n(o.trim()||void 0),i("")},a=()=>{i(""),r()};return ao.createElement(W6,{onClick:c=>{c.target===c.currentTarget&&a()}},ao.createElement(V6,null,ao.createElement(G6,null,"Dismiss as False Positive"),ao.createElement(q6,null,'Mark "',t,'" as a false positive. You can optionally provide a reason for dismissing this issue.'),ao.createElement(Y6,{htmlFor:"dismiss-reason"},"Reason (optional)"),ao.createElement(K6,{id:"dismiss-reason",value:o,onChange:c=>i(c.target.value),placeholder:"e.g., This is intentional design, not an issue..."}),ao.createElement(X6,null,ao.createElement(J6,{onClick:a},"Cancel"),ao.createElement(Q6,{onClick:s},"Dismiss Issue"))))};ke();import Ae from"react";import{styled as ot}from"storybook/theming";var ze={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"},Z6=ot.div(({theme:e})=>({marginTop:6,borderRadius:e.appBorderRadius,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content,overflow:"hidden",maxWidth:340})),ej=ot.div(({theme:e})=>({padding:"6px 10px",fontSize:11,fontWeight:500,color:e.color.defaultText,borderBottom:`1px solid ${e.appBorderColor}`})),tj=ot.div({position:"relative",backgroundColor:ze.outerBg,padding:"8px 12px 24px",fontFamily:"monospace",fontSize:11}),qde=ot.div({display:"flex",justifyContent:"space-between",alignItems:"center",color:ze.dash,padding:"0 8px",height:18,fontSize:11}),Yde=ot.div({position:"absolute",color:ze.dash,fontSize:11,top:"50%",transform:"translateY(-50%)"},e=>({...e.side==="left"&&{left:8},...e.side==="right"&&{right:8}})),Kde=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%)"}})),Xde=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}})),nj=ot.div(e=>({position:"relative",backgroundColor:e.isErr?ze.errBg:ze.borderBoxBg,border:`1px solid ${e.isErr?ze.err:ze.borderBoxStroke}`,borderRadius:6,padding:0})),rj=ot.div({display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 10px",fontSize:11,color:ze.text}),oj=ot.span({fontWeight:500,fontSize:11}),Qde=ot.span({color:ze.dash}),ij=ot.div(e=>({position:"relative",backgroundColor:e.isErr?ze.errBg:ze.paddingBg,border:`1px solid ${e.isErr?ze.err:ze.paddingStroke}`,margin:"0 8px 8px",padding:"18px 28px"})),sj=ot.span({position:"absolute",top:3,left:8,fontSize:10,fontWeight:500,color:ze.text,fontStyle:"italic"}),Vc=ot.span(e=>({position:"absolute",fontSize:11,fontFamily:"monospace",color:e.isErr?ze.err:ze.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%)"}})),aj=ot.div(e=>({backgroundColor:e.isErr?ze.errBg:"#fff",border:`1.5px dashed ${e.isErr?ze.err:ze.contentStroke}`,display:"flex",alignItems:"center",justifyContent:"center",padding:"10px 20px",fontSize:11,fontFamily:"monospace",color:e.isErr?ze.err:ze.text,fontWeight:e.isErr?600:400})),lj=ot.span({position:"absolute",bottom:4,right:8,fontSize:9,color:ze.dim,fontFamily:"monospace"}),cj=ot.div({display:"flex",alignItems:"center",gap:4,fontSize:10,fontWeight:600,color:ze.ok,padding:"4px 8px 6px"}),Jde=ot.div({fontSize:11,fontWeight:600,color:ze.text,padding:"4px 12px 2px",display:"flex",alignItems:"center",gap:6}),Zde=ot.span({fontSize:12,color:ze.dim}),uj=ot.img({maxWidth:"100%",maxHeight:40,objectFit:"contain",borderRadius:2}),pj=ot.div({fontSize:9,color:ze.dim,marginTop:2}),dj=({property:e,currentValue:t,expectedValue:n,figmaContext:r,elementName:o})=>{let i=e.toLowerCase(),s=i.includes("padding"),a=i.includes("border")||i.includes("stroke")||i.includes("box-shadow"),u=i.includes("width")||i.includes("height")||i==="dimensions",c=i.includes("radius"),{figmaImageUrl:l}=ce(),p=r||{},d=!(!!r&&Object.keys(r).length>0)&&s?Sj(n):null,m=p.padding||d||{top:0,right:0,bottom:0,left:0},C=p.strokeWeight??(a?Qi(n)??0:0),T=p.width??(u?wj(n)??"\u2014":"\u2014"),E=p.height??(u?vj(n)??"\u2014":"\u2014");return Ae.createElement(Ae.Fragment,null,Ae.createElement(tj,null,Ae.createElement(nj,{isErr:a},Ae.createElement(rj,null,Ae.createElement(oj,null,"Border"),Ae.createElement("span",{style:{fontSize:11,fontFamily:"monospace",color:a?ze.err:ze.dim}},C)),Ae.createElement(ij,{isErr:s},Ae.createElement(sj,null,"Padding"),Ae.createElement(Vc,{side:"top",isErr:s},m.top),Ae.createElement(Vc,{side:"right",isErr:s},m.right),Ae.createElement(Vc,{side:"bottom",isErr:s},m.bottom),Ae.createElement(Vc,{side:"left",isErr:s},m.left),Ae.createElement(aj,{isErr:u,style:{flexDirection:"column",gap:4}},l&&Ae.createElement(uj,{src:l,alt:"Figma element"}),Ae.createElement(pj,null,T," \xD7 ",E)))),Ae.createElement(lj,null,"border-box")),Ae.createElement(cj,null,"\u2192 ",n))},aI=ot.div({backgroundColor:ze.outerBg,padding:"24px 16px 16px",display:"flex",flexDirection:"column",alignItems:"center",gap:8}),gj=ot.div({position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"12px 20px"}),bx=ot.span(e=>({fontSize:e.fSize||"42px",fontWeight:e.fWeight||"600",color:ze.text,lineHeight:1,fontFamily:'-apple-system, BlinkMacSystemFont, "Inter", sans-serif',position:"relative",zIndex:1})),fj=ot.div({position:"absolute",border:`1.5px dashed ${ze.err}`,pointerEvents:"none",zIndex:0}),mj=ot.div({position:"absolute",border:`1.5px dashed ${ze.blue}`,pointerEvents:"none",zIndex:0}),lI=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%)"}})),ege=ot.div({fontSize:12,color:ze.text,fontWeight:500,fontFamily:'-apple-system, BlinkMacSystemFont, "Inter", sans-serif'}),hj=ot.div({display:"flex",alignItems:"center",gap:6,fontSize:10,fontFamily:"monospace"}),cI=ot.span(e=>({padding:"1px 6px",borderRadius:3,fontWeight:600,fontSize:10,color:"#fff",backgroundColor:e.variant==="err"?ze.err:ze.ok})),xj=ot.div({display:"flex",alignItems:"flex-end",justifyContent:"center",gap:16,padding:"4px 0"}),uI=ot.div({display:"flex",flexDirection:"column",alignItems:"center",gap:4}),pI=ot.div(e=>({fontSize:9,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.3px",color:e.variant==="err"?ze.err:ze.ok})),dI=ot.div(e=>({fontSize:10,fontFamily:"monospace",fontWeight:600,color:e.variant==="err"?ze.err:ze.ok,textDecoration:e.variant==="err"?"line-through":"none"})),yj=ot.span({fontSize:16,color:ze.dim,paddingBottom:20}),gI=ot.div(e=>({fontSize:9,color:e.color,fontFamily:"monospace",textAlign:"center",marginTop:2}));function fI(e){return e>=800?"ExtraBold":e>=700?"Bold":e>=600?"Semibold":e>=500?"Medium":e>=400?"Regular":e>=300?"Light":"Thin"}var bj=({property:e,currentValue:t,expectedValue:n,figmaContext:r})=>{let o=r||{},i=e.toLowerCase(),s=i.includes("size"),a=i.includes("weight"),u=i.includes("lineheight")||i.includes("line-height"),c=i.includes("text")||i.includes("content"),l=i.includes("family"),p=s||u,g=o.fontSize??(s?Qi(n):14),d=o.fontWeight??(a?Qi(n):600),C=(o.lineHeight??(u?Qi(n):null))||Math.round((g||14)*1.43),T=`${Math.min(Math.max(g||14,24),48)}px`;if(p)return Ae.createElement(Ae.Fragment,null,Ae.createElement(aI,null,Ae.createElement(gj,null,Ae.createElement(mj,{style:{top:-6,left:0,right:0,bottom:-6}}),Ae.createElement(fj,{style:{top:2,left:8,right:8,bottom:2}}),Ae.createElement(lI,{color:s?ze.err:"#7b3030",side:"left"},s?t:`${g}px`),Ae.createElement(lI,{color:u?ze.err:"#7b3030",side:"right"},u?t:`${C}px`),Ae.createElement(bx,{fSize:T,fWeight:String(d||600)},"Ag")),Ae.createElement("div",{style:{display:"flex",gap:16,justifyContent:"center"}},Ae.createElement(gI,{color:ze.err},"\u2508\u2508 font-size",s?" \u2717":""),Ae.createElement(gI,{color:ze.blue},"\u2508\u2508 line-height",u?" \u2717":"")),Ae.createElement(hj,null,Ae.createElement(cI,{variant:"err"},t),Ae.createElement("span",{style:{color:ze.dim}},"\u2192"),Ae.createElement(cI,{variant:"ok"},n))));let E=a?t:String(d||600),I=a?n:E,D=Qi(t),R=Qi(n);return Ae.createElement(Ae.Fragment,null,Ae.createElement(aI,null,Ae.createElement(xj,null,Ae.createElement(uI,null,Ae.createElement(pI,{variant:"err"},"Current"),Ae.createElement(bx,{fSize:T,fWeight:a?E:String(d||600),style:{color:ze.err}},c?t:"Ag"),Ae.createElement(dI,{variant:"err"},a&&D?`${t} (${fI(D)})`:t)),Ae.createElement(yj,null,"\u2192"),Ae.createElement(uI,null,Ae.createElement(pI,{variant:"ok"},"Figma"),Ae.createElement(bx,{fSize:T,fWeight:a?I:String(d||600),style:{color:ze.ok}},c?n:"Ag"),Ae.createElement(dI,{variant:"ok"},a&&R?`${n} (${fI(R)})`:n)))))};function Sj(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 Qi(e){let t=e.match(/(\d+(?:\.\d+)?)\s*(?:px)?/);return t?parseFloat(t[1]):null}function wj(e){let t=e.match(/(\d+(?:\.\d+)?)\s*[×x]\s*(\d+(?:\.\d+)?)/);return t?parseFloat(t[1]):null}function vj(e){let t=e.match(/(\d+(?:\.\d+)?)\s*[×x]\s*(\d+(?:\.\d+)?)/);return t?parseFloat(t[2]):null}var mI=new Set(["fontSize","font-size","fontWeight","font-weight","lineHeight","line-height","letterSpacing","letter-spacing","fontFamily","font-family","textContent","text-content"]);function kj(e){if(mI.has(e))return!0;let t=e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return mI.has(t)}var hI=e=>{let t=!!e.figmaContext&&Object.keys(e.figmaContext).length>0,n=kj(e.property);return Ae.createElement(Z6,null,Ae.createElement(ej,null,"\u25BE Layer properties",t?"":" (from review)"),n?Ae.createElement(bj,{...e}):Ae.createElement(dj,{...e}))};import jr from"react";import{styled as Hr}from"storybook/theming";var Cj={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)"}},Tj=Hr.div({display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap",marginBottom:"12px"}),Ij=Hr.div(({theme:e,category:t})=>{let n=Cj[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}`}}),Fj=Hr.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}}}),Ej=Hr.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"}}),Aj=Hr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",marginLeft:"12px",paddingLeft:"12px",borderLeft:`1px solid ${e.appBorderColor}`})),Pj=Hr.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"}}),Lj=Hr.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"}}),Mj=Hr.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"}}),Bj=Hr.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}`})),Dj=Hr.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},xI=({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),g=e.generatedFix?.filePath||e.file;return jr.createElement(Tj,null,jr.createElement(Ij,{category:e.type},e.type),e.status!=="pending"&&jr.createElement(Fj,{status:e.status},e.status),n&&t&&jr.createElement(Ej,null,t),p&&jr.createElement(Aj,null,c.ai&&!l&&jr.createElement(Pj,null,c.ai),c.programmatic&&jr.createElement(Lj,null,"Pre-filter: ",c.programmatic)),a&&jr.createElement(Mj,{title:u},"Unreliable"),e.dismissed&&jr.createElement(Bj,null,"Dismissed"),i&&s&&g&&jr.createElement(Dj,null,g))};import jn from"react";import{styled as $o}from"storybook/theming";var zj=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},Nj=e=>e?typeof e=="string"?e:typeof e=="object"?JSON.stringify(e):String(e):"",Oj=$o.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"})),Sx=$o.div({display:"flex",gap:"8px",alignItems:"baseline"}),wx=$o.span(({theme:e})=>({color:e.textMutedColor,fontWeight:500,width:"60px",flexShrink:0,fontSize:"11px"})),vx=$o.span(({theme:e})=>({color:e.color.defaultText,fontFamily:"inherit",fontSize:"11px",fontWeight:500})),_j=$o(vx)(({theme:e})=>({color:e.color.negative,textDecoration:"line-through",opacity:.7})),$j=$o(vx)(({theme:e})=>({color:e.color.positive,fontWeight:600})),Uj=$o.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)"})),dj=Lo.span({display:"flex",alignItems:"center"}),sI=({value:e,isStrikethrough:t=!1})=>{let n=sj(e),r=aj(e),o=t?cj:uj;return n?$n.createElement(dj,null,$n.createElement(pj,{color:n,title:`Color: ${n}`}),$n.createElement(o,null,r)):$n.createElement(o,null,r)},aI=({property:e,currentValue:t,suggestedValue:n})=>$n.createElement(lj,null,$n.createElement(px,null,$n.createElement(dx,null,"Property"),$n.createElement(fx,{style:{fontWeight:600}},e)),t!=null&&t!==""&&$n.createElement(px,null,$n.createElement(dx,null,"Current"),$n.createElement(sI,{value:t,isStrikethrough:!0})),n!=null&&n!==""&&$n.createElement(px,null,$n.createElement(dx,null,"Expected"),$n.createElement(sI,{value:n,isStrikethrough:!1})));we();var cI=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 mj(e){if(cI.has(e))return!0;let t=e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return cI.has(t)}var hj=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"}})),wde=Ie.div({display:"flex",alignItems:"flex-start",gap:"8px",marginBottom:"12px"}),xj=Ie.div({display:"flex",alignItems:"flex-start",gap:"8px",marginBottom:"12px"}),yj=Ie.p(({theme:e})=>({flex:1,minWidth:0,margin:0,fontSize:"14px",fontWeight:400,lineHeight:"1.5",color:e.color.defaultText})),bj=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"}})),Sj=Ie.span(({theme:e,severity:t})=>({flexShrink:0,marginTop:"2px",display:"flex",alignItems:"center",color:"#94a3b8","& svg":{width:"16px",height:"16px"}})),vde=Ie.div({flex:1,minWidth:0}),kde=Ie.div({display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px",marginBottom:"6px"}),wj=Ie.div({display:"flex",alignItems:"center",gap:"12px",flexShrink:0}),mx=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"}})),vj=Ie(mx)(({theme:e})=>({"&:hover":{color:e.color.negative}})),Cde=Ie.div(({theme:e})=>({fontSize:"14px",fontWeight:500,color:e.color.defaultText,marginBottom:"4px",lineHeight:"1.5"})),Tde=Ie.div({display:"flex",gap:"6px",alignItems:"center",flexWrap:"wrap"}),kj=Ie.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,lineHeight:"1.5",marginBottom:"10px"})),Ide=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"})),Fde=Ie.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',marginTop:"4px"})),Cj=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"}})),Tj=Ie.div(({theme:e})=>({marginTop:"8px",padding:"10px",backgroundColor:e.background.app,borderRadius:"4px",borderLeft:`3px solid ${le}`})),Ij=Ie.div(({theme:e})=>({fontSize:"11px",fontWeight:600,color:le,marginBottom:"8px",display:"flex",alignItems:"center",gap:"6px"})),Fj=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"}})),Ej=Ie.span(({theme:e})=>({fontFamily:"monospace",fontWeight:600,color:e.color.defaultText})),uI=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"})),Ede=Ie.div({position:"absolute",top:"10px",right:"10px",display:"flex",alignItems:"center",gap:"2px"}),Aj=Ie(wn)({width:"24px",height:"24px",padding:0,fontSize:"12px"}),Ade=Ie(Aj)(({theme:e})=>({"&:hover":{backgroundColor:e.background.negative,color:e.color.negative}})),Pj=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}`})),pI=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"})),Lj=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}`})),Mj=Ie.div({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px"}),Bj=Ie.div(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive,display:"flex",alignItems:"center",gap:"6px","&::before":{content:'"\u{1F916}"',fontSize:"14px"}})),Dj=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})),dI=Ie.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginBottom:"8px"})),fI=Ie.details({marginBottom:"8px"}),gI=Ie.summary(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive,cursor:"pointer",userSelect:"none",marginBottom:"8px","&:hover":{opacity:.8}})),Rj=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"})),zj=Ie.div({display:"flex",gap:"8px",marginTop:"8px"}),Nj=Ie(er)(({theme:e})=>({padding:"6px 12px",fontSize:"12px",backgroundColor:e.color.positive})),Oj=Ie(Er)({padding:"6px 12px",fontSize:"12px"}),Pde=Ie(en)(({theme:e,copied:t})=>({padding:"6px 12px",fontSize:"12px",minWidth:"90px",...t?{backgroundColor:e.color.positive}:{}})),Lde=Ie.div({display:"flex",flexDirection:"column",gap:"10px",padding:"8px 0"}),_j=Ie.div({display:"flex",alignItems:"center",gap:"12px"}),$j=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)"}}})),Uj=Ie.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontStyle:"italic"})),Mde=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}}})),jj=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"})),mI=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"})),hI=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}`})),xI=Ie.div({display:"flex",flexDirection:"column",overflowX:"auto",maxHeight:"300px",overflowY:"auto"}),yI=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)"}}),bI=Ie.div(({theme:e,status:t})=>({fontSize:"12px",color:e.color.positive,fontStyle:t==="applying"?"italic":"normal",fontWeight:t==="applied"?600:400})),SI=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},Hj=e=>{switch(e){case"post-ai-validation":return"Pre-filter (programmatic)";case"ai-validation":return"Haiku AI";case"user":return"Manual";default:return"Unknown"}},Wj=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,wI=gj(({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]=gx(!1),[m,w]=gx(!1),[k,F]=gx(!1),C=fj(null),z=lI(()=>{C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{p(e.id),F(!0)},100)},[e.id,p]),R=lI(()=>{C.current&&clearTimeout(C.current),C.current=null,p(null),F(!1)},[p]),O=()=>{e.dismissed?s(e.id):d(!0)},P=x=>{i(e.id,x),d(!1)},M=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(`
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)"})),jj=$o.span({display:"flex",alignItems:"center"}),yI=({value:e,isStrikethrough:t=!1})=>{let n=zj(e),r=Nj(e),o=t?_j:$j;return n?jn.createElement(jj,null,jn.createElement(Uj,{color:n,title:`Color: ${n}`}),jn.createElement(o,null,r)):jn.createElement(o,null,r)},bI=({property:e,currentValue:t,suggestedValue:n})=>jn.createElement(Oj,null,jn.createElement(Sx,null,jn.createElement(wx,null,"Property"),jn.createElement(vx,{style:{fontWeight:600}},e)),t!=null&&t!==""&&jn.createElement(Sx,null,jn.createElement(wx,null,"Current"),jn.createElement(yI,{value:t,isStrikethrough:!0})),n!=null&&n!==""&&jn.createElement(Sx,null,jn.createElement(wx,null,"Expected"),jn.createElement(yI,{value:n,isStrikethrough:!1})));ke();var wI=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 Vj(e){if(wI.has(e))return!0;let t=e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return wI.has(t)}var Gj=Pe.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"}})),hge=Pe.div({display:"flex",alignItems:"flex-start",gap:"8px",marginBottom:"12px"}),qj=Pe.div({display:"flex",alignItems:"flex-start",gap:"8px",marginBottom:"12px"}),Yj=Pe.p(({theme:e})=>({flex:1,minWidth:0,margin:0,fontSize:"14px",fontWeight:400,lineHeight:"1.5",color:e.color.defaultText})),Kj=Pe.input(({theme:e})=>({appearance:"none",WebkitAppearance:"none",marginTop:"2px",width:"14px",height:"14px",cursor:"pointer",flexShrink:0,border:`1.5px solid ${e.color.mediumdark||"#cbd5e1"}`,borderRadius:"3px",backgroundColor:e.background.content,position:"relative",transition:"all 0.15s","&:hover":{borderColor:ae},"&:checked":{backgroundColor:ae,borderColor:ae},"&:checked::after":{content:'""',position:"absolute",left:"3px",top:"0px",width:"4px",height:"8px",border:"solid #fff",borderWidth:"0 2px 2px 0",transform:"rotate(45deg)"},"&:disabled":{opacity:.4,cursor:"not-allowed"}})),Xj=Pe.span(({theme:e,severity:t})=>({flexShrink:0,marginTop:"2px",display:"flex",alignItems:"center",color:"#94a3b8","& svg":{width:"16px",height:"16px"}})),xge=Pe.div({flex:1,minWidth:0}),yge=Pe.div({display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px",marginBottom:"6px"}),Qj=Pe.div({display:"flex",alignItems:"center",gap:"12px",flexShrink:0}),Cx=Pe.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"}})),Jj=Pe(Cx)(({theme:e})=>({"&:hover":{color:e.color.negative}})),bge=Pe.div(({theme:e})=>({fontSize:"14px",fontWeight:500,color:e.color.defaultText,marginBottom:"4px",lineHeight:"1.5"})),Sge=Pe.div({display:"flex",gap:"6px",alignItems:"center",flexWrap:"wrap"}),Zj=Pe.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,lineHeight:"1.5",marginBottom:"10px"})),wge=Pe.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"})),vge=Pe.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',marginTop:"4px"})),eH=Pe.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"}})),tH=Pe.div(({theme:e})=>({marginTop:"8px",padding:"10px",backgroundColor:e.background.app,borderRadius:"4px",borderLeft:`3px solid ${ae}`})),nH=Pe.div(({theme:e})=>({fontSize:"11px",fontWeight:600,color:ae,marginBottom:"8px",display:"flex",alignItems:"center",gap:"6px"})),rH=Pe.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"}})),oH=Pe.span(({theme:e})=>({fontFamily:"monospace",fontWeight:600,color:e.color.defaultText})),vI=Pe.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"})),kge=Pe.div({position:"absolute",top:"10px",right:"10px",display:"flex",alignItems:"center",gap:"2px"}),iH=Pe(kn)({width:"24px",height:"24px",padding:0,fontSize:"12px"}),Cge=Pe(iH)(({theme:e})=>({"&:hover":{backgroundColor:e.background.negative,color:e.color.negative}})),sH=Pe.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}`})),kI=Pe.div(({theme:e})=>({fontSize:"11px",color:e.color.negative,backgroundColor:e.background.negative,padding:"10px",borderRadius:"4px",marginTop:"10px",borderLeft:`3px solid ${e.color.negative}`,fontFamily:"monospace",lineHeight:"1.5"})),aH=Pe.div(({theme:e,compact:t})=>({marginTop:"12px",padding:t?"8px 12px":"12px",backgroundColor:e.background.positive,borderRadius:"6px",border:`1px solid ${e.color.positive}`})),lH=Pe.div({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px"}),cH=Pe.div(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive,display:"flex",alignItems:"center",gap:"6px","&::before":{content:'"\u{1F916}"',fontSize:"14px"}})),uH=Pe.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})),CI=Pe.div(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginBottom:"8px"})),TI=Pe.details({marginBottom:"8px"}),II=Pe.summary(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive,cursor:"pointer",userSelect:"none",marginBottom:"8px","&:hover":{opacity:.8}})),pH=Pe.pre(({theme:e})=>({fontSize:"11px",fontFamily:"monospace",backgroundColor:e.base==="dark"?"#1e293b":"#f8fafc",color:e.base==="dark"?"#e2e8f0":"#1e293b",padding:"10px",borderRadius:"4px",overflowX:"auto",margin:0,lineHeight:"1.5",maxHeight:"300px",overflowY:"auto"})),dH=Pe.div({display:"flex",gap:"8px",marginTop:"8px"}),gH=Pe(vn)(({theme:e})=>({padding:"6px 12px",fontSize:"12px",backgroundColor:e.color.positive})),fH=Pe(Br)({padding:"6px 12px",fontSize:"12px"}),Tge=Pe(qt)(({theme:e,copied:t})=>({padding:"6px 12px",fontSize:"12px",minWidth:"90px",...t?{backgroundColor:e.color.positive}:{}})),Ige=Pe.div({display:"flex",flexDirection:"column",gap:"10px",padding:"8px 0"}),mH=Pe.div({display:"flex",alignItems:"center",gap:"12px"}),hH=Pe.div(({theme:e})=>({width:"16px",height:"16px",border:`2px solid ${e.appBorderColor}`,borderTopColor:ae,borderRadius:"50%",animation:"spin 0.8s linear infinite","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),xH=Pe.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,fontStyle:"italic"})),Fge=Pe.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}}})),yH=Pe.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"})),FI=Pe.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"})),EI=Pe.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}`})),AI=Pe.div({display:"flex",flexDirection:"column",overflowX:"auto",maxHeight:"300px",overflowY:"auto"}),PI=Pe.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)"}}),LI=Pe.div(({theme:e,status:t})=>({fontSize:"12px",color:e.color.positive,fontStyle:t==="applying"?"italic":"normal",fontWeight:t==="applied"?600:400})),MI=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},bH=e=>{switch(e){case"post-ai-validation":return"Pre-filter (programmatic)";case"ai-validation":return"Haiku AI";case"user":return"Manual";default:return"Unknown"}},SH=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,BI=Wj(({issue:e,modelId:t,dominantDetector:n,showFilePath:r=!0,onToggleSelection:o,onDismiss:i,onUndismiss:s,onApplyFix:a,onRegenerateFix:u})=>{let{featureFlags:c,userRole:l,setHoveredIssueId:p}=ce(),[g,d]=kx(!1),[m,C]=kx(!1),[T,E]=kx(!1),I=Hj(null),D=SI(()=>{I.current&&clearTimeout(I.current),I.current=setTimeout(()=>{p(e.id),E(!0)},100)},[e.id,p]),R=SI(()=>{I.current&&clearTimeout(I.current),I.current=null,p(null),E(!1)},[p]),_=()=>{e.dismissed?s(e.id):d(!0)},P=w=>{i(e.id,w),d(!1)},z=async()=>{let w=[`**${e.title}**`,`Type: ${e.type} | Severity: ${e.severity} | Status: ${e.status}`,e.description];if(e.property&&w.push(`Property: ${e.property}`),e.currentValue&&w.push(`Current: ${e.currentValue}`),e.suggestedValue&&w.push(`Expected: ${e.suggestedValue}`),e.file&&w.push(`File: ${e.file}${e.lineNumber!==void 0?`:${e.lineNumber}`:""}`),e.relatedTo&&e.relatedTo.length>0&&w.push(`Caused by: ${e.relatedTo.join(", ")}`),e.suggestedCode&&w.push(`
99
99
  Suggested code:
100
100
  \`\`\`
101
101
  ${e.suggestedCode}
102
- \`\`\``),e.generatedFix){let E=e.generatedFix;if(x.push(`
103
- --- AI-Generated Fix ---`),x.push(`Status: ${E.status}`),E.confidence!==void 0){let h=E.confidence>1?E.confidence:Math.round(E.confidence*100);x.push(`Confidence: ${h}%`)}E.strategy&&x.push(`Strategy: ${E.strategy}`),E.filePath&&x.push(`Target file: ${E.filePath}`),E.code&&x.push(`
102
+ \`\`\``),e.generatedFix){let k=e.generatedFix;if(w.push(`
103
+ --- AI-Generated Fix ---`),w.push(`Status: ${k.status}`),k.confidence!==void 0){let f=k.confidence>1?k.confidence:Math.round(k.confidence*100);w.push(`Confidence: ${f}%`)}k.strategy&&w.push(`Strategy: ${k.strategy}`),k.filePath&&w.push(`Target file: ${k.filePath}`),k.code&&w.push(`
104
104
  Generated code:
105
105
  \`\`\`
106
- ${E.code}
107
- \`\`\``),E.diffPreview&&x.push(`
106
+ ${k.code}
107
+ \`\`\``),k.diffPreview&&w.push(`
108
108
  Diff:
109
109
  \`\`\`diff
110
- ${E.diffPreview}
111
- \`\`\``),E.error&&x.push(`Error: ${E.error}`)}let b=x.filter(Boolean).join(`
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(hj,{dismissed:!!e.dismissed,fixApplied:g,onMouseEnter:z,onMouseLeave:R},ee.createElement(xj,null,ee.createElement(bj,{type:"checkbox",checked:e.selectedForFix,onChange:()=>o(e.id),disabled:e.dismissed||e.generatedFix?.status==="failed"}),ee.createElement(Sj,{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(yj,null,e.title),ee.createElement(wj,null,ee.createElement(mx,{onClick:M,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(mx,{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(vj,{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(iI,{issue:e,modelDisplayName:Wj(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(kj,null,e.description),e.property&&ee.createElement(aI,{property:e.property,currentValue:e.currentValue,suggestedValue:e.suggestedValue}),l==="admin"&&k&&e.property&&e.currentValue&&e.suggestedValue&&mj(e.property)&&ee.createElement(oI,{property:e.property,currentValue:e.currentValue,expectedValue:e.suggestedValue,figmaContext:e.figmaContext}),e.relatedTo&&e.relatedTo.length>0&&ee.createElement(Cj,null,ee.createElement("strong",null,"Caused by:")," ",e.relatedTo.join(", ")),e.relatedProperties&&e.relatedProperties.length>0&&ee.createElement(Tj,null,ee.createElement(Ij,null,"Affected Properties (",e.relatedProperties.length,")"),e.relatedProperties.map((x,b)=>ee.createElement(Fj,{key:`${x.property}-${b}`},ee.createElement(Ej,null,x.property),ee.createElement(uI,{type:"current"},x.currentValue),ee.createElement(uI,{type:"suggested"},x.suggestedValue)))),e.dismissed&&ee.createElement(Pj,null,ee.createElement("strong",null,"Filtered by:")," ",Hj(e.dismissedBy),e.dismissReason&&ee.createElement(ee.Fragment,null,ee.createElement("br",null),"Reason: ",e.dismissReason)),e.status==="failed"&&e.error&&ee.createElement(pI,null,ee.createElement("strong",null,"Error:")," ",e.error),e.generatedFix&&ee.createElement(Lj,{compact:e.generatedFix.status==="generating"},e.generatedFix.status==="generating"?ee.createElement(_j,{style:{margin:0}},ee.createElement($j,null),ee.createElement(Uj,{style:{margin:0}},"Generating fix...")):ee.createElement(ee.Fragment,null,ee.createElement(Mj,null,ee.createElement(Bj,null,"AI-Generated Fix"),ee.createElement(Dj,{confidence:e.generatedFix.confidence},Math.round(e.generatedFix.confidence>1?e.generatedFix.confidence:e.generatedFix.confidence*100),"% confidence")),e.generatedFix.strategy&&ee.createElement(dI,null,"Strategy: ",e.generatedFix.strategy),e.generatedFix.noChangesExplanation&&ee.createElement(dI,{style:{color:"#6b7280",fontStyle:"italic"}},"Reason: ",e.generatedFix.noChangesExplanation),e.generatedFix.diffPreview?ee.createElement(fI,null,ee.createElement(gI,null,"View Diff"),ee.createElement(jj,null,ee.createElement(mI,{side:"old"},ee.createElement(hI,{side:"old"},"Old"),ee.createElement(xI,null,SI(e.generatedFix.diffPreview).map((x,b)=>ee.createElement(yI,{key:`old-${b}`,type:x.oldLine.type},x.oldLine.content||"\xA0")))),ee.createElement(mI,{side:"new"},ee.createElement(hI,{side:"new"},"New"),ee.createElement(xI,null,SI(e.generatedFix.diffPreview).map((x,b)=>ee.createElement(yI,{key:`new-${b}`,type:x.newLine.type},x.newLine.content||"\xA0")))))):e.generatedFix.code&&ee.createElement(fI,null,ee.createElement(gI,null,"View Generated Code"),ee.createElement(Rj,null,e.generatedFix.code)),e.generatedFix.status==="failed"&&e.generatedFix.error&&ee.createElement(pI,null,ee.createElement("strong",null,"Fix generation failed:")," ",e.generatedFix.error),e.generatedFix.status==="ready"&&c.enableFixApply&&a&&ee.createElement(zj,null,ee.createElement(Nj,{onClick:()=>a(e.id)},"Apply Fix"),u&&ee.createElement(Oj,{onClick:()=>u(e.id)},"Regenerate")),e.generatedFix.status==="applying"&&ee.createElement(bI,{status:"applying"},"Applying fix..."),e.generatedFix.status==="applied"&&ee.createElement(bI,{status:"applied"},"\u2713 Fix applied successfully")))),ee.createElement(YT,{isOpen:f,issueTitle:e.title,onConfirm:P,onCancel:()=>d(!1)}))});import hx from"react";import{styled as xx,keyframes as Vj}from"storybook/theming";var Gj=Vj`
110
+ ${k.diffPreview}
111
+ \`\`\``),k.error&&w.push(`Error: ${k.error}`)}let v=w.filter(Boolean).join(`
112
+ `);try{await navigator.clipboard.writeText(v),C(!0),setTimeout(()=>C(!1),2e3)}catch(k){console.error("Failed to copy:",k)}},x=e.generatedFix?.status==="applied";return ee.createElement(ee.Fragment,null,ee.createElement(Gj,{dismissed:!!e.dismissed,fixApplied:x,onMouseEnter:D,onMouseLeave:R},ee.createElement(qj,null,ee.createElement(Kj,{type:"checkbox",checked:e.selectedForFix,onChange:()=>o(e.id),disabled:e.dismissed||e.generatedFix?.status==="failed"}),ee.createElement(Xj,{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(Yj,null,e.title),ee.createElement(Qj,null,ee.createElement(Cx,{onClick:z,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(Cx,{onClick:_,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(Jj,{onClick:_,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(xI,{issue:e,modelDisplayName:SH(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(Zj,null,e.description),e.property&&ee.createElement(bI,{property:e.property,currentValue:e.currentValue,suggestedValue:e.suggestedValue}),l==="admin"&&T&&e.property&&e.currentValue&&e.suggestedValue&&Vj(e.property)&&ee.createElement(hI,{property:e.property,currentValue:e.currentValue,expectedValue:e.suggestedValue,figmaContext:e.figmaContext}),e.relatedTo&&e.relatedTo.length>0&&ee.createElement(eH,null,ee.createElement("strong",null,"Caused by:")," ",e.relatedTo.join(", ")),e.relatedProperties&&e.relatedProperties.length>0&&ee.createElement(tH,null,ee.createElement(nH,null,"Affected Properties (",e.relatedProperties.length,")"),e.relatedProperties.map((w,v)=>ee.createElement(rH,{key:`${w.property}-${v}`},ee.createElement(oH,null,w.property),ee.createElement(vI,{type:"current"},w.currentValue),ee.createElement(vI,{type:"suggested"},w.suggestedValue)))),e.dismissed&&ee.createElement(sH,null,ee.createElement("strong",null,"Filtered by:")," ",bH(e.dismissedBy),e.dismissReason&&ee.createElement(ee.Fragment,null,ee.createElement("br",null),"Reason: ",e.dismissReason)),e.status==="failed"&&e.error&&ee.createElement(kI,null,ee.createElement("strong",null,"Error:")," ",e.error),e.generatedFix&&ee.createElement(aH,{compact:e.generatedFix.status==="generating"},e.generatedFix.status==="generating"?ee.createElement(mH,{style:{margin:0}},ee.createElement(hH,null),ee.createElement(xH,{style:{margin:0}},"Generating fix...")):ee.createElement(ee.Fragment,null,ee.createElement(lH,null,ee.createElement(cH,null,"AI-Generated Fix"),ee.createElement(uH,{confidence:e.generatedFix.confidence},Math.round(e.generatedFix.confidence>1?e.generatedFix.confidence:e.generatedFix.confidence*100),"% confidence")),e.generatedFix.strategy&&ee.createElement(CI,null,"Strategy: ",e.generatedFix.strategy),e.generatedFix.noChangesExplanation&&ee.createElement(CI,{style:{fontStyle:"italic"}},"Reason: ",e.generatedFix.noChangesExplanation),e.generatedFix.diffPreview?ee.createElement(TI,null,ee.createElement(II,null,"View Diff"),ee.createElement(yH,null,ee.createElement(FI,{side:"old"},ee.createElement(EI,{side:"old"},"Old"),ee.createElement(AI,null,MI(e.generatedFix.diffPreview).map((w,v)=>ee.createElement(PI,{key:`old-${v}`,type:w.oldLine.type},w.oldLine.content||"\xA0")))),ee.createElement(FI,{side:"new"},ee.createElement(EI,{side:"new"},"New"),ee.createElement(AI,null,MI(e.generatedFix.diffPreview).map((w,v)=>ee.createElement(PI,{key:`new-${v}`,type:w.newLine.type},w.newLine.content||"\xA0")))))):e.generatedFix.code&&ee.createElement(TI,null,ee.createElement(II,null,"View Generated Code"),ee.createElement(pH,null,e.generatedFix.code)),e.generatedFix.status==="failed"&&e.generatedFix.error&&ee.createElement(kI,null,ee.createElement("strong",null,"Fix generation failed:")," ",e.generatedFix.error),e.generatedFix.status==="ready"&&c.enableFixApply&&a&&ee.createElement(dH,null,ee.createElement(gH,{onClick:()=>a(e.id)},"Apply Fix"),u&&ee.createElement(fH,{onClick:()=>u(e.id)},"Regenerate")),e.generatedFix.status==="applying"&&ee.createElement(LI,{status:"applying"},"Applying fix..."),e.generatedFix.status==="applied"&&ee.createElement(LI,{status:"applied"},"\u2713 Fix applied successfully")))),ee.createElement(sI,{isOpen:g,issueTitle:e.title,onConfirm:P,onCancel:()=>d(!1)}))});import Tx from"react";import{styled as Ix,keyframes as wH}from"storybook/theming";var vH=wH`
113
113
  0% { transform: rotate(0deg); }
114
114
  100% { transform: rotate(360deg); }
115
- `,qj=xx.div({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"32px",gap:"12px"}),Yj=xx.div(({theme:e})=>({width:"24px",height:"24px",border:`3px solid ${e.appBorderColor}`,borderTopColor:"#7c3aed",borderRadius:"50%",animation:`${Gj} 0.8s linear infinite`})),Kj=xx.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),Oc=({label:e="Loading..."})=>hx.createElement(qj,null,hx.createElement(Yj,null),hx.createElement(Kj,null,e));we();import gt,{useState as Xj,useEffect as Qj,useRef as Jj}from"react";import{styled as fn,keyframes as ya}from"storybook/theming";var Gi="#8b6cc1",Zj="rgba(139, 108, 193, 0.2)",CI="rgba(139, 108, 193, 0.15)",eH="rgba(139, 108, 193, 0.1)",tH="rgba(139, 108, 193, 0.5)",TI=ya`
115
+ `,kH=Ix.div({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"32px",gap:"12px"}),CH=Ix.div(({theme:e})=>({width:"24px",height:"24px",border:`3px solid ${e.appBorderColor}`,borderTopColor:"#7c3aed",borderRadius:"50%",animation:`${vH} 0.8s linear infinite`})),TH=Ix.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),Gc=({label:e="Loading..."})=>Tx.createElement(kH,null,Tx.createElement(CH,null),Tx.createElement(TH,null,e));ke();import ft,{useState as IH,useEffect as FH,useRef as EH}from"react";import{styled as fn,keyframes as Ta}from"storybook/theming";var Ji="#8b6cc1",AH="rgba(139, 108, 193, 0.2)",zI="rgba(139, 108, 193, 0.15)",PH="rgba(139, 108, 193, 0.1)",LH="rgba(139, 108, 193, 0.5)",NI=Ta`
116
116
  from { transform: rotate(0deg); }
117
117
  to { transform: rotate(360deg); }
118
- `,nH=ya`
118
+ `,MH=Ta`
119
119
  from { transform: rotate(0deg); }
120
120
  to { transform: rotate(-360deg); }
121
- `,rH=ya`
121
+ `,BH=Ta`
122
122
  0%, 100% { opacity: 1; transform: scale(1); }
123
123
  50% { opacity: 0.6; transform: scale(1.05); }
124
- `,oH=ya`
124
+ `,DH=Ta`
125
125
  from { opacity: 0; transform: translateY(8px); }
126
126
  to { opacity: 1; transform: translateY(0); }
127
- `,iH=ya`
127
+ `,RH=Ta`
128
128
  0%, 100% { opacity: 1; }
129
129
  50% { opacity: 0.4; }
130
- `,sH=fn.div({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"60px 20px",textAlign:"center",animation:`${oH} 0.4s ease-out`}),aH=fn.div({position:"relative",width:"80px",height:"80px",marginBottom:"32px"}),lH=fn.div({position:"absolute",inset:0,borderRadius:"50%",background:`radial-gradient(circle, ${CI} 0%, transparent 70%)`,animation:`${rH} 2s ease-in-out infinite`}),cH=fn.div({position:"absolute",inset:0,borderRadius:"50%",border:`2px solid ${Zj}`}),uH=fn.div({position:"absolute",inset:0,borderRadius:"50%",border:"2px solid transparent",borderTopColor:Gi,borderRightColor:Gi,animation:`${TI} 1.2s linear infinite`}),pH=fn.div({position:"absolute",inset:"12px",borderRadius:"50%",border:`1px solid ${CI}`}),dH=fn.div({position:"absolute",inset:"12px",borderRadius:"50%",border:"1px solid transparent",borderBottomColor:tH,animation:`${nH} 1.8s linear infinite`}),fH=fn.div({position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center"}),gH=fn.div({position:"absolute",inset:0,animation:`${TI} 3s linear infinite`}),mH=fn.div({position:"absolute",top:0,left:"50%",transform:"translate(-50%, -50%)",width:"8px",height:"8px",borderRadius:"50%",backgroundColor:Gi}),hH=()=>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"})),xH=fn.div(({theme:e})=>({fontSize:"15px",fontWeight:600,color:e.color.defaultText,letterSpacing:"-0.01em"})),yH=fn.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.textMutedColor,marginTop:"6px",maxWidth:"220px"})),bH=fn.div({display:"flex",alignItems:"center",gap:"8px",marginTop:"24px"}),yx=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:eH,color:Gi},...t==="pending"&&{backgroundColor:e.background.hoverable||"#f3f4f6",color:e.textMutedColor}})),vI=fn.div(({theme:e})=>({width:"16px",height:"1px",backgroundColor:e.appBorderColor})),kI=fn.div({width:"6px",height:"6px",borderRadius:"50%",backgroundColor:Gi,animation:`${iH} 1.5s ease-in-out infinite`}),SH=fn.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,marginTop:"16px"})),wH=()=>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"})),II=()=>{let{streamingProgress:e}=se(),t=(e||0)>25,[n,r]=Xj(0),o=Jj();return Qj(()=>(o.current=setInterval(()=>r(i=>i+1),1e3),()=>clearInterval(o.current)),[]),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(dH,null),gt.createElement(fH,null,gt.createElement(hH,null)),gt.createElement(gH,null,gt.createElement(mH,null))),gt.createElement(xH,null,"Analyzing designs"),gt.createElement(yH,null,"AI is comparing screenshots and detecting issues"),gt.createElement(bH,null,gt.createElement(yx,{variant:t?"done":"active"},t?gt.createElement(wH,null):gt.createElement(kI,null),"Screenshots"),gt.createElement(vI,null),gt.createElement(yx,{variant:t?"active":"pending"},t?gt.createElement(kI,null):null,"Analysis"),gt.createElement(vI,null),gt.createElement(yx,{variant:"pending"},"Report")),gt.createElement(SH,null,n,"s \xB7 Esc to stop"))};we();var Xde=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})),IH=it.div({display:"flex",flexDirection:"column",gap:"12px",padding:"12px"}),FH=it.div({display:"flex",gap:"8px"}),FI=it(En)({flex:1}),EH=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}})),AH=it.div({display:"flex",alignItems:"center",gap:"10px",fontSize:"12px"}),PH=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"}})),LH=it.div(({theme:e})=>({border:`1px solid ${e.appBorderColor}`,borderTop:"none",borderRadius:"0 0 8px 8px",display:"flex",flexDirection:"column"})),MH=it.div({display:"flex",alignItems:"center",gap:"2px"}),_c=it(wn)({padding:"4px 8px",fontSize:"11px",fontWeight:500}),bx=it.span(({theme:e,variant:t})=>({fontSize:"11px",fontWeight:500,color:t==="critical"?e.color.negative:t==="major"?e.color.warning:e.textMutedColor})),BH=it.span(({theme:e})=>({fontWeight:600,color:e.color.defaultText})),Jde=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"}}),DH=it.div({display:"flex",flexDirection:"column"}),RH=it.span(({theme:e})=>({fontSize:"11px",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',color:e.textMutedColor,marginLeft:"4px"})),EI=it.div(({theme:e})=>({textAlign:"center",padding:"40px 20px",color:e.textMutedColor})),AI=it.div({fontSize:"36px",marginBottom:"12px"}),PI=it.div(({theme:e})=>({fontSize:"14px",fontWeight:600,marginBottom:"6px",color:e.textMutedColor})),LI=it.div({fontSize:"12px"}),zH=TH`
130
+ `,zH=fn.div({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"60px 20px",textAlign:"center",animation:`${DH} 0.4s ease-out`}),NH=fn.div({position:"relative",width:"80px",height:"80px",marginBottom:"32px"}),OH=fn.div({position:"absolute",inset:0,borderRadius:"50%",background:`radial-gradient(circle, ${zI} 0%, transparent 70%)`,animation:`${BH} 2s ease-in-out infinite`}),_H=fn.div({position:"absolute",inset:0,borderRadius:"50%",border:`2px solid ${AH}`}),$H=fn.div({position:"absolute",inset:0,borderRadius:"50%",border:"2px solid transparent",borderTopColor:Ji,borderRightColor:Ji,animation:`${NI} 1.2s linear infinite`}),UH=fn.div({position:"absolute",inset:"12px",borderRadius:"50%",border:`1px solid ${zI}`}),jH=fn.div({position:"absolute",inset:"12px",borderRadius:"50%",border:"1px solid transparent",borderBottomColor:LH,animation:`${MH} 1.8s linear infinite`}),HH=fn.div({position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center"}),WH=fn.div({position:"absolute",inset:0,animation:`${NI} 3s linear infinite`}),VH=fn.div({position:"absolute",top:0,left:"50%",transform:"translate(-50%, -50%)",width:"8px",height:"8px",borderRadius:"50%",backgroundColor:Ji}),GH=()=>ft.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:Ji,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},ft.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"}),ft.createElement("path",{d:"M5 3v4"}),ft.createElement("path",{d:"M3 5h4"}),ft.createElement("path",{d:"M19 17v4"}),ft.createElement("path",{d:"M17 19h4"})),qH=fn.div(({theme:e})=>({fontSize:"15px",fontWeight:600,color:e.color.defaultText,letterSpacing:"-0.01em"})),YH=fn.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.textMutedColor,marginTop:"6px",maxWidth:"220px"})),KH=fn.div({display:"flex",alignItems:"center",gap:"8px",marginTop:"24px"}),Fx=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:PH,color:Ji},...t==="pending"&&{backgroundColor:e.background.hoverable||"#f3f4f6",color:e.textMutedColor}})),DI=fn.div(({theme:e})=>({width:"16px",height:"1px",backgroundColor:e.appBorderColor})),RI=fn.div({width:"6px",height:"6px",borderRadius:"50%",backgroundColor:Ji,animation:`${RH} 1.5s ease-in-out infinite`}),XH=fn.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,marginTop:"16px"})),QH=()=>ft.createElement("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"},ft.createElement("polyline",{points:"20 6 9 17 4 12"})),OI=()=>{let{streamingProgress:e}=ce(),t=(e||0)>25,[n,r]=IH(0),o=EH();return FH(()=>(o.current=setInterval(()=>r(i=>i+1),1e3),()=>clearInterval(o.current)),[]),ft.createElement(zH,null,ft.createElement(NH,null,ft.createElement(OH,null),ft.createElement(_H,null),ft.createElement($H,null),ft.createElement(UH,null),ft.createElement(jH,null),ft.createElement(HH,null,ft.createElement(GH,null)),ft.createElement(WH,null,ft.createElement(VH,null))),ft.createElement(qH,null,"Analyzing designs"),ft.createElement(YH,null,"AI is comparing screenshots and detecting issues"),ft.createElement(KH,null,ft.createElement(Fx,{variant:t?"done":"active"},t?ft.createElement(QH,null):ft.createElement(RI,null),"Screenshots"),ft.createElement(DI,null),ft.createElement(Fx,{variant:t?"active":"pending"},t?ft.createElement(RI,null):null,"Analysis"),ft.createElement(DI,null),ft.createElement(Fx,{variant:"pending"},"Report")),ft.createElement(XH,null,n,"s \xB7 Esc to stop"))};ke();var Vge=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}})),Gge=it.input(({theme:e})=>({width:"14px",height:"14px",cursor:"pointer",accentColor:ae})),n8=it.div({display:"flex",flexDirection:"column",gap:"12px",padding:"12px"}),r8=it.div({display:"flex",gap:"8px"}),_I=it(mn)({flex:1}),o8=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}})),i8=it.div({display:"flex",alignItems:"center",gap:"10px",fontSize:"12px"}),s8=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"}})),a8=it.div(({theme:e})=>({border:`1px solid ${e.appBorderColor}`,borderTop:"none",borderRadius:"0 0 8px 8px",display:"flex",flexDirection:"column"})),l8=it.div({display:"flex",alignItems:"center",gap:"2px"}),qc=it(kn)({padding:"4px 8px",fontSize:"11px",fontWeight:500}),Ex=it.span(({theme:e,variant:t})=>({fontSize:"11px",fontWeight:500,color:t==="critical"?e.color.negative:t==="major"?e.color.warning:e.textMutedColor})),c8=it.span(({theme:e})=>({fontWeight:600,color:e.color.defaultText})),qge=it.div(({theme:e})=>({display:"flex",gap:"12px",alignItems:"center",fontSize:"12px",color:e.textMutedColor})),Uo=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:ae};case"selected":return{bg:e.color.tertiary,text:ae};case"score":return{bg:e.background.positive,text:e.color.positive};case"cost":return{bg:e.background.warning,text:e.color.warning};case"timing":return{bg:e.color.tertiary,text:ae};case"tokens":return{bg:e.background.app,text:e.color.mediumdark};case"model":return{bg:e.background.app,text:e.color.mediumdark}}})();return{padding:"3px 8px",borderRadius:"10px",backgroundColor:r.bg,color:r.text,fontWeight:600,fontSize:"11px",whiteSpace:"nowrap"}}),u8=it.div({display:"flex",flexDirection:"column"}),p8=it.span(({theme:e})=>({fontSize:"11px",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',color:e.textMutedColor,marginLeft:"4px"})),$I=it.div(({theme:e})=>({textAlign:"center",padding:"40px 20px",color:e.textMutedColor})),UI=it.div({fontSize:"36px",marginBottom:"12px"}),jI=it.div(({theme:e})=>({fontSize:"14px",fontWeight:600,marginBottom:"6px",color:e.textMutedColor})),HI=it.div({fontSize:"12px"}),d8=t8`
131
131
  0% {
132
132
  transform: translateY(0) rotate(0deg) scale(1);
133
133
  opacity: 1;
@@ -139,35 +139,35 @@ ${E.diffPreview}
139
139
  transform: translateY(120px) rotate(720deg) scale(0.3);
140
140
  opacity: 0;
141
141
  }
142
- `;var Zde=it.div({position:"relative",width:"100%",height:"60px",marginBottom:"10px",overflow:"visible"}),efe=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:`${zH} 3s ease-out ${e}s forwards`,pointerEvents:"none"}));var NH=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}}})),OH=it(wn)(({theme:e})=>({marginLeft:"auto",padding:"2px 6px",fontSize:"10px",backgroundColor:e.background.hoverable,color:e.color.defaultText})),MI=it.div({display:"flex",gap:"8px",alignItems:"center",justifyContent:"flex-end"}),BI=it(er)(({theme:e})=>({padding:"6px 12px",fontSize:"12px",backgroundColor:e.color.positive})),DI=it(en)(({theme:e,copied:t})=>({padding:"6px 12px",fontSize:"12px",minWidth:"120px",...t?{backgroundColor:e.color.positive}:{}})),RI=it(en)({padding:"6px 12px",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px"}),_H=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}}),$H=it.div({display:"flex",alignItems:"center",gap:"8px",marginBottom:"6px"}),UH=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}}),jH=it.span(({theme:e})=>({fontSize:"11px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px"})),HH=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"})),WH=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},zI=({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:P=!1,applyFixesResult:M,onDismissResult:g,generationTiming:x,generationUsage:b,generationProgress:E,autoApplySupported:h=!0,hasReviewBeenRun:T=!1,isLoadingReview:I=!1,isReviewing:v=!1,selfReview:A})=>{let[L,D]=V.useState("all"),[N,S]=V.useState("all"),[j,G]=V.useState(!1),[B,J]=V.useState(!0),{includeComponentIssues:Z,setIncludeComponentIssues:oe,featureFlags:pe}=se(),ae=V.useRef(null),[qe,tt]=kH(0);CH(()=>{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(`
142
+ `;var Yge=it.div({position:"relative",width:"100%",height:"60px",marginBottom:"10px",overflow:"visible"}),Kge=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:`${d8} 3s ease-out ${e}s forwards`,pointerEvents:"none"}));var g8=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}}})),f8=it(kn)(({theme:e})=>({marginLeft:"auto",padding:"2px 6px",fontSize:"10px",backgroundColor:e.background.hoverable,color:e.color.defaultText})),WI=it.div({display:"flex",gap:"8px",alignItems:"center",justifyContent:"flex-end"}),VI=it(vn)(({theme:e})=>({padding:"6px 12px",fontSize:"12px",backgroundColor:e.color.positive})),GI=it(qt)(({theme:e,copied:t})=>({padding:"6px 12px",fontSize:"12px",minWidth:"120px",...t?{backgroundColor:e.color.positive}:{}})),qI=it(qt)({padding:"6px 12px",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px"}),m8=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}}),h8=it.div({display:"flex",alignItems:"center",gap:"8px",marginBottom:"6px"}),x8=it.span(({confidence:e,theme:t})=>{let n=e>=90?"#16a34a":e>=70?"#ca8a04":"#dc2626";return{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"10px",backgroundColor:t.base==="dark"?e>=90?"rgba(22, 163, 74, 0.18)":e>=70?"rgba(202, 138, 4, 0.18)":"rgba(220, 38, 38, 0.18)":e>=90?"#dcfce7":e>=70?"#fef9c3":"#fee2e2",color:n,fontSize:"11px",fontWeight:700}}),y8=it.span(({theme:e})=>({fontSize:"11px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px"})),b8=it.div(({theme:e})=>({color:e.color.defaultText,fontSize:"12px","& ul":{margin:"4px 0",paddingLeft:"16px"},"& li":{marginBottom:"2px"}})),Yc=it.div(({theme:e})=>({marginTop:"6px","&:first-of-type":{marginTop:0}})),Kc=it.span(({theme:e})=>({fontWeight:600,color:e.textMutedColor,fontSize:"11px"})),S8=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},YI=({issues:e,modelId:t,complianceScore:n,visualSimilarity:r,costUsd:o,reviewDurationMs:i,inputTokens:s,outputTokens:a,cacheCreationTokens:u,cacheReadTokens:c,onToggleSelection:l,onSelectAll:p,onSelectNone:g,onSelectAllFixes:d,onApplyFixes:m,onApplyFix:C,onCopyAllFixes:T,onGenerateFixes:E,onDismiss:I,onUndismiss:D,isGenerating:R=!1,isApplying:_=!1,isCopying:P=!1,applyFixesResult:z,onDismissResult:x,generationTiming:w,generationUsage:v,generationProgress:k,autoApplySupported:f=!0,hasReviewBeenRun:F=!1,isLoadingReview:S=!1,isReviewing:b=!1,selfReview:A})=>{let[L,B]=q.useState("all"),[N,h]=q.useState("all"),[j,H]=q.useState(!1),[M,X]=q.useState(!0),{includeComponentIssues:Z,setIncludeComponentIssues:me,featureFlags:xe}=ce(),oe=q.useRef(null),[Ye,be]=ZH(0);e8(()=>{if(!R){be(0);return}let ie=setInterval(()=>be(Y=>Y+1),1e3);return()=>clearInterval(ie)},[R]);let Ce=async()=>{let ie=te.map(W=>{let Me=[`[${W.severity.toUpperCase()}] ${W.title||W.description}`,`Status: ${W.status}`,W.description&&W.description!==W.title?`Description: ${W.description}`:"",W.property?`Property: ${W.property}`:"",W.currentValue?`Current: ${W.currentValue}`:"",W.suggestedValue?`Expected: ${W.suggestedValue}`:"",W.file?`File: ${W.file}${W.lineNumber!==void 0?`:${W.lineNumber}`:""}`:"",W.suggestedCode?`Suggested code: ${W.suggestedCode}`:""];if(W.generatedFix){let _e=W.generatedFix;if(Me.push(""),Me.push("--- AI-Generated Fix ---"),Me.push(`Fix Status: ${_e.status}`),_e.confidence!==void 0){let xt=_e.confidence>1?_e.confidence:Math.round(_e.confidence*100);Me.push(`Confidence: ${xt}%`)}_e.strategy&&Me.push(`Strategy: ${_e.strategy}`),_e.filePath&&Me.push(`Target file: ${_e.filePath}`),_e.code&&Me.push(`Generated code:
143
+ ${_e.code}`),_e.diffPreview&&Me.push(`Diff:
144
+ ${_e.diffPreview}`),_e.error&&Me.push(`Error: ${_e.error}`)}return Me.push(""),Me.filter(Boolean).join(`
145
145
  `)}).join(`
146
146
  ---
147
147
 
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}
148
+ `),Y=te.filter(W=>W.generatedFix?.status==="applied").length,fe=te.filter(W=>W.generatedFix?.status==="ready").length,se=Y>0||fe>0?` | Fixes: ${Y} applied, ${fe} ready`:"",O=r!==void 0?` | Similarity: ${r}%`:"",U=`Score: ${n}/100${O} | ${te.length} issues${se}
149
149
 
150
- `;try{await navigator.clipboard.writeText(U+re),G(!0),setTimeout(()=>G(!1),2e3)}catch(H){console.error("Failed to copy:",H)}};V.useEffect(()=>{M&&ae.current&&ae.current.scrollIntoView({behavior:"smooth",block:"start"})},[M]);let te=vH(()=>e.filter(re=>{let W=L==="all"||re.severity===L,Fe=N==="all"||re.status===N,me=Z||!WH(re);return W&&Fe&&me}),[e,L,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(II,null):V.createElement(EI,null,V.createElement(AI,null,T?"\u2728":"\u{1F441}\uFE0F"),V.createElement(PI,null,T?"No issues found":"No review yet"),V.createElement(LI,null,T?"This review didn't detect any issues. Great work!":'Click the "Review" button to analyze your component.')):V.createElement(IH,{"data-testid":"issues-panel"},V.createElement(FH,null,V.createElement(FI,{value:L,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(FI,{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(EH,{isOpen:B,onClick:()=>J(!B)},V.createElement(AH,null,V.createElement(PH,{isOpen:B},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(BH,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(RH,null,"in ",W):null})(),V.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},fe>0&&V.createElement(bx,{variant:"critical"},fe," critical"),vt>0&&V.createElement(bx,{variant:"major"},vt," major"),Ge>0&&V.createElement(bx,{variant:"minor"},Ge," minor"))),V.createElement(MH,{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,")"))),M&&V.createElement(NH,{ref:ae,variant:M.error||M.failed>0?"warning":"success"},M.error?V.createElement(V.Fragment,null,M.error):M.failed>0?V.createElement(V.Fragment,null,"Applied ",M.succeeded,"/",M.total," fixes. ",M.failed," failed. Run a new review to verify."):V.createElement(V.Fragment,null,"Applied ",M.total," fix",M.total!==1?"es":"","! Run a new review to verify changes."),g&&V.createElement(OH,{onClick:g},"\u2715")),Et>0&&V.createElement(MI,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(RI,{disabled:R||O||P,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(BI,{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(DI,{disabled:R||P||nt===0,copied:P,onClick:k},P?"Copied!":nt>0?`Copy ${nt} Fix${nt>1?"es":""}`:"Copy Fixes (generate first)")),A&&!R&&V.createElement(_H,{confidence:A.overallConfidence},V.createElement($H,null,V.createElement(jH,null,"AI Self-Review"),V.createElement(UH,{confidence:A.overallConfidence},A.wouldReachPerfect?"\u2713":"\u25B3"," ",A.overallConfidence,"% confidence")),V.createElement(HH,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)))))),B&&V.createElement(LH,null,te.length===0?V.createElement(EI,null,V.createElement(AI,null,"\u{1F50D}"),V.createElement(PI,null,"No issues match current filters"),V.createElement(LI,null,"Try adjusting your severity or status filters")):V.createElement(DH,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(wI,{key:U.id,issue:U,modelId:t,dominantDetector:Fe,showFilePath:!_,onToggleSelection:l,onDismiss:C,onUndismiss:z,onApplyFix:w}))})()))),Et>0&&V.createElement(MI,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(RI,{disabled:R||O||P,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(BI,{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(DI,{disabled:R||P||nt===0,copied:P,onClick:k},P?"Copied!":nt>0?`Copy ${nt} Fix${nt>1?"es":""}`:"Copy Fixes (generate first)")))};De();var VH=Ct.div({display:"flex",flexDirection:"column"}),GH=Ct.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.background.positive,borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"})),qH=Ct.span(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive})),Sx=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}}),YH=Ct.span(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginLeft:"auto"})),pfe=Ct.div(({theme:e})=>({textAlign:"center",padding:"60px 20px",color:e.textMutedColor})),dfe=Ct.div({fontSize:"48px",marginBottom:"16px"}),ffe=Ct.div(({theme:e})=>({fontSize:"16px",fontWeight:600,marginBottom:"8px",color:e.color.defaultText})),gfe=Ct.div({fontSize:"14px",opacity:.8}),KH=Ct.div(({theme:e})=>({borderTop:`1px solid ${e.appBorderColor}`,marginTop:"8px"})),XH=Ct.div(({theme:e})=>({width:"100%",display:"flex",alignItems:"center",gap:"8px",padding:"12px 16px",backgroundColor:e.background.app,fontSize:"12px",color:e.textMutedColor})),QH=Ct(wn)({display:"flex",gap:"8px",padding:"0",fontSize:"12px"}),JH=Ct(Er)(({theme:e})=>({marginLeft:"auto",padding:"4px 10px",fontSize:"11px",color:e.color.secondary})),ZH=Ct.span(({theme:e})=>({backgroundColor:e.color.medium,color:e.textMutedColor,padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600})),eW=Ct.div(({theme:e})=>({padding:"8px 16px",backgroundColor:e.background.app})),tW=Ct.div(({theme:e})=>({padding:"12px 14px",marginBottom:"8px",backgroundColor:e.background.content,borderRadius:"6px",border:`1px solid ${e.appBorderColor}`})),nW=Ct.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px"}),rW=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}})),oW=Ct.div(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText,lineHeight:"1.4"})),iW=Ct.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,marginTop:"8px",paddingTop:"8px",borderTop:`1px solid ${e.appBorderColor}`,lineHeight:"1.4"})),sW=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}})),aW=Ct.span(({theme:e})=>({fontSize:"10px",fontWeight:600,color:e.textMutedColor,backgroundColor:e.background.hoverable,padding:"2px 6px",borderRadius:"8px"})),lW=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"},NI=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},cW=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"}}),uW=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"}})),vx=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"},pW=(e,t)=>{switch(e||vx(t)){case"post-ai-validation":return"\u2699\uFE0F";case"ai-validation":return"\u2726";case"user":return"\u{1F464}";default:return"\u2699\uFE0F"}},OI=(e,t)=>{switch(e||vx(t)){case"post-ai-validation":return"Pre-filter";case"ai-validation":return"Haiku";case"user":return"Manual";default:return"Auto"}},dW=Ct.div(({theme:e})=>({padding:"20px",margin:"20px",backgroundColor:e.background.negative,borderRadius:"8px",borderLeft:`4px solid ${e.color.negative}`})),fW=Ct.h3(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.negative,marginTop:0,marginBottom:"8px"})),gW=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"})),mW=Ct(Yx)({marginTop:"12px"}),wx=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(dW,null,$e.createElement(fW,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(gW,null,this.state.error?.message||"Unknown error",`
150
+ `;try{await navigator.clipboard.writeText(U+ie),H(!0),setTimeout(()=>H(!1),2e3)}catch(W){console.error("Failed to copy:",W)}};q.useEffect(()=>{z&&oe.current&&oe.current.scrollIntoView({behavior:"smooth",block:"start"})},[z]);let te=JH(()=>e.filter(ie=>{let Y=L==="all"||ie.severity===L,fe=N==="all"||ie.status===N,se=Z||!S8(ie);return Y&&fe&&se}),[e,L,N,Z]),Le=()=>{te.forEach(ie=>{ie.selectedForFix||l(ie.id)})},Ee=()=>{te.forEach(ie=>{ie.selectedForFix&&l(ie.id)})},pe=()=>{te.forEach(ie=>{ie.generatedFix&&ie.generatedFix.status==="ready"&&!ie.selectedForFix&&l(ie.id)})},At=te.filter(ie=>ie.selectedForFix).length,tn=te.filter(ie=>ie.severity==="critical").length,Pr=te.filter(ie=>ie.severity==="major").length,ge=te.filter(ie=>ie.severity==="minor").length,tt=te.filter(ie=>ie.generatedFix&&ie.generatedFix.status==="ready").length,he=te.filter(ie=>ie.selectedForFix&&ie.generatedFix&&ie.generatedFix.status==="ready").length;return e.length===0?S?q.createElement(Gc,{label:"Loading review..."}):b?q.createElement(OI,null):q.createElement($I,null,q.createElement(UI,null,F?"\u2728":"\u{1F441}\uFE0F"),q.createElement(jI,null,F?"No issues found":"No review yet"),q.createElement(HI,null,F?"This review didn't detect any issues. Great work!":'Click the "Review" button to analyze your component.')):q.createElement(n8,{"data-testid":"issues-panel"},q.createElement(r8,null,q.createElement(_I,{value:L,onChange:ie=>B(ie.target.value)},q.createElement("option",{value:"all"},"All Severities"),q.createElement("option",{value:"critical"},"Critical Only"),q.createElement("option",{value:"major"},"Major Only"),q.createElement("option",{value:"minor"},"Minor Only")),q.createElement(_I,{value:N,onChange:ie=>h(ie.target.value)},q.createElement("option",{value:"all"},"All Statuses"),q.createElement("option",{value:"pending"},"Pending"),q.createElement("option",{value:"applied"},"Applied"),q.createElement("option",{value:"verified"},"Verified"),q.createElement("option",{value:"failed"},"Failed"))),q.createElement("div",null,q.createElement(o8,{isOpen:M,onClick:()=>X(!M)},q.createElement(i8,null,q.createElement(s8,{isOpen:M},q.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},q.createElement("polyline",{points:"6 9 12 15 18 9"}))),q.createElement(c8,null,te.length," issues"),(()=>{if(te.length===0)return null;let ie=te.map(se=>se.generatedFix?.filePath||se.file).filter(Boolean);if(ie.length===0)return null;let Y=ie[0];return ie.every(se=>se===Y)?q.createElement(p8,null,"in ",Y):null})(),q.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},tn>0&&q.createElement(Ex,{variant:"critical"},tn," critical"),Pr>0&&q.createElement(Ex,{variant:"major"},Pr," major"),ge>0&&q.createElement(Ex,{variant:"minor"},ge," minor"))),q.createElement(l8,{onClick:ie=>ie.stopPropagation()},q.createElement(qc,{onClick:Le},"All"),q.createElement(qc,{onClick:Ee},"None"),q.createElement(qc,{onClick:Ce},j?"\u2713":"\u2398"," Copy"),tt>0&&q.createElement(qc,{onClick:pe},"Fixes (",tt,")"))),z&&q.createElement(g8,{ref:oe,variant:z.error||z.failed>0?"warning":"success"},z.error?q.createElement(q.Fragment,null,z.error):z.failed>0?q.createElement(q.Fragment,null,"Applied ",z.succeeded,"/",z.total," ","fixes. ",z.failed," failed. Run a new review to verify."):q.createElement(q.Fragment,null,"Applied ",z.total," fix",z.total!==1?"es":"","! Run a new review to verify changes."),x&&q.createElement(f8,{onClick:x},"\u2715")),At>0&&q.createElement(WI,null,w&&q.createElement(Uo,{variant:"timing"},w.durationSec,"s (",w.issueCount," ","fixes)"),v&&q.createElement(q.Fragment,null,q.createElement(Uo,{variant:"cost"},"$",v.costUsd.toFixed(3)," / \u20AA",(v.costUsd*3.65).toFixed(2)),q.createElement(Uo,{variant:"tokens",title:`Input: ${v.inputTokens.toLocaleString()} \xB7 Output: ${v.outputTokens.toLocaleString()}`},"#"," ",((v.inputTokens+v.outputTokens)/1e3).toFixed(1),"K"),q.createElement(Uo,{variant:"model",title:v.modelId},v.modelId.replace("claude-","").replace(/-\d{8}$/,""))),xe.enableFixGeneration&&E&&q.createElement(qI,{disabled:R||_||P,onClick:E},q.createElement("span",null,"\u{1F916}"),R&&k?`Generating ${k.completed}/${k.total}... (${Ye}s)`:R?`Generating... (${Ye}s)`:`Generate Fixes for ${At} Issue${At>1?"s":""}`),xe.enableFixApply&&f&&m&&q.createElement(VI,{disabled:R||_||he===0,onClick:m},_?"Applying...":R?"Generating...":he>0?`Apply ${he} Ready Fix${he>1?"es":""}`:"Apply Fixes (generate first)"),xe.enableFixApply&&!f&&T&&q.createElement(GI,{disabled:R||P||he===0,copied:P,onClick:T},P?"Copied!":he>0?`Copy ${he} Fix${he>1?"es":""}`:"Copy Fixes (generate first)")),A&&!R&&q.createElement(m8,{confidence:A.overallConfidence},q.createElement(h8,null,q.createElement(y8,null,"AI Self-Review"),q.createElement(x8,{confidence:A.overallConfidence},A.wouldReachPerfect?"\u2713":"\u25B3"," ",A.overallConfidence,"% confidence")),q.createElement(b8,null,A.variantSafety&&q.createElement(Yc,null,q.createElement(Kc,null,"Variant safety:"," "),A.variantSafety),A.gaps.length>0&&q.createElement(Yc,null,q.createElement(Kc,null,"Gaps: "),q.createElement("ul",null,A.gaps.map((ie,Y)=>q.createElement("li",{key:Y},ie)))),!A.wouldReachPerfect&&A.reasonsNotPerfect.length>0&&q.createElement(Yc,null,q.createElement(Kc,null,"Why not 100%:"," "),q.createElement("ul",null,A.reasonsNotPerfect.map((ie,Y)=>q.createElement("li",{key:Y},ie)))),A.suggestions&&A.suggestions.length>0&&q.createElement(Yc,null,q.createElement(Kc,null,"Suggestions: "),q.createElement("ul",null,A.suggestions.map((ie,Y)=>q.createElement("li",{key:Y},ie)))))),M&&q.createElement(a8,null,te.length===0?q.createElement($I,null,q.createElement(UI,null,"\u{1F50D}"),q.createElement(jI,null,"No issues match current filters"),q.createElement(HI,null,"Try adjusting your severity or status filters")):q.createElement(u8,null,(()=>{let ie={};te.forEach(U=>{let W=U.detectedBy;W&&(ie[W]=(ie[W]||0)+1)});let Y=Object.entries(ie).sort((U,W)=>W[1]-U[1])[0],fe=Y&&Y[1]>te.length/2?Y[0]:void 0,se=te.map(U=>U.generatedFix?.filePath||U.file).filter(Boolean),O=se.length>0&&se.every(U=>U===se[0]);return te.map(U=>q.createElement(BI,{key:U.id,issue:U,modelId:t,dominantDetector:fe,showFilePath:!O,onToggleSelection:l,onDismiss:I,onUndismiss:D,onApplyFix:C}))})()))),At>0&&q.createElement(WI,null,w&&q.createElement(Uo,{variant:"timing"},w.durationSec,"s (",w.issueCount," ","fixes)"),v&&q.createElement(q.Fragment,null,q.createElement(Uo,{variant:"cost"},"$",v.costUsd.toFixed(3)," / \u20AA",(v.costUsd*3.65).toFixed(2)),q.createElement(Uo,{variant:"tokens",title:`Input: ${v.inputTokens.toLocaleString()} \xB7 Output: ${v.outputTokens.toLocaleString()}`},"#"," ",((v.inputTokens+v.outputTokens)/1e3).toFixed(1),"K"),q.createElement(Uo,{variant:"model",title:v.modelId},v.modelId.replace("claude-","").replace(/-\d{8}$/,""))),xe.enableFixGeneration&&E&&q.createElement(qI,{disabled:R||_||P,onClick:E},q.createElement("span",null,"\u{1F916}"),R&&k?`Generating ${k.completed}/${k.total}... (${Ye}s)`:R?`Generating... (${Ye}s)`:`Generate Fixes for ${At} Issue${At>1?"s":""}`),xe.enableFixApply&&f&&m&&q.createElement(VI,{disabled:R||_||he===0,onClick:m},_?"Applying...":R?"Generating...":he>0?`Apply ${he} Ready Fix${he>1?"es":""}`:"Apply Fixes (generate first)"),xe.enableFixApply&&!f&&T&&q.createElement(GI,{disabled:R||P||he===0,copied:P,onClick:T},P?"Copied!":he>0?`Copy ${he} Fix${he>1?"es":""}`:"Copy Fixes (generate first)")))};Ne();var w8=kt.div({display:"flex",flexDirection:"column"}),v8=kt.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.background.positive,borderBottom:`1px solid ${e.appBorderColor}`,display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"})),k8=kt.span(({theme:e})=>({fontSize:"12px",fontWeight:600,color:e.color.positive})),Ax=kt.span(({theme:e,variant:t})=>{let n={resolved:{bg:e.background.positive,text:e.color.positive},remaining:{bg:e.background.warning,text:e.color.warning},new:{bg:e.color.tertiary,text:ae}};return{padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600,backgroundColor:n[t].bg,color:n[t].text}}),C8=kt.span(({theme:e})=>({fontSize:"11px",color:e.textMutedColor,marginLeft:"auto"})),sfe=kt.div(({theme:e})=>({textAlign:"center",padding:"60px 20px",color:e.textMutedColor})),afe=kt.div({fontSize:"48px",marginBottom:"16px"}),lfe=kt.div(({theme:e})=>({fontSize:"16px",fontWeight:600,marginBottom:"8px",color:e.color.defaultText})),cfe=kt.div({fontSize:"14px",opacity:.8}),T8=kt.div(({theme:e})=>({borderTop:`1px solid ${e.appBorderColor}`,marginTop:"8px"})),I8=kt.div(({theme:e})=>({width:"100%",display:"flex",alignItems:"center",gap:"8px",padding:"12px 16px",backgroundColor:e.background.app,fontSize:"12px",color:e.textMutedColor})),F8=kt(kn)({display:"flex",gap:"8px",padding:"0",fontSize:"12px"}),E8=kt(Br)(({theme:e})=>({marginLeft:"auto",padding:"4px 10px",fontSize:"11px",color:e.color.secondary})),A8=kt.span(({theme:e})=>({backgroundColor:e.color.medium,color:e.textMutedColor,padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600})),P8=kt.div(({theme:e})=>({padding:"8px 16px",backgroundColor:e.background.app})),L8=kt.div(({theme:e})=>({padding:"12px 14px",marginBottom:"8px",backgroundColor:e.background.content,borderRadius:"6px",border:`1px solid ${e.appBorderColor}`})),M8=kt.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px"}),B8=kt.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}})),D8=kt.div(({theme:e})=>({fontSize:"13px",fontWeight:500,color:e.color.defaultText,lineHeight:"1.4"})),R8=kt.div(({theme:e})=>({fontSize:"12px",color:e.textMutedColor,marginTop:"8px",paddingTop:"8px",borderTop:`1px solid ${e.appBorderColor}`,lineHeight:"1.4"})),z8=kt.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}})),N8=kt.span(({theme:e})=>({fontSize:"10px",fontWeight:600,color:e.textMutedColor,backgroundColor:e.background.hoverable,padding:"2px 6px",borderRadius:"8px"})),O8=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"},KI=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},_8=kt.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"}}),$8=kt.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"}})),Lx=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"},U8=(e,t)=>{switch(e||Lx(t)){case"post-ai-validation":return"\u2699\uFE0F";case"ai-validation":return"\u2726";case"user":return"\u{1F464}";default:return"\u2699\uFE0F"}},XI=(e,t)=>{switch(e||Lx(t)){case"post-ai-validation":return"Pre-filter";case"ai-validation":return"Haiku";case"user":return"Manual";default:return"Auto"}},j8=kt.div(({theme:e})=>({padding:"20px",margin:"20px",backgroundColor:e.background.negative,borderRadius:"8px",borderLeft:`4px solid ${e.color.negative}`})),H8=kt.h3(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.negative,marginTop:0,marginBottom:"8px"})),W8=kt.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"})),V8=kt(ry)({marginTop:"12px"}),Px=class extends We.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?We.createElement(j8,null,We.createElement(H8,null,"\u26A0\uFE0F Issues Panel Error"),We.createElement("p",null,"Something went wrong displaying the issues. This might happen if a fix failed or there's invalid data."),We.createElement(W8,null,this.state.error?.message||"Unknown error",`
151
151
 
152
- `,this.state.error?.stack),$e.createElement(mW,{onClick:this.handleReset},"Try Again")):this.props.children}},_I=()=>{let{currentStoryId:e}=rt(),{currentReviewId:t,isReviewing:n,reviewHistory:r,toggleIssueSelection:o,applyFixesResult:i,setApplyFixesResult:s}=se(),{dismissAndSync:a,undismissAndSync:u}=qT(),{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:P,timing:M,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]),L=$e.useMemo(()=>v.filter(W=>W.dismissed),[v]),D=$e.useMemo(()=>{let W={postAiValidation:0,aiValidation:0,user:0};for(let Fe of L)switch(Fe.dismissedBy){case"post-ai-validation":W.postAiValidation++;break;case"ai-validation":W.aiValidation++;break;default:W.user++;break}return W},[L]),N=A,S=I?.modelId||"unknown",j=A.filter(W=>W.severity==="critical").length,G=A.filter(W=>W.severity==="major").length,B=A.filter(W=>W.severity==="minor").length,J=I?Si(j,G,B):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(`
152
+ `,this.state.error?.stack),We.createElement(V8,{onClick:this.handleReset},"Try Again")):this.props.children}},QI=()=>{let{currentStoryId:e}=nt(),{currentReviewId:t,isReviewing:n,reviewHistory:r,toggleIssueSelection:o,applyFixesResult:i,setApplyFixesResult:s}=ce(),{dismissAndSync:a,undismissAndSync:u}=iI(),{loadingMapping:c}=nt(),l=!!e&&!t&&!n&&c,[p,g]=We.useState(!1),[d,m]=We.useState(!1),[C,T]=We.useState(!1),{isSupported:E,isDetecting:I}=xm(),{refreshStorybookOnly:D}=Qo(),{generateBatchFixes:R,isGenerating:_,error:P,timing:z,progress:x,usage:w,selfReview:v,lastStorybookRoot:k}=gm(),{applyFixes:f,isApplying:F}=dm({onComplete:D,storybookRoot:k}),S=r.find(Y=>Y.id===t),b=S?.issues||[],A=We.useMemo(()=>b.filter(Y=>!Y.dismissed),[b]),L=We.useMemo(()=>b.filter(Y=>Y.dismissed),[b]),B=We.useMemo(()=>{let Y={postAiValidation:0,aiValidation:0,user:0};for(let fe of L)switch(fe.dismissedBy){case"post-ai-validation":Y.postAiValidation++;break;case"ai-validation":Y.aiValidation++;break;default:Y.user++;break}return Y},[L]),N=A,h=S?.modelId||"unknown",j=A.filter(Y=>Y.severity==="critical").length,H=A.filter(Y=>Y.severity==="major").length,M=A.filter(Y=>Y.severity==="minor").length,X=S?Fi(j,H,M):void 0,Z=S?.visualSimilarity,me=S?.costUsd,xe=S?.reviewDurationMs,oe=S?.inputTokens,Ye=S?.outputTokens,be=S?.cacheCreationTokens,Ce=S?.cacheReadTokens,te=S?.parentReviewId?r.find(Y=>Y.id===S.parentReviewId):null,Le=We.useMemo(()=>{if(!te||!S)return null;let Y=new Set(te.issues.map(W=>`${W.type}:${W.property||""}:${W.description}`)),fe=new Set(N.map(W=>`${W.type}:${W.property||""}:${W.description}`)),se=te.issues.filter(W=>!fe.has(`${W.type}:${W.property||""}:${W.description}`)).length,O=N.filter(W=>Y.has(`${W.type}:${W.property||""}:${W.description}`)).length,U=N.filter(W=>!Y.has(`${W.type}:${W.property||""}:${W.description}`)).length;return{resolved:se,remaining:O,newIssues:U}},[te,S,N]),Ee=()=>{N.forEach(Y=>{Y.selectedForFix||o(Y.id)})},pe=()=>{N.forEach(Y=>{Y.selectedForFix&&o(Y.id)})},At=()=>{N.forEach(Y=>{Y.generatedFix&&Y.generatedFix.status==="ready"&&!Y.selectedForFix&&o(Y.id)})},{featureFlags:tn}=ce(),Pr=()=>{if(!tn.enableFixGeneration){y.warn("[IssuesPanel] Fix generation is disabled by feature flag");return}let Y=N.filter(fe=>fe.selectedForFix);if(Y.length===0){y.warn("[IssuesPanel] No issues selected for fix generation");return}y.debug(`[IssuesPanel] Generating fixes for ${Y.length} issue(s)`,Y),R(Y)},ge=()=>{if(!tn.enableFixApply){y.warn("[IssuesPanel] Fix apply is disabled by feature flag");return}let Y=N.filter(se=>se.selectedForFix&&se.generatedFix&&se.generatedFix.status==="ready"&&se.generatedFix.code&&se.generatedFix.filePath);if(Y.length===0){y.warn("[IssuesPanel] No issues with ready AI-generated fixes selected");return}let fe=Y.map(se=>({id:se.id,reviewId:se.reviewId,type:se.type,severity:se.severity,title:se.title,description:se.description,generatedFix:se.generatedFix,storyId:S?.storyId||""}));y.debug(`[IssuesPanel] Applying AI-generated fixes for ${fe.length} issue(s)`,fe),f(fe)},tt=Y=>{let fe=N.find(O=>O.id===Y);if(!fe){y.warn("[IssuesPanel] Issue not found:",Y);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:",Y);return}let se={id:fe.id,reviewId:fe.reviewId,type:fe.type,severity:fe.severity,title:fe.title,description:fe.description,generatedFix:fe.generatedFix,storyId:S?.storyId||""};y.debug("[IssuesPanel] Applying single AI-generated fix for issue:",se),f([se])},he=async()=>{let Y=N.filter(se=>se.selectedForFix&&se.generatedFix&&se.generatedFix.status==="ready"&&se.generatedFix.code&&se.generatedFix.filePath);if(Y.length===0){y.warn("[IssuesPanel] No issues with ready AI-generated fixes selected");return}let fe=Y.map(se=>{let O=se.generatedFix,U=[];return U.push(`// File: ${O.filePath}`),U.push(`// Issue: ${se.title||se.description}`),se.currentValue&&U.push(`// Actual: ${se.currentValue}`),se.suggestedValue&&U.push(`// Expected (Figma): ${se.suggestedValue}`),O.diffPreview&&(U.push("//"),U.push("// Diff:"),O.diffPreview.split(`
153
+ `).forEach(W=>{U.push(`// ${W}`)})),U.push("//"),U.push("// Full Fixed Code:"),U.push(O.code),U.join(`
154
154
  `)}).join(`
155
155
 
156
156
  `+"=".repeat(60)+`
157
157
 
158
- `);m(!0);try{await 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=L.map(_=>[`[${_.severity.toUpperCase()}] ${_.title||_.description}`,`Phase: ${OI(_.dismissedBy,_.dismissReason)}`,_.dismissReason?`Reason: ${NI(_.dismissReason)}`:"",_.property?`Property: ${_.property}`:"",_.currentValue?`Current: ${_.currentValue}`:"",_.suggestedValue?`Expected: ${_.suggestedValue}`:""].filter(Boolean).join(`
158
+ `);m(!0);try{await ym(fe)?y.debug(`[IssuesPanel] Copied ${Y.length} fix(es) to clipboard`):y.error("[IssuesPanel] Failed to copy fixes to clipboard"),setTimeout(()=>m(!1),1500)}catch(se){y.error("[IssuesPanel] Error copying fixes:",se),m(!1)}},ie=async Y=>{Y.stopPropagation();let fe=L.map(O=>[`[${O.severity.toUpperCase()}] ${O.title||O.description}`,`Phase: ${XI(O.dismissedBy,O.dismissReason)}`,O.dismissReason?`Reason: ${KI(O.dismissReason)}`:"",O.property?`Property: ${O.property}`:"",O.currentValue?`Current: ${O.currentValue}`:"",O.suggestedValue?`Expected: ${O.suggestedValue}`:""].filter(Boolean).join(`
159
159
  `)).join(`
160
160
 
161
161
  ---
162
162
 
163
- `),me=`Filtered Issues (${L.length})
163
+ `),se=`Filtered Issues (${L.length})
164
164
  ${"=".repeat(40)}
165
165
 
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(VH,null,Be&&$e.createElement(GH,null,$e.createElement(qH,null,"\u{1F4CA} Progress:"),$e.createElement(Sx,{variant:"resolved"},"\u2705 ",Be.resolved," resolved"),$e.createElement(Sx,{variant:"remaining"},"\u23F3 ",Be.remaining," remaining"),Be.newIssues>0&&$e.createElement(Sx,{variant:"new"},"\u{1F195} ",Be.newIssues," new"),$e.createElement(YH,null,"Iteration ",I?.iterationNumber||1)),$e.createElement(wx,null,$e.createElement(zI,{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:M,generationUsage:x,hasReviewBeenRun:!!I,isLoadingReview:l,isReviewing:n,generationProgress:g,autoApplySupported:F,selfReview:b})),L.length>0&&$e.createElement(KH,null,$e.createElement(XH,null,$e.createElement(QH,{onClick:()=>f(!p)},$e.createElement("span",null,p?"\u25BC":"\u25B6"),$e.createElement("span",null,"Filtered out"),$e.createElement(ZH,null,L.length),$e.createElement(uW,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(JH,{onClick:re},w?"\u2713 Copied!":"Copy")),p&&$e.createElement(eW,null,(()=>{let W=L.reduce((_,U)=>{let H=lW(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(sW,null,_,$e.createElement(aW,null,W[_].length)),W[_].map(U=>$e.createElement(tW,{key:U.id},$e.createElement(nW,null,$e.createElement(cW,{phase:U.dismissedBy||vx(U.dismissReason)||"post-ai-validation"},pW(U.dismissedBy,U.dismissReason)," ",OI(U.dismissedBy,U.dismissReason)),$e.createElement(rW,{onClick:()=>u(U.id),title:"Restore to active issues"},"\u21A9 Restore")),$e.createElement(oW,null,"[",U.severity.toUpperCase(),"] ",U.title||U.description),U.dismissReason&&$e.createElement(iW,null,NI(U.dismissReason))))))})())))};var xW=ba.div({marginTop:"20px"}),yW=ba.div(({theme:e})=>({display:"flex",alignItems:"center",borderBottom:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),bW=ba.div({display:"flex",alignItems:"center"}),kx=ba(io)({padding:"10px 16px"}),SW=ba.div({minHeight:"200px"}),Cx=()=>{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 hW(()=>{!a&&(e==="chat"||e==="prompt")&&t("issues")},[a,e,t]),Tr.createElement(xW,null,Tr.createElement(yW,null,Tr.createElement(bW,null,a&&Tr.createElement(kx,{active:e==="prompt",onClick:()=>t("prompt")},"Prompt"),a&&Tr.createElement(kx,{active:e==="chat",onClick:()=>t("chat")},u?"Models":"Chat"),Tr.createElement(kx,{active:e==="issues",onClick:()=>t("issues")},"Issues"))),Tr.createElement(SW,null,a&&e==="chat"&&(u?Tr.createElement(GT,null):Tr.createElement(lx,null)),e==="issues"&&Tr.createElement(_I,null),a&&e==="prompt"&&Tr.createElement(ax,null)))};we();import Q,{useState as ri,useRef as Ex,useEffect as CW,useMemo as TW}from"react";import{styled as wt,useTheme as IW}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 Tx(){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 wW(e,t){try{let r={...Tx(),[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 vW(){try{localStorage.removeItem(Sa),y.debug("[FeatureFlags] Reset to defaults")}catch(e){y.error("[FeatureFlags] Failed to reset:",e)}}function Ix(e){return Tx()[e]}function kW(){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:Tx,set:wW,reset:vW,enableAll:kW,isEnabled:Ix}});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 Fx={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",{...Fx},gn.createElement("circle",{cx:"11",cy:"11",r:"8"}),gn.createElement("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})),UI=()=>gn.createElement("svg",{...Fx},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"})),jI=()=>gn.createElement("svg",{...Fx},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"}),Ax=wt.div({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",flexWrap:"wrap",gap:"8px"}),Px=wt.div({display:"flex",alignItems:"center",gap:"12px"}),va=wt.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),_fe=wt.div({display:"flex",gap:"8px"}),$fe=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}})),HI=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})),Lx=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"}})),FW=wt.img(({opacity:e=1})=>({maxWidth:"100%",maxHeight:"120px",height:"auto",display:"block",objectFit:"contain",opacity:e})),EW=wt.img({display:"block",objectFit:"contain",maxHeight:"120px",maxWidth:"100%"}),AW=wt.div({position:"relative",display:"inline-block"}),Ufe=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"}})),PW=wt.div({position:"relative",display:"inline-block"}),jfe=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})),LW=wt.img({display:"block",maxWidth:"100%",height:"auto",objectFit:"contain"}),MW=wt.img({position:"absolute",top:"0",left:"0",pointerEvents:"none"}),BW=wt.div({marginTop:"12px",display:"flex",alignItems:"center",gap:"12px"}),DW=wt.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,minWidth:"80px"})),RW=wt.input({flex:1}),Mx=wt.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px",border:`1px dashed ${e.appBorderColor}`,borderRadius:"4px"})),Hfe=wt.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),WI=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})),Bx=({isLoading:e=!1,isLoadingFigma:t=!1,isLoadingStorybook:n=!1})=>{let r=IW(),{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=Ix("enableHoverHighlight"),[R,O]=ri("side-by-side"),[P,M]=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)}};CW(()=>{E(!1)},[s]);let[v,A]=ri(null),[L,D]=ri(null),N=Ex(null),S=Ex(null),j=Ex(null),G=TW(()=>{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]),B=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(Ax,null,Q.createElement(Px,null,Q.createElement(va,null,"Screenshot Comparison"))),Q.createElement(WI,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(Ax,null,Q.createElement(Px,null,Q.createElement(va,null,"Screenshot Comparison"))),Q.createElement(WI,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(Lx,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(Mx,{style:{border:"none",padding:"16px"}},"No Figma mapping."))):!s&&!a?Q.createElement(wa,null,Q.createElement(va,null,"Screenshot Comparison"),Q.createElement(Mx,null,"No screenshots available. Run a review to capture Figma and Storybook screenshots.")):Q.createElement(wa,{ref:j},Q.createElement(Ax,null,Q.createElement(Px,null,Q.createElement(va,null,"Screenshot Comparison"))),R==="side-by-side"?Q.createElement(HI,{layout:"side-by-side"},s&&!t?Q.createElement(Wc,null,Q.createElement(Vc,null,"Figma Design"),Q.createElement(Lx,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(jI,null)),k&&Q.createElement(ka,{accent:r.color.negative,onClick:()=>T(!0),title:"Unlink Figma mapping","aria-label":"Unlink Figma mapping"},Q.createElement(UI,null))),Q.createElement(AW,null,Q.createElement(EW,{ref:S,src:s,alt:"Figma design",onLoad:B,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(Lx,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(Mx,{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(FW,{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(HI,{layout:"overlay"},Q.createElement(PW,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(LW,{ref:N,src:a,alt:"Storybook component",onLoad:J,style:{maxHeight:"200px"}}),v&&Q.createElement(MW,{src:s,alt:"Figma design overlay",style:{opacity:P,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(BW,null,Q.createElement(DW,null,"Figma Opacity:"),Q.createElement(RW,{type:"range",min:"0",max:"1",step:"0.01",value:P,onChange:oe=>M(parseFloat(oe.target.value))}),Q.createElement("span",null,Math.round(P*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 zW=Qi.div({height:"100%"}),Dx=Qi.div({marginBottom:"20px"}),VI=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"})),GI=Qi.span({fontSize:"16px",flexShrink:0}),NW=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})),qI=Qi.div({flex:1}),Rx=()=>{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 P=q(),M=localStorage.getItem("uicopilot_session_token");if(y.debug("[ReviewPanel] sessionToken exists:",!!M),y.debug("[ReviewPanel] dashboardUrl:",P),!M||!C||!z){y.error("[ReviewPanel] Missing required data for saving mapping:",{hasSessionToken:!!M,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(`${P}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${M}`},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(P){y.error("[ReviewPanel] Error saving mapping:",P)}};return Xt.createElement(zW,null,Xt.createElement(Dx,null,Xt.createElement(ih,null)),e&&Xt.createElement(VI,null,Xt.createElement(GI,null,"\u26A0\uFE0F"),Xt.createElement(qI,null,e)),d&&Xt.createElement(VI,null,Xt.createElement(GI,null,"\u26A0\uFE0F"),Xt.createElement(qI,null,"Screenshot loading error: ",d)),n?.variantMismatch&&Xt.createElement(NW,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(Dx,null,Xt.createElement(Bx,{isLoading:l,isLoadingFigma:p,isLoadingStorybook:f})),Xt.createElement(Dx,null,Xt.createElement(Cx,null)),Xt.createElement(Mi,{isOpen:r,onClose:o,onSelect:w,figmaFileUrl:i||"",projectId:s||void 0}))};we();De();Ue();pt();import{useEffect as YI,useState as OW,useRef as zx,useCallback as _W}from"react";var $W=q(),UW=2e3;function KI(){let{sessionToken:e,usageData:t,setUsageData:n}=Se(),[r,o]=OW(null),i=zx(null),s=zx(!1),a=zx(0);YI(()=>{t?.creditBalance!==void 0&&i.current===null&&(i.current=t.creditBalance)},[t?.creditBalance]);let u=_W(()=>{o(null)},[]);return YI(()=>{if(!e)return;let c=async()=>{let p=Date.now();if(s.current||p-a.current<UW){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(`${$W}/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 jW,useRef as HW}from"react";var WW=300*1e3,XI="uicopilot_feature_flags_fetched_at";function VW(){if(typeof localStorage>"u")return!1;try{let e=localStorage.getItem(XI);if(!e)return!1;let t=parseInt(e,10);return Number.isNaN(t)?!1:Date.now()-t<WW}catch{return!1}}var Nx=null,GW={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 QI(){let{setFeatureFlags:e,setUserRole:t,roleOverride:n}=se(),{sessionToken:r,resetAuth:o}=Se(),i=HW(null);jW(()=>{if(!r||r===i.current)return;if(i.current=r,VW()){y.debug("[useFeatureFlags] Cache fresh, skipping fetch");return}if(Nx){y.debug("[useFeatureFlags] Reusing in-flight fetch");return}let s=`${q()}/api/addon/flags`;Nx=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"&&rw());let c=a.role==="admin"&&n?GW[n]:u;e(c);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(c)),a.role&&localStorage.setItem("uicopilot_user_role",a.role),localStorage.setItem(XI,Date.now().toString())}catch{}}).catch(a=>{y.warn("[useFeatureFlags] Failed to fetch flags, using defaults:",a.message)}).finally(()=>{Nx=null})},[r,e,t])}we();Ue();var KW={success:"linear-gradient(135deg, #10b981 0%, #059669 100%)",warning:"linear-gradient(135deg, #f59e0b 0%, #d97706 100%)",error:"linear-gradient(135deg, #ef4444 0%, #dc2626 100%)"},XW=fr.div`
166
+ `;try{await navigator.clipboard.writeText(se+fe),T(!0),setTimeout(()=>T(!1),2e3)}catch(O){y.error("Failed to copy dismissed issues:",O)}};return We.createElement(w8,null,Le&&We.createElement(v8,null,We.createElement(k8,null,"\u{1F4CA} Progress:"),We.createElement(Ax,{variant:"resolved"},"\u2705 ",Le.resolved," resolved"),We.createElement(Ax,{variant:"remaining"},"\u23F3 ",Le.remaining," remaining"),Le.newIssues>0&&We.createElement(Ax,{variant:"new"},"\u{1F195} ",Le.newIssues," new"),We.createElement(C8,null,"Iteration ",S?.iterationNumber||1)),We.createElement(Px,null,We.createElement(YI,{issues:N,modelId:h,complianceScore:X,visualSimilarity:Z,costUsd:me,reviewDurationMs:xe,inputTokens:oe,outputTokens:Ye,cacheCreationTokens:be,cacheReadTokens:Ce,onToggleSelection:o,onSelectAll:Ee,onSelectNone:pe,onSelectAllFixes:At,onGenerateFixes:Pr,onApplyFixes:ge,onApplyFix:tt,onCopyAllFixes:he,onDismiss:a,onUndismiss:u,isGenerating:_,isApplying:F,isCopying:d,applyFixesResult:i,onDismissResult:()=>s(null),generationTiming:z,generationUsage:w,hasReviewBeenRun:!!S,isLoadingReview:l,isReviewing:n,generationProgress:x,autoApplySupported:E,selfReview:v})),L.length>0&&We.createElement(T8,null,We.createElement(I8,null,We.createElement(F8,{onClick:()=>g(!p)},We.createElement("span",null,p?"\u25BC":"\u25B6"),We.createElement("span",null,"Filtered out"),We.createElement(A8,null,L.length),We.createElement($8,null,B.postAiValidation>0&&We.createElement("span",null,"\u2699\uFE0F ",B.postAiValidation),B.aiValidation>0&&We.createElement("span",null,"\u2726 ",B.aiValidation),B.user>0&&We.createElement("span",null,"\u{1F464} ",B.user))),We.createElement(E8,{onClick:ie},C?"\u2713 Copied!":"Copy")),p&&We.createElement(P8,null,(()=>{let Y=L.reduce((O,U)=>{let W=O8(U.dismissReason);return O[W]||(O[W]=[]),O[W].push(U),O},{}),fe=["HUG/FILL Sizing","Sub-pixel Differences","Values Match","No Fix Needed","Other"];return Object.keys(Y).sort((O,U)=>fe.indexOf(O)-fe.indexOf(U)).map(O=>We.createElement(We.Fragment,{key:O},We.createElement(z8,null,O,We.createElement(N8,null,Y[O].length)),Y[O].map(U=>We.createElement(L8,{key:U.id},We.createElement(M8,null,We.createElement(_8,{phase:U.dismissedBy||Lx(U.dismissReason)||"post-ai-validation"},U8(U.dismissedBy,U.dismissReason)," ",XI(U.dismissedBy,U.dismissReason)),We.createElement(B8,{onClick:()=>u(U.id),title:"Restore to active issues"},"\u21A9 Restore")),We.createElement(D8,null,"[",U.severity.toUpperCase(),"] ",U.title||U.description),U.dismissReason&&We.createElement(R8,null,KI(U.dismissReason))))))})())))};var q8=Ia.div({marginTop:"20px"}),Y8=Ia.div(({theme:e})=>({display:"flex",alignItems:"center",borderBottom:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),K8=Ia.div({display:"flex",alignItems:"center"}),Mx=Ia(mo)({padding:"10px 16px"}),X8=Ia.div({minHeight:"200px"}),Bx=()=>{let{reviewDetailTab:e,setReviewDetailTab:t,multiModelResults:n,selectedModels:r,userRole:o,roleOverride:i}=ce(),a=(i??o)==="admin",u=r.length>1||n&&Object.keys(n.byModel).length>1;return G8(()=>{!a&&(e==="chat"||e==="prompt")&&t("issues")},[a,e,t]),Ar.createElement(q8,null,Ar.createElement(Y8,null,Ar.createElement(K8,null,a&&Ar.createElement(Mx,{active:e==="prompt",onClick:()=>t("prompt")},"Prompt"),a&&Ar.createElement(Mx,{active:e==="chat",onClick:()=>t("chat")},u?"Models":"Chat"),Ar.createElement(Mx,{active:e==="issues",onClick:()=>t("issues")},"Issues"))),Ar.createElement(X8,null,a&&e==="chat"&&(u?Ar.createElement(oI,null):Ar.createElement(xx,null)),e==="issues"&&Ar.createElement(QI,null),a&&e==="prompt"&&Ar.createElement(hx,null)))};ke();import V,{useState as co,useRef as Ox,useEffect as eW,useMemo as tW}from"react";import{styled as wt,useTheme as nW}from"storybook/theming";je();Ne();var Xc={enableIssueTracking:!1,enableAutoFix:!1,enableFileModification:!1,enableMultiModelComparison:!0,enableBulkFixApplication:!1,enableFixUndo:!1,enableHoverHighlight:!0,enableEvaluationFixtures:!1,enableDebugMode:!1},Fa="uicopilot_feature_flags";function Dx(){try{let e=localStorage.getItem(Fa);if(e){let t=JSON.parse(e);return{...Xc,...t}}}catch(e){y.warn("[FeatureFlags] Failed to load from localStorage:",e)}return Xc}function Q8(e,t){try{let r={...Dx(),[e]:t},o={};for(let i in r){let s=i;r[s]!==Xc[s]&&(o[s]=r[s])}Object.keys(o).length>0?localStorage.setItem(Fa,JSON.stringify(o)):localStorage.removeItem(Fa),y.debug(`[FeatureFlags] Set ${e} = ${t}`)}catch(n){y.error("[FeatureFlags] Failed to set flag:",n)}}function J8(){try{localStorage.removeItem(Fa),y.debug("[FeatureFlags] Reset to defaults")}catch(e){y.error("[FeatureFlags] Failed to reset:",e)}}function Rx(e){return Dx()[e]}function Z8(){let e=Object.keys(Xc).reduce((t,n)=>({...t,[n]:!0}),{});try{localStorage.setItem(Fa,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:Dx,set:Q8,reset:J8,enableAll:Z8,isEnabled:Rx}});Ne();lt();import Et from"react";var JI=()=>Et.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"},Et.createElement("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),Et.createElement("circle",{cx:"12",cy:"12",r:"3"}));var Ea={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"},Qc=()=>Et.createElement("svg",{...Ea},Et.createElement("circle",{cx:"11",cy:"11",r:"8"}),Et.createElement("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})),ZI=()=>Et.createElement("svg",{...Ea},Et.createElement("path",{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07l-1.71 1.71"}),Et.createElement("path",{d:"M5.17 11.75l-1.71 1.71a5 5 0 0 0 7.07 7.07l1.71-1.71"}),Et.createElement("line",{x1:"8",y1:"2",x2:"8",y2:"5"}),Et.createElement("line",{x1:"2",y1:"8",x2:"5",y2:"8"}),Et.createElement("line",{x1:"16",y1:"22",x2:"16",y2:"19"}),Et.createElement("line",{x1:"22",y1:"16",x2:"19",y2:"16"})),eF=()=>Et.createElement("svg",{...Ea},Et.createElement("polyline",{points:"23 4 23 10 17 10"}),Et.createElement("polyline",{points:"1 20 1 14 7 14"}),Et.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"})),zx=()=>Et.createElement("svg",{...Ea},Et.createElement("circle",{cx:"11",cy:"11",r:"8"}),Et.createElement("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),Et.createElement("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),Et.createElement("line",{x1:"8",y1:"11",x2:"14",y2:"11"})),Nx=()=>Et.createElement("svg",{...Ea},Et.createElement("circle",{cx:"11",cy:"11",r:"8"}),Et.createElement("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),Et.createElement("line",{x1:"8",y1:"11",x2:"14",y2:"11"}));var Aa=wt.div({marginTop:"20px"}),_x=wt.div({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",flexWrap:"wrap",gap:"8px"}),$x=wt.div({display:"flex",alignItems:"center",gap:"12px"}),Pa=wt.div(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),Dfe=wt.div({display:"flex",gap:"8px"}),Rfe=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}})),tF=wt.div(({theme:e,layout:t})=>({display:t==="side-by-side"?"grid":"flex",gridTemplateColumns:t==="side-by-side"?"minmax(0, 1fr) minmax(0, 1fr)":void 0,gap:t==="side-by-side"?`${e.layoutMargin}px`:0,position:"relative",width:"100%",justifyContent:t==="overlay"?"center":void 0})),Jc=wt.div(({theme:e,zoomed:t})=>({position:"relative",border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,overflow:"hidden",backgroundColor:e.background.app,minHeight:"60px",maxHeight:t?"400px":"150px",display:"flex",alignItems:"center",justifyContent:"center",transition:"max-height 0.2s ease, box-shadow 0.2s ease",boxShadow:t?"0 8px 30px rgba(0, 0, 0, 0.15)":"none","& img":t?{maxWidth:"100%",maxHeight:"400px"}:void 0})),Zc=wt.div(({theme:e})=>({position:"absolute",top:"6px",left:"6px",backgroundColor:e.base==="dark"?"rgba(255, 255, 255, 0.92)":"rgba(0, 0, 0, 0.7)",color:e.base==="dark"?"#0a0a0f":e.color.inverseText,padding:"3px 6px",borderRadius:"3px",fontSize:"10px",fontWeight:600,zIndex:10})),eu=wt.div({position:"absolute",top:"6px",right:"6px",display:"flex",gap:"4px",zIndex:10}),ui=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"}})),rW=wt.img(({opacity:e=1})=>({maxWidth:"150px",maxHeight:"150px",height:"auto",display:"block",objectFit:"contain",opacity:e})),oW=wt.img({display:"block",objectFit:"contain",maxHeight:"150px",maxWidth:"150px"}),iW=wt.div({position:"relative",display:"inline-block",maxHeight:"150px",overflow:"hidden"}),zfe=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"}})),sW=wt.div({position:"relative",display:"inline-block"}),Nfe=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"}),lW=wt.img({position:"absolute",top:"0",left:"0",pointerEvents:"none"}),cW=wt.div({marginTop:"12px",display:"flex",alignItems:"center",gap:"12px"}),uW=wt.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,minWidth:"80px"})),pW=wt.input({flex:1}),Ux=wt.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px",border:`1px dashed ${e.appBorderColor}`,borderRadius:"4px"})),Ofe=wt.div(({theme:e})=>({padding:"40px",textAlign:"center",color:e.color.mediumdark,fontSize:"13px"})),nF=wt.div({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"}),Zi=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%"}}})),es=wt.div({textAlign:"center",zIndex:1}),ts=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)"}}})),ns=wt.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,fontWeight:500})),jx=({isLoading:e=!1,isLoadingFigma:t=!1,isLoadingStorybook:n=!1})=>{let r=nW(),{currentMapping:o,loadingMapping:i}=nt(),{figmaImageUrl:s,storybookImageUrl:a,figmaDimensions:u,setFigmaImageUrl:c,hoveredIssueId:l,reviewHistory:p,currentReviewId:g}=ce(),{selectedProjectId:d}=Je(),{sessionToken:m}=we(),{openComponentBrowser:C}=$s(),{hasMapping:T,deleteMapping:E,setCurrentMapping:I}=Zo(),D=Rx("enableHoverHighlight"),[R,_]=co("side-by-side"),[P,z]=co(.5),[x,w]=co(!1),[v,k]=co(!1),[f,F]=co(!1),[S,b]=co(!1),[A,L]=co(!1),B=async()=>{F(!1);try{let be=o?.id;be&&await E(be),I(null)}catch(be){y.error("[ScreenshotComparison] Failed to unlink:",be)}};eW(()=>{k(!1)},[s]);let[N,h]=co(null),[j,H]=co(null),M=Ox(null),X=Ox(null),Z=Ox(null),me=tW(()=>{if(!D||!l||!g)return null;let be=p.find(Ce=>Ce.id===g);return be?.issues&&be.issues.find(Ce=>Ce.id===l)||null},[l,g,p]),xe=be=>{let Ce=be.currentTarget;k(!0),!dt.getState().figmaDimensions&&Ce.naturalWidth&&Ce.naturalHeight&&dt.getState().setFigmaDimensions({width:Ce.naturalWidth,height:Ce.naturalHeight}),requestAnimationFrame(()=>{if(X.current){let{clientWidth:Le,clientHeight:Ee}=X.current;Le&&Ee&&H({width:Le,height:Ee})}})},oe=()=>{requestAnimationFrame(()=>{if(M.current){let{clientWidth:be,clientHeight:Ce}=M.current;be&&Ce&&h({width:be,height:Ce})}})},Ye=async()=>{if(!(!d||!m)){w(!0);try{let be=G();await ne(`${be}/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(be){y.error("Failed to refresh Figma:",be)}finally{w(!1)}}};return e?V.createElement(Aa,null,V.createElement(_x,null,V.createElement($x,null,V.createElement(Pa,null,"Screenshot Comparison"))),V.createElement(nF,null,V.createElement(Zi,null,V.createElement(es,null,V.createElement(ts,null),V.createElement(ns,null,"Loading Figma..."))),V.createElement(Zi,null,V.createElement(es,null,V.createElement(ts,null),V.createElement(ns,null,"Loading Storybook..."))))):!s&&!a&&!o?i?V.createElement(Aa,null,V.createElement(_x,null,V.createElement($x,null,V.createElement(Pa,null,"Screenshot Comparison"))),V.createElement(nF,null,V.createElement(Zi,null,V.createElement(es,null,V.createElement(ts,null),V.createElement(ns,null,"Loading..."))))):V.createElement(Aa,null,V.createElement(Pa,null,"Screenshot Comparison"),V.createElement(Jc,null,V.createElement(Zc,null,"Figma Design"),V.createElement(eu,null,V.createElement(ui,{accent:r.color.secondary,onClick:C,disabled:!d,title:"Browse Figma to map this component","aria-label":"Browse Figma to map this component"},V.createElement(Qc,null))),V.createElement(Ux,{style:{border:"none",padding:"20px 16px",lineHeight:"1.6"}},V.createElement("div",{style:{fontSize:"14px",marginBottom:"6px"}},"\u2728 This story isn't linked to a Figma frame yet"),V.createElement("div",{style:{fontSize:"12px",opacity:.75}},"Click the \u{1F50D} above to browse your Figma file and pick a matching frame. Once linked, run a Review to compare your code with the design.")))):!s&&!a?V.createElement(Aa,null,V.createElement(Pa,null,"Screenshot Comparison"),V.createElement(Ux,{style:{lineHeight:"1.6"}},V.createElement("div",{style:{fontSize:"14px",marginBottom:"6px"}},"\u{1F440} Ready to compare"),V.createElement("div",{style:{fontSize:"12px",opacity:.75}},"Click the ",V.createElement("strong",null,"Review")," button above to capture both the Figma frame and your Storybook component, then check for differences."))):V.createElement(Aa,{ref:Z},V.createElement(_x,null,V.createElement($x,null,V.createElement(Pa,null,"Screenshot Comparison"))),R==="side-by-side"?V.createElement(tF,{layout:"side-by-side"},o&&s&&!t?V.createElement(Jc,{zoomed:S},V.createElement(Zc,null,"Figma Design"),V.createElement(eu,null,V.createElement(ui,{accent:r.color.secondary,onClick:()=>b(be=>!be),title:S?"Shrink preview":"Enlarge preview","aria-label":S?"Shrink preview":"Enlarge preview"},S?V.createElement(Nx,null):V.createElement(zx,null)),T&&V.createElement(ui,{accent:r.color.secondary,onClick:C,title:"Browse Figma \u2014 change mapping","aria-label":"Browse Figma"},V.createElement(Qc,null)),V.createElement(ui,{accent:r.color.positive,onClick:Ye,disabled:x,title:"Refresh Figma cache and reload image","aria-label":"Refresh Figma cache"},V.createElement(eF,null)),T&&V.createElement(ui,{accent:r.color.negative,onClick:()=>F(!0),title:"Unlink Figma mapping","aria-label":"Unlink Figma mapping"},V.createElement(ZI,null))),V.createElement(iW,null,V.createElement(oW,{ref:X,src:s,alt:"Figma design",onLoad:xe,style:{opacity:v?1:0,transition:"opacity 150ms ease-in"}}))):!o&&!i?V.createElement(Jc,null,V.createElement(Zc,null,"Figma Design"),V.createElement(eu,null,V.createElement(ui,{accent:r.color.secondary,onClick:C,disabled:!d,title:"Browse Figma to map this component","aria-label":"Browse Figma to map this component"},V.createElement(Qc,null))),V.createElement(Ux,{style:{border:"none",padding:"16px"}},"No Figma mapping.")):V.createElement(Zi,null,V.createElement(es,null,V.createElement(ts,null),V.createElement(ns,null,t?"Refreshing Figma...":"Loading Figma..."))),a&&!n?V.createElement(Jc,{zoomed:A},V.createElement(Zc,null,"Storybook Component"),V.createElement(eu,null,V.createElement(ui,{accent:r.color.secondary,onClick:()=>L(be=>!be),title:A?"Shrink preview":"Enlarge preview","aria-label":A?"Shrink preview":"Enlarge preview"},A?V.createElement(Nx,null):V.createElement(zx,null))),V.createElement(rW,{ref:M,src:a,alt:"Storybook component",onLoad:oe})):V.createElement(Zi,null,V.createElement(es,null,V.createElement(ts,null),V.createElement(ns,null,n?"Refreshing Storybook...":"Loading Storybook...")))):V.createElement(V.Fragment,null,V.createElement(tF,{layout:"overlay"},V.createElement(sW,null,s&&a?V.createElement(V.Fragment,null,V.createElement("div",{style:{position:"relative",display:"inline-block",border:"1px solid #ccc",borderRadius:"4px",overflow:"hidden"}},V.createElement(aW,{ref:M,src:a,alt:"Storybook component",onLoad:oe,style:{maxHeight:"150px"}}),N&&V.createElement(lW,{src:s,alt:"Figma design overlay",style:{opacity:P,width:N.width,height:N.height,objectFit:"fill"}})),V.createElement("div",{style:{fontSize:"10px",color:r.color.mediumdark,marginTop:"8px",textAlign:"center"}},V.createElement("span",{style:{color:"#1ea7fd"}},"Storybook (base)")," + ",V.createElement("span",{style:{color:"#667eea"}},"Figma (overlay)"),N&&` \u2022 ${N.width}\xD7${N.height}px`)):V.createElement(Zi,null,V.createElement(es,null,V.createElement(ts,null),V.createElement(ns,null,"Loading Images..."))))),a&&s&&V.createElement(cW,null,V.createElement(uW,null,"Figma Opacity:"),V.createElement(pW,{type:"range",min:"0",max:"1",step:"0.01",value:P,onChange:be=>z(parseFloat(be.target.value))}),V.createElement("span",null,Math.round(P*100),"%"))),V.createElement(Nr,{isOpen:f,title:"Unlink Figma Mapping",message:"Unlink this story from its Figma mapping?",confirmLabel:"Unlink",variant:"danger",onConfirm:B,onCancel:()=>F(!1)}))};ke();lt();var dW=rs.div({height:"100%"}),Hx=rs.div({marginBottom:"20px"}),rF=rs.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"})),oF=rs.span({fontSize:"16px",flexShrink:0}),gW=rs.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})),iF=rs.div({flex:1}),Wx=()=>{let{reviewError:e,getCurrentReview:t}=ce(),n=t(),{showComponentBrowser:r,closeComponentBrowser:o,figmaFileUrl:i}=$s(),{selectedProjectId:s}=Zr(),{setCurrentMapping:a}=Zo(),{currentStoryId:u,currentStoryName:c}=nt(),{isLoadingScreenshots:l,isLoadingFigma:p,isLoadingStorybook:g,screenshotError:d,setFigmaImageDirect:m}=Qo(),C=async T=>{y.debug("[ReviewPanel] handleSelectFrame CALLED with frame:",T),y.debug("[ReviewPanel] frame.id:",T?.id);let E=dt.getState(),I=E.selectedProjectId,D=E.currentStoryId,R=E.currentStoryName,_=E.figmaFileUrl;y.debug("[ReviewPanel] selectedProjectId (from store):",I),y.debug("[ReviewPanel] currentStoryId (from store):",D),y.debug("[ReviewPanel] currentStoryName (from store):",R),T.thumbnail&&D&&(y.debug("[ReviewPanel] Setting Figma image directly BEFORE mapping save (instant display)"),m(D,T.id,T.thumbnail));try{let P=G(),z=localStorage.getItem("uicopilot_session_token");if(y.debug("[ReviewPanel] sessionToken exists:",!!z),y.debug("[ReviewPanel] dashboardUrl:",P),!z||!I||!D){y.error("[ReviewPanel] Missing required data for saving mapping:",{hasSessionToken:!!z,selectedProjectId:I,currentStoryId:D});return}let x=_?.match(/\/file\/([^\/]+)/)?.[1]||void 0;y.debug("[ReviewPanel] Making POST to /api/mappings with:",{projectId:I,storyId:D,name:R,figmaNodeId:T.id,figmaFileKey:x});let w=await ne(`${P}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${z}`},body:JSON.stringify({projectId:I,storyId:D,name:R,figmaNodeId:T.id,figmaFileKey:x})});if(w.ok){let v=await w.json();v.mapping&&(a(v.mapping),T.thumbnail||(y.debug("[ReviewPanel] No thumbnail available, triggering fetch"),dt.getState().triggerScreenshotRefresh()),y.debug("[ReviewPanel] Mapping saved successfully:",v.mapping))}else{let v=await w.text();y.error("[ReviewPanel] Failed to save mapping:",v)}}catch(P){y.error("[ReviewPanel] Error saving mapping:",P)}};return Xt.createElement(dW,null,Xt.createElement(Hx,null,Xt.createElement(fh,null)),e&&Xt.createElement(rF,null,Xt.createElement(oF,null,"\u26A0\uFE0F"),Xt.createElement(iF,null,e)),d&&Xt.createElement(rF,null,Xt.createElement(oF,null,"\u26A0\uFE0F"),Xt.createElement(iF,null,"Screenshot loading error: ",d)),n?.variantMismatch&&Xt.createElement(gW,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(Hx,null,Xt.createElement(jx,{isLoading:l,isLoadingFigma:p,isLoadingStorybook:g})),Xt.createElement(Hx,null,Xt.createElement(Bx,null)),Xt.createElement(_i,{isOpen:r,onClose:o,onSelect:C,figmaFileUrl:i||"",projectId:s||void 0}))};ke();Ne();je();lt();import{useEffect as sF,useState as fW,useRef as Vx,useCallback as mW}from"react";var hW=G(),xW=2e3;function aF(){let{sessionToken:e,usageData:t,setUsageData:n}=we(),[r,o]=fW(null),i=Vx(null),s=Vx(!1),a=Vx(0);sF(()=>{t?.creditBalance!==void 0&&i.current===null&&(i.current=t.creditBalance)},[t?.creditBalance]);let u=mW(()=>{o(null)},[]);return sF(()=>{if(!e)return;let c=async()=>{let p=Date.now();if(s.current||p-a.current<xW){y.debug("[useBalanceRefresh] Skipping refresh (debounced or in progress)");return}s.current=!0,a.current=p;try{y.debug("[useBalanceRefresh] Refreshing balance...");let g=await ne(`${hW}/api/addon/account`,{headers:{Authorization:`Bearer ${e}`}});if(g.ok){let d=await g.json(),m=d.creditBalance,C=i.current;if(C!==null&&m>C){let T=m-C;o({message:`Credits added! +${Math.floor(T)} credit(s)`,previousBalance:C,newBalance:m}),y.debug("[useBalanceRefresh] Credits added:",T)}i.current=m,n(d),y.debug("[useBalanceRefresh] Balance updated:",m)}}catch(g){y.error("[useBalanceRefresh] Failed to refresh:",g)}finally{s.current=!1}},l=()=>{document.visibilityState==="visible"&&c()};return document.addEventListener("visibilitychange",l),()=>{document.removeEventListener("visibilitychange",l)}},[e,n]),{notification:r,dismissNotification:u}}ke();ke();je();Ne();lt();If();import{useEffect as yW,useRef as bW}from"react";var SW=300*1e3,lF="uicopilot_feature_flags_fetched_at";function wW(){if(typeof localStorage>"u")return!1;try{let e=localStorage.getItem(lF);if(!e)return!1;let t=parseInt(e,10);return Number.isNaN(t)?!1:Date.now()-t<SW}catch{return!1}}var Gx=null,vW={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 cF(){let{setFeatureFlags:e,setUserRole:t,roleOverride:n}=ce(),{sessionToken:r,resetAuth:o}=we(),i=bW(null);yW(()=>{if(!r||r===i.current)return;if(i.current=r,wW()){y.debug("[useFeatureFlags] Cache fresh, skipping fetch");return}if(Gx){y.debug("[useFeatureFlags] Reusing in-flight fetch");return}let s=`${G()}/api/addon/flags`;Gx=ne(s,{headers:{Authorization:`Bearer ${r}`}}).then(a=>{if(a.status===401||a.status===403)throw y.debug("[useFeatureFlags] Token rejected, resetting auth"),o(),new Error("session token invalid");if(!a.ok)throw new Error(`flags endpoint returned ${a.status}`);return a.json()}).then(a=>{y.debug("[useFeatureFlags] Received flags:",a);let u={enableFixGeneration:!!a.enableFixGeneration,enableFixApply:!!a.enableFixApply,enableAutoMap:!!a.enableAutoMap,enableReviewBadges:!!a.enableReviewBadges,showCosts:!!a.showCosts,enableParallelReview:!!a.enableParallelReview,enableModelSelection:!!a.enableModelSelection};a.role&&(t(a.role),a.role==="beta"&&dw());let c=a.role==="admin"&&n?vW[n]:u;e(c);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(c)),a.role&&localStorage.setItem("uicopilot_user_role",a.role),localStorage.setItem(lF,Date.now().toString())}catch{}}).catch(a=>{y.warn("[useFeatureFlags] Failed to fetch flags, using defaults:",a.message)}).finally(()=>{Gx=null})},[r,e,t])}ke();je();var TW={success:"linear-gradient(135deg, #10b981 0%, #059669 100%)",warning:"linear-gradient(135deg, #f59e0b 0%, #d97706 100%)",error:"linear-gradient(135deg, #ef4444 0%, #dc2626 100%)"},IW=mr.div`
167
167
  position: fixed;
168
168
  top: 16px;
169
169
  right: 16px;
170
- background: ${({variant:e})=>KW[e||"success"]};
170
+ background: ${({variant:e})=>TW[e||"success"]};
171
171
  color: white;
172
172
  padding: 12px 20px;
173
173
  border-radius: 8px;
@@ -181,22 +181,22 @@ ${"=".repeat(40)}
181
181
  from { transform: translateX(100%); opacity: 0; }
182
182
  to { transform: translateX(0); opacity: 1; }
183
183
  }
184
- `,QW=fr.span`font-size: 20px;`,JW=fr.span`font-weight: 500; font-size: 14px;`,ZW=fr.button`
184
+ `,FW=mr.span`font-size: 20px;`,EW=mr.span`font-weight: 500; font-size: 14px;`,AW=mr.button`
185
185
  background: rgba(255, 255, 255, 0.2);
186
186
  border: none; color: white;
187
187
  width: 24px; height: 24px; border-radius: 50%;
188
188
  cursor: pointer; display: flex; align-items: center; justify-content: center;
189
189
  font-size: 14px; margin-left: 8px;
190
190
  &:hover { background: rgba(255, 255, 255, 0.3); }
191
- `,e8=fr.div`
191
+ `,PW=mr.div`
192
192
  padding: 8px 16px;
193
193
  border-top: 1px solid ${({theme:e})=>e.appBorderColor};
194
194
  font-size: 11px;
195
195
  color: ${({theme:e})=>e.color.mediumdark};
196
196
  text-align: center;
197
197
  opacity: 0.7;
198
- `,t8=fr.div(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 24px",textAlign:"center",gap:"16px"})),n8=fr.div({fontSize:"32px"}),r8=fr.h3(({theme:e})=>({margin:0,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),o8=fr.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s2,color:e.color.mediumdark,maxWidth:"320px",lineHeight:1.5})),JI=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})),ZI=fr.span({flex:1}),eF=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`}})),tF=()=>{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]=qW(!1),m=()=>{l(null),o&&fetch(`${q()}/api/addon/flags`,{headers:{Authorization:`Bearer ${o}`}}).then(P=>P.json()).then(P=>{p({enableFixGeneration:!!P.enableFixGeneration,enableFixApply:!!P.enableFixApply,enableAutoMap:!!P.enableAutoMap,enableReviewBadges:!!P.enableReviewBadges,showCosts:!!P.showCosts,enableParallelReview:!!P.enableParallelReview,enableModelSelection:!!P.enableModelSelection})}).catch(()=>{})};Zg(),xm(),QI(),lm(),im();let{notification:w,dismissNotification:k}=KI();YW(()=>{if(w){let P=setTimeout(k,5e3);return()=>clearTimeout(P)}},[w,k]);let F=t.find(P=>P.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(e8,null,"UI Copilot v","0.5.7")},w&&Bt.createElement(XW,{variant:w.variant||"success"},Bt.createElement(QW,null,w.variant==="error"?"!":w.variant==="warning"?"\u26A0":"+"),Bt.createElement(JW,null,w.message),Bt.createElement(ZW,{onClick:k},"x")),i&&Bt.createElement(JI,null,Bt.createElement("span",null,"\u26A0"),Bt.createElement(ZI,null,i),Bt.createElement(eF,{onClick:()=>d(!0)},"Reconnect")),u==="admin"&&c&&Bt.createElement(JI,null,Bt.createElement("span",null,"\u{1F441}"),Bt.createElement(ZI,null,"Previewing as ",c),Bt.createElement(eF,{onClick:m},"Exit preview")),z||O?Bt.createElement(Oc,{label:z?"Loading...":"Loading review..."}):C?Bt.createElement(Rx,null):Bt.createElement(t8,null,Bt.createElement(n8,null,"\u2699"),Bt.createElement(r8,null,i?"Connection issue":"Set up UI Copilot"),Bt.createElement(o8,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(IC,{onClose:()=>d(!1)}))};import nF,{useCallback as i8}from"react";import{useStorybookApi as s8}from"storybook/manager-api";import{IconButton as a8}from"storybook/internal/components";var l8="uireview",c8=`${l8}/panel`,rF=()=>{let e=s8(),t=i8(()=>{e.togglePanel(!0),e.setSelectedPanel(c8)},[e]);return nF.createElement(a8,{key:"uireview-tool",title:"UI Review - Compare with Figma",onClick:t},nF.createElement($I,null))};we();import Vt,{useState as Fa,useCallback as aF,useEffect as Ux}from"react";import{styled as ro,useTheme as S8}from"storybook/theming";import{addons as Yc}from"storybook/manager-api";Ue();De();import{addons as m8,experimental_getStatusStore as qc}from"storybook/manager-api";async function oF(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 u8=q(),p8="uireview/badge";async function d8(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 f8(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:p8,storyId:t,title:r,description:o}])}async function g8(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 iF(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 g8(e.storyId);console.warn(`[reviewAll] Captured: screenshot=${!!s.screenshot} domTree=${!!s.domTree} styles=${!!s.computedStyles} for: ${e.storyName}`);let a=await d8(`${u8}/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 f8(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 h8=q(),Ca="uireview/badge";function sF(){let e=!1,t=!1;try{let n=m8.getChannel();n.on(_x,async()=>{if(!t){t=!0,e=!1;try{await b8(n,()=>e)}finally{t=!1}}}),n.on($x,()=>{e=!0})}catch{}}async function Ox(){try{let e=localStorage.getItem("uicopilot_session_token"),t=localStorage.getItem("uicopilot_selected_project_id");if(!e||!t)return[];let n=await fetch(`${h8}/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 x8(i),i}catch(e){return y.error("[useReviewAll] Failed to load mapped stories:",e),[]}}function x8(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 y8(){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 b8(e,t){let n=await Ox();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=y8(),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=>()=>iF(w,r,o,i,s,t));await oF(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 w8=ro.div({padding:"8px 12px",display:"flex",flexDirection:"column",gap:"6px"}),v8=ro.div({display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"}),k8=ro.span(({theme:e})=>({fontSize:"12px",fontWeight:500,color:e.color.defaultText})),lF=ro.span(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark})),cF=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}})),C8=ro.div(({theme:e})=>({width:"100%",height:"3px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),T8=ro.div(({theme:e,percent:t})=>({width:`${t}%`,height:"100%",backgroundColor:e.color.secondary,borderRadius:"2px",transition:"width 0.3s ease"})),uF=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}})),_x="uireview/review-all-start",$x="uireview/review-all-cancel",Ta="uireview/review-all-progress",Ia="uireview/review-all-complete";function pF(){try{let e=localStorage.getItem("uicopilot_feature_flags");return e?!!JSON.parse(e).enableParallelReview:!1}catch{return!1}}var dF=()=>{let[e,t]=Fa(!1),[n,r]=Fa(null),[o,i]=Fa(null),[s,a]=Fa(null),[u,c]=Fa(pF);Ux(()=>{let m=()=>c(pF()),w=setInterval(m,2e3);return window.addEventListener("storage",m),()=>{clearInterval(w),window.removeEventListener("storage",m)}},[]),Ux(()=>{let m=()=>{Ox().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))}},[]),Ux(()=>{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=aF(()=>{try{Yc.getChannel().emit(_x),t(!0),i(null)}catch{}},[]),p=aF(()=>{try{Yc.getChannel().emit($x)}catch{}t(!1),r(null)},[]),f=n?Math.round(n.completed/n.total*100):0,d=S8();return u?Vt.createElement(w8,null,Vt.createElement(v8,null,Vt.createElement(k8,null,"UI Review"),e?Vt.createElement(cF,{running:!0,onClick:p},"Cancel"):Vt.createElement(cF,{onClick:l,disabled:!s||s===0},"Run",s?` (${s})`:"")),!e&&o?Vt.createElement(Vt.Fragment,null,Vt.createElement(uF,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(lF,null,"$",o.costUsd.toFixed(3)," \xB7 \u20AA",(o.costUsd*3.6).toFixed(3))):e?null:Vt.createElement(uF,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(C8,null,Vt.createElement(T8,{percent:f})),Vt.createElement(lF,null,"Reviewing ",Math.min(n.completed+1,n.total),"/",n.total," \u2014 ",n.currentStoryName))):null};import*as gF from"@sentry/react";var I8="https://015e961f5f626bad5315430e02940616@o138219.ingest.us.sentry.io/4511134750539776",fF=!1;function F8(){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 mF(){if(!fF){fF=!0;try{gF.init({dsn:I8,environment:F8(),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{}}}mF();var Xc="uireview",A8=`${Xc}/panel`,P8=`${Xc}/tool`,xF=`${Xc}/test-provider`;Kc.register(Xc,()=>{if(console.log("[UI Review] Registering addon, checking for StatusStore API..."),typeof hF=="function"){console.log("[UI Review] StatusStore API available, initializing badges");let t=hF("uireview/badge");dv(t),console.log("[UI Review] Badge listener initialized")}else console.warn("[UI Review] experimental_getStatusStore not available \u2014 badges disabled");Kc.add(P8,{type:jx.TOOL,title:"UI Review",match:({viewMode:t})=>t==="story",render:()=>Ea.createElement(rF,null)}),sF(),(()=>{try{let t=localStorage.getItem("uicopilot_feature_flags");return t?!!JSON.parse(t).enableParallelReview:!1}catch{return!1}})()&&Kc.add(xF,{type:jx.experimental_TEST_PROVIDER,id:xF,render:()=>Ea.createElement(dF,null)}),Kc.add(A8,{type:jx.PANEL,title:"UI Review",match:({viewMode:t})=>t==="story",render:({active:t})=>Ea.createElement(E8,{active:t||!1},Ea.createElement(vg,null,Ea.createElement(tF,null)))})});
198
+ `,LW=mr.div(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 24px",textAlign:"center",gap:"16px"})),MW=mr.div({fontSize:"32px"}),BW=mr.h3(({theme:e})=>({margin:0,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),DW=mr.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s2,color:e.color.mediumdark,maxWidth:"320px",lineHeight:1.5})),uF=mr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",margin:"8px 12px",backgroundColor:`${e.color.warning}15`,border:`1px solid ${e.color.warning}50`,borderRadius:e.appBorderRadius,fontSize:e.typography.size.s2,color:e.color.defaultText})),pF=mr.span({flex:1}),dF=mr.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`}})),gF=()=>{let{selectedProjectId:e,projects:t,loadingProjects:n}=Je(),{isConnected:r,sessionToken:o,authError:i}=we(),{currentStoryId:s}=nt(),{currentReviewId:a,userRole:u,roleOverride:c,setRoleOverride:l,setFeatureFlags:p}=ce(),[g,d]=kW(!1),m=()=>{l(null),o&&fetch(`${G()}/api/addon/flags`,{headers:{Authorization:`Bearer ${o}`}}).then(P=>P.json()).then(P=>{p({enableFixGeneration:!!P.enableFixGeneration,enableFixApply:!!P.enableFixApply,enableAutoMap:!!P.enableAutoMap,enableReviewBadges:!!P.enableReviewBadges,showCosts:!!P.showCosts,enableParallelReview:!!P.enableParallelReview,enableModelSelection:!!P.enableModelSelection})}).catch(()=>{})};um(),Fm(),cF(),bm(),hm();let{notification:C,dismissNotification:T}=aF();CW(()=>{if(C){let P=setTimeout(T,5e3);return()=>clearTimeout(P)}},[C,T]);let E=t.find(P=>P.id===e),I=r&&!!e&&!!E,D=!!o&&!!e&&(n||t.length===0),{loadingMapping:R}=nt(),_=I&&!!s&&!a&&R;return Bt.createElement(uu,{header:Bt.createElement(pu,{toolbar:Bt.createElement(Df,{onOpenSettings:()=>d(!0)})}),footer:Bt.createElement(PW,null,"UI Parity v","0.5.9")},C&&Bt.createElement(IW,{variant:C.variant||"success"},Bt.createElement(FW,null,C.variant==="error"?"!":C.variant==="warning"?"\u26A0":"+"),Bt.createElement(EW,null,C.message),Bt.createElement(AW,{onClick:T},"x")),i&&Bt.createElement(uF,null,Bt.createElement("span",null,"\u26A0"),Bt.createElement(pF,null,i),Bt.createElement(dF,{onClick:()=>d(!0)},"Reconnect")),u==="admin"&&c&&Bt.createElement(uF,null,Bt.createElement("span",null,"\u{1F441}"),Bt.createElement(pF,null,"Previewing as ",c),Bt.createElement(dF,{onClick:m},"Exit preview")),D||_?Bt.createElement(Gc,{label:D?"Loading...":"Loading review..."}):I?Bt.createElement(Wx,null):Bt.createElement(LW,null,Bt.createElement(MW,null,"\u2699"),Bt.createElement(BW,null,i?"Connection issue":"Set up UI Parity"),Bt.createElement(DW,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(qt,{onClick:()=>d(!0)},i?"Reconnect":"Open Settings")),g&&Bt.createElement(OC,{onClose:()=>d(!1)}))};import fF,{useCallback as RW}from"react";import{useStorybookApi as zW}from"storybook/manager-api";import{IconButton as NW}from"storybook/internal/components";var OW="uireview",_W=`${OW}/panel`,mF=()=>{let e=zW(),t=RW(()=>{e.togglePanel(!0),e.setSelectedPanel(_W)},[e]);return fF.createElement(NW,{key:"uireview-tool",title:"UI Review - Compare with Figma",onClick:t},fF.createElement(JI,null))};ke();import Vt,{useState as Da,useCallback as bF,useEffect as Xx}from"react";import{styled as uo,useTheme as XW}from"storybook/theming";import{addons as ru}from"storybook/manager-api";je();Ne();import{addons as VW,experimental_getStatusStore as nu}from"storybook/manager-api";async function hF(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}je();Ne();var $W=G(),UW="uireview/badge";async function jW(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 HW(e,t){let n=new TextDecoder,r="",o=null,i=0,s=0,a=0,u=0,c=0,l=0;for(;;){let{done:p,value:g}=await e.read();if(p)break;if(t()){e.cancel();break}r+=n.decode(g,{stream:!0});let d=r.split(`
199
+ `);r=d.pop()||"";for(let m of d)if(m.startsWith("data: "))try{let C=JSON.parse(m.slice(6));if(C.type==="complete"){o=C.complianceScore??C.validation?.complianceScore??null;let E=(C.issues||[]).filter(I=>!I.dismissed);i=E.filter(I=>I.severity==="critical").length,s=E.filter(I=>I.severity==="major").length,a=E.filter(I=>I.severity==="minor").length,u=C.costUsd||0,c=C.inputTokens||0,l=C.outputTokens||0}}catch{}}return{score:o,criticalCount:i,majorCount:s,minorCount:a,costUsd:u,inputTokens:c,outputTokens:l}}function tu(e,t,n,r,o){e&&e.set([{value:n,typeId:UW,storyId:t,title:r,description:o}])}async function WW(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 xF(e,t,n,r,o,i){tu(o,e.storyId,"status-value:pending","Reviewing...",e.storyName);try{console.warn(`[reviewAll] Capturing for: ${e.storyName} (${e.storyId})`);let s=await WW(e.storyId);console.warn(`[reviewAll] Captured: screenshot=${!!s.screenshot} domTree=${!!s.domTree} styles=${!!s.computedStyles} for: ${e.storyName}`);let a=await jW(`${$W}/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 HW(u,i),{score:l,criticalCount:p,majorCount:g,minorCount:d,costUsd:m,inputTokens:C,outputTokens:T}=c;if(l!==null){let E=p>0||l<70?"status-value:error":g>0||l<90?"status-value:warning":"status-value:success",I=[`Score: ${l}`];p>0&&I.push(`${p} critical`),g>0&&I.push(`${g} major`),d>0&&I.push(`${d} minor`);let D=l>=90?`\u2713 Score ${l}`:l>=70?`\u26A0 Score ${l}`:`\u2717 Score ${l}`;return tu(o,e.storyId,E,D,I.join(" \xB7 ")),{passed:l>=70,score:l,costUsd:m,inputTokens:C,outputTokens:T}}return tu(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 tu(o,e.storyId,"status-value:error","Review Failed",a),{passed:!1,score:null,costUsd:0,inputTokens:0,outputTokens:0}}}var GW=G(),La="uireview/badge";function yF(){let e=!1,t=!1;try{let n=VW.getChannel();n.on(Yx,async()=>{if(!t){t=!0,e=!1;try{await KW(n,()=>e)}finally{t=!1}}}),n.on(Kx,()=>{e=!0})}catch{}}async function qx(){try{let e=localStorage.getItem("uicopilot_session_token"),t=localStorage.getItem("uicopilot_selected_project_id");if(!e||!t)return[];let n=await fetch(`${GW}/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 qW(i),i}catch(e){return y.error("[useReviewAll] Failed to load mapped stories:",e),[]}}function qW(e){try{if(typeof nu!="function")return;let t=nu(La);if(!t)return;let n=t.getAll?.()||{},r=new Set(e.map(s=>s.storyId)),o=Object.keys(n).filter(s=>n[s]?.[La]&&!r.has(s));o.length>0&&t.unset(o);let i=e.filter(s=>{let a=n[s.storyId]?.[La];return!(a?.value==="status-value:success"||a?.value==="status-value:warning"||a?.value==="status-value:error")}).map(s=>({value:"status-value:pending",typeId:La,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 YW(){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 KW(e,t){let n=await qx();if(n.length===0){e.emit(Ba,{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 C=localStorage.getItem("uicopilot_selected_models");if(C){let T=JSON.parse(C);Array.isArray(T)&&T.length>0&&(i=T[0])}}catch{}let s=null;try{typeof nu=="function"&&(s=nu(La))}catch{}let a=YW(),u=0,c=0,l=0,p=0,g=0,d=0;e.emit(Ma,{total:n.length,completed:0,currentStoryName:n[0]?.storyName||""});let m=n.map(C=>()=>xF(C,r,o,i,s,t));await hF(m,a,(C,T)=>{if(T&&typeof T=="object"&&"score"in T){let E=T;E.score!==null&&E.score>=90?u++:E.score!==null&&E.score>=70?c++:l++,p+=E.costUsd||0,g+=E.inputTokens||0,d+=E.outputTokens||0}else l++;console.warn(`[reviewAll] Story ${C+1}/${n.length} done:`,n[C].storyName,T),e.emit(Ma,{total:n.length,completed:u+c+l,currentStoryName:n[C].storyName})},t),e.emit(Ba,{total:n.length,passed:u,failed:l,warnCount:c,costUsd:p,inputTokens:g,outputTokens:d})}var QW=uo.div({padding:"8px 12px",display:"flex",flexDirection:"column",gap:"6px"}),JW=uo.div({display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"}),ZW=uo.span(({theme:e})=>({fontSize:"12px",fontWeight:500,color:e.color.defaultText})),SF=uo.span(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark})),wF=uo.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}})),eV=uo.div(({theme:e})=>({width:"100%",height:"3px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),tV=uo.div(({theme:e,percent:t})=>({width:`${t}%`,height:"100%",backgroundColor:e.color.secondary,borderRadius:"2px",transition:"width 0.3s ease"})),vF=uo.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.8}px`,fontSize:e.typography.size.s1,color:e.color.mediumdark})),os=uo.span(e=>({display:"flex",alignItems:"center",gap:"3px","&::before":{content:'""',display:"inline-block",width:"7px",height:"7px",borderRadius:"50%",backgroundColor:e.dotColor}})),Yx="uireview/review-all-start",Kx="uireview/review-all-cancel",Ma="uireview/review-all-progress",Ba="uireview/review-all-complete";function kF(){try{let e=localStorage.getItem("uicopilot_feature_flags");return e?!!JSON.parse(e).enableParallelReview:!1}catch{return!1}}var CF=()=>{let[e,t]=Da(!1),[n,r]=Da(null),[o,i]=Da(null),[s,a]=Da(null),[u,c]=Da(kF);Xx(()=>{let m=()=>c(kF()),C=setInterval(m,2e3);return window.addEventListener("storage",m),()=>{clearInterval(C),window.removeEventListener("storage",m)}},[]),Xx(()=>{let m=()=>{qx().then(I=>{a(I.length)}).catch(()=>{})},C=setTimeout(m,3e3),T=null;try{T=ru.getChannel(),T.on("storyChanged",m),T.on("uireview/mappings-changed",m)}catch{}let E=setInterval(m,6e4);return()=>{clearTimeout(C),clearInterval(E),T&&(T.off("storyChanged",m),T.off("uireview/mappings-changed",m))}},[]),Xx(()=>{let m;try{m=ru.getChannel()}catch{return}let C=E=>{r(E),t(!0)},T=E=>{t(!1),r(null),i({total:E.total,passed:E.passed,failed:E.failed,warned:E.warnCount||0,costUsd:E.costUsd||0})};return m.on(Ma,C),m.on(Ba,T),()=>{m.off(Ma,C),m.off(Ba,T)}},[]);let l=bF(()=>{try{ru.getChannel().emit(Yx),t(!0),i(null)}catch{}},[]),p=bF(()=>{try{ru.getChannel().emit(Kx)}catch{}t(!1),r(null)},[]),g=n?Math.round(n.completed/n.total*100):0,d=XW();return u?Vt.createElement(QW,null,Vt.createElement(JW,null,Vt.createElement(ZW,null,"UI Review"),e?Vt.createElement(wF,{running:!0,onClick:p},"Cancel"):Vt.createElement(wF,{onClick:l,disabled:!s||s===0},"Run",s?` (${s})`:"")),!e&&o?Vt.createElement(Vt.Fragment,null,Vt.createElement(vF,null,Vt.createElement(os,{dotColor:d.color.positive},"Pass (",o.passed,")"),Vt.createElement(os,{dotColor:d.color.warning},"Warn (",o.warned,")"),Vt.createElement(os,{dotColor:d.color.negative},"Fail (",o.failed,")")),o.costUsd>0&&Vt.createElement(SF,null,"$",o.costUsd.toFixed(3)," \xB7 \u20AA",(o.costUsd*3.6).toFixed(3))):e?null:Vt.createElement(vF,null,Vt.createElement(os,{dotColor:d.color.positive},"Pass"),Vt.createElement(os,{dotColor:d.color.warning},"Warn"),Vt.createElement(os,{dotColor:d.color.negative},"Fail")),e&&n&&Vt.createElement(Vt.Fragment,null,Vt.createElement(eV,null,Vt.createElement(tV,{percent:g})),Vt.createElement(SF,null,"Reviewing ",Math.min(n.completed+1,n.total),"/",n.total," \u2014 ",n.currentStoryName))):null};import*as IF from"@sentry/react";var nV="https://015e961f5f626bad5315430e02940616@o138219.ingest.us.sentry.io/4511134750539776",TF=!1;function rV(){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 FF(){if(!TF){TF=!0;try{IF.init({dsn:nV,environment:rV(),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{}}}FF();var iu="uireview",iV=`${iu}/panel`,sV=`${iu}/tool`,AF=`${iu}/test-provider`;ou.register(iu,()=>{if(console.log("[UI Review] Registering addon, checking for StatusStore API..."),typeof EF=="function"){console.log("[UI Review] StatusStore API available, initializing badges");let t=EF("uireview/badge");Fv(t),console.log("[UI Review] Badge listener initialized")}else console.warn("[UI Review] experimental_getStatusStore not available \u2014 badges disabled");ou.add(sV,{type:Qx.TOOL,title:"UI Review",match:({viewMode:t})=>t==="story",render:()=>Ra.createElement(mF,null)}),yF(),(()=>{try{let t=localStorage.getItem("uicopilot_feature_flags");return t?!!JSON.parse(t).enableParallelReview:!1}catch{return!1}})()&&ou.add(AF,{type:Qx.experimental_TEST_PROVIDER,id:AF,render:()=>Ra.createElement(CF,null)}),ou.add(iV,{type:Qx.PANEL,title:"UI Review",match:({viewMode:t})=>t==="story",render:({active:t})=>Ra.createElement(oV,{active:t||!1},Ra.createElement(Lf,null,Ra.createElement(gF,null)))})});
200
200
  /*! Bundled license information:
201
201
 
202
202
  @noble/hashes/utils.js: