@uicopilot/storybook-addon 0.12.1 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -8
- package/dist/manager.mjs +3 -3
- package/package.json +6 -1
package/dist/manager.mjs
CHANGED
|
@@ -11,7 +11,7 @@ var vE=Object.create;var ec=Object.defineProperty;var SE=Object.getOwnPropertyDe
|
|
|
11
11
|
`+t+`
|
|
12
12
|
--`+new Array((n||t.length)+1).join("-")+"^"})}var qb=$(()=>{"use strict";Cc()});var TR,ER,RR,AR,FR,Yb,$c,Kb=$(()=>{"use strict";qb();TR=9,ER=10,RR=12,AR=13,FR=32,Yb=new Uint8Array(128).map((e,t)=>/[a-zA-Z0-9\-]/.test(String.fromCharCode(t))?1:0),$c=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&&Yb[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!==AR&&n!==ER&&n!==RR&&n!==FR&&n!==TR)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 Gb(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||Yb[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 t2(e){let t=null,n=null;return e.eat(jc),e.skipWs(),t=e.scanNumber(e),e.skipWs(),e.charCode()===ug?(e.pos++,e.skipWs(),e.charCode()!==sg&&(n=e.scanNumber(e),e.skipWs())):n=t,e.eat(sg),{min:Number(t),max:n?Number(n):0}}function _R(e){let t=null,n=!1;switch(e.charCode()){case i2:e.pos++,t={min:0,max:0};break;case cg:e.pos++,t={min:1,max:0};break;case Uc:e.pos++,t={min:0,max:1};break;case lg:e.pos++,n=!0,e.charCode()===jc?t=t2(e):e.charCode()===Uc?(e.pos++,t={min:0,max:0}):t={min:1,max:0};break;case jc:t=t2(e);break;default:return null}return{type:"Multiplier",comma:n,min:t.min,max:t.max,term:null}}function $o(e,t){let n=_R(e);return n!==null?(n.term=t,e.charCode()===lg&&e.charCodeAt(e.pos-1)===cg||e.charCode()===Uc&&e.charCodeAt(e.pos-1)===sg?$o(e,n):n):t}function ig(e){let t=e.peek();return t===""?null:$o(e,{type:"Token",value:t})}function NR(e){let t;return e.eat(dg),e.eat(Hc),t=e.scanWord(),e.eat(Hc),e.eat(ag),$o(e,{type:"Property",name:t})}function OR(e){let t=null,n=null,r=1;return e.eat(Fs),e.charCode()===Jb&&(e.peek(),r=-1),r==-1&&e.charCode()===Zb?e.peek():(t=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(t+=e.scanWord())),e.skipWs(),e.eat(ug),e.skipWs(),e.charCode()===Zb?e.peek():(r=1,e.charCode()===Jb&&(e.peek(),r=-1),n=r*Number(e.scanNumber(e)),e.isNameCharCode()&&(n+=e.scanWord())),e.eat(Sa),{type:"Range",min:t,max:n}}function $R(e){let t,n=null;if(e.eat(dg),t=e.scanWord(),t==="boolean-expr"){e.eat(Fs);let r=Vc(e,Sa);return e.eat(Sa),e.eat(ag),$o(e,{type:"Boolean",term:r.terms.length===1?r.terms[0]:r})}return e.charCode()===r2&&e.nextCharCode()===o2&&(e.pos+=2,t+="()"),e.charCodeAt(e.findWsEnd(e.pos))===Fs&&(e.skipWs(),n=OR(e)),e.eat(ag),$o(e,{type:"Type",name:t,opts:n})}function HR(e){let t=e.scanWord();return e.charCode()===r2?(e.pos++,{type:"Function",name:t}):$o(e,{type:"Keyword",name:t})}function UR(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)=>e2[o]-e2[i]);t.length>0;){r=t.shift();let o=0,i=0;for(;o<e.length;o++){let a=e[o];a.type==="Combinator"&&(a.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 Vc(e,t=-1){let n=Object.create(null),r=[],o=null,i=e.pos,a=!1;for(;e.charCode()!==t;){let s=a?Vc(e,o2):VR(e);if(!s)break;if(s.type!=="Spaces"){if(a){if(s.terms.length===0){a=!1;continue}if(s.combinator===" "){for(;s.terms.length>1;)n[" "]=!0,r.push({type:"Combinator",value:" "},s.terms.shift());s=s.terms[0]}}s.type==="Combinator"?((o===null||o.type==="Combinator")&&(e.pos=i,e.error("Unexpected combinator")),n[s.value]=!0):o!==null&&o.type!=="Combinator"&&(n[" "]=!0,r.push({type:"Combinator",value:" "})),r.push(s),o=s,i=e.pos,a=s.type==="Function"}}return o!==null&&o.type==="Combinator"&&(e.pos-=i,e.error("Unexpected combinator")),{type:"Group",terms:r,combinator:UR(r,n)||" ",disallowEmpty:!1,explicit:!1}}function jR(e){let t;return e.eat(Fs),t=Vc(e,Sa),e.eat(Sa),t.explicit=!0,e.charCode()===n2&&(e.pos++,t.disallowEmpty=!0),t}function VR(e){let t=e.charCode();switch(t){case Sa:break;case Fs:return $o(e,jR(e));case dg:return e.nextCharCode()===Hc?NR(e):$R(e);case Qb:return{type:"Combinator",value:e.substringToPos(e.pos+(e.nextCharCode()===Qb?2:1))};case Xb:return e.pos++,e.eat(Xb),{type:"Combinator",value:"&&"};case ug:return e.pos++,{type:"Comma"};case Hc:return $o(e,{type:"String",value:e.scanString()});case zR:case PR:case MR:case BR:case LR:return{type:"Spaces",value:e.scanSpaces()};case DR:return t=e.nextCharCode(),e.isNameCharCode(t)?(e.pos++,{type:"AtKeyword",name:e.scanWord()}):ig(e);case i2:case cg:case Uc:case lg:case n2:break;case jc:if(t=e.nextCharCode(),t<48||t>57)return ig(e);break;default:return e.isNameCharCode(t)?HR(e):ig(e)}}function Ps(e){let t=new $c(e),n=Vc(t);return t.pos!==e.length&&t.error("Unexpected input"),n.terms.length===1&&n.terms[0].type==="Group"?n.terms[0]:n}var PR,MR,LR,BR,zR,n2,lg,Xb,Hc,r2,o2,i2,cg,ug,Jb,dg,ag,Uc,DR,Fs,Sa,jc,Qb,sg,Zb,e2,pg=$(()=>{"use strict";Kb();PR=9,MR=10,LR=12,BR=13,zR=32,n2=33,lg=35,Xb=38,Hc=39,r2=40,o2=41,i2=42,cg=43,ug=44,Jb=45,dg=60,ag=62,Uc=63,DR=64,Fs=91,Sa=93,jc=123,Qb=124,sg=125,Zb=8734,e2={" ":1,"&&":2,"||":3,"|":4}});function a2(e){return typeof e=="function"?e:Ms}function gg(e,t,n){function r(a){switch(o.call(n,a),a.type){case"Group":a.terms.forEach(r);break;case"Multiplier":case"Boolean":r(a.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: "+a.type)}i.call(n,a)}let o=Ms,i=Ms;if(typeof t=="function"?o=t:t&&(o=a2(t.enter),i=a2(t.leave)),o===Ms&&i===Ms)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");r(e,n)}var Ms,s2=$(()=>{"use strict";Ms=function(){}});var fg=$(()=>{"use strict";Wp();pg();s2()});function qR(e){let t=[];return oi(e,(n,r,o)=>t.push({type:n,value:e.slice(r,o),node:null})),t}function l2(e,t){return typeof e=="string"?qR(e):t.generate(e,GR)}var GR,c2=$(()=>{"use strict";Br();GR={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 qn(e,t,n){return t===Ft&&n===$t||e===Ft&&t===Ft&&n===Ft?e:(e.type==="If"&&e.else===$t&&t===Ft&&(t=e.then,e=e.match),{type:"If",match:e,then:t,else:n})}function d2(e){return e.length>2&&e.charCodeAt(e.length-2)===YR&&e.charCodeAt(e.length-1)===KR}function u2(e){return e.type==="Keyword"||e.type==="AtKeyword"||e.type==="Function"||e.type==="Type"&&d2(e.name)}function ai(e,t=" ",n=!1){return{type:"Group",terms:e,combinator:t,disallowEmpty:!1,explicit:n}}function Ls(e,t,n=new Set){if(!n.has(e))switch(n.add(e),e.type){case"If":e.match=Ls(e.match,t,n),e.then=Ls(e.then,t,n),e.else=Ls(e.else,t,n);break;case"Type":return t[e.name]||e}return e}function mg(e,t,n){switch(e){case" ":{let r=Ft;for(let o=t.length-1;o>=0;o--){let i=t[o];r=qn(i,r,$t)}return r}case"|":{let r=$t,o=null;for(let i=t.length-1;i>=0;i--){let a=t[i];if(u2(a)&&(o===null&&i>0&&u2(t[i-1])&&(o=Object.create(null),r=qn({type:"Enum",map:o},Ft,r)),o!==null)){let s=(d2(a.name)?a.name.slice(0,-1):a.name).toLowerCase();if(!(s in o)){o[s]=a;continue}}o=null,r=qn(a,Ft,r)}return r}case"&&":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!0};let r=$t;for(let o=t.length-1;o>=0;o--){let i=t[o],a;t.length>1?a=mg(e,t.filter(function(s){return s!==i}),!1):a=Ft,r=qn(i,a,r)}return r}case"||":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!1};let r=n?Ft:$t;for(let o=t.length-1;o>=0;o--){let i=t[o],a;t.length>1?a=mg(e,t.filter(function(s){return s!==i}),!0):a=Ft,r=qn(i,a,r)}return r}}}function XR(e){let t=Ft,n=ka(e.term);if(e.max===0)n=qn(n,Wc,$t),t=qn(n,null,$t),t.then=qn(Ft,Ft,t),e.comma&&(t.then.else=qn({type:"Comma",syntax:e},t,$t));else for(let r=e.min||1;r<=e.max;r++)e.comma&&t!==Ft&&(t=qn({type:"Comma",syntax:e},t,$t)),t=qn(n,qn(Ft,Ft,t),$t);if(e.min===0)t=qn(Ft,Ft,t);else for(let r=0;r<e.min-1;r++)e.comma&&t!==Ft&&(t=qn({type:"Comma",syntax:e},t,$t)),t=qn(n,t,$t);return t}function ka(e){if(typeof e=="function")return{type:"Generic",fn:e};switch(e.type){case"Group":{let t=mg(e.combinator,e.terms.map(ka),!1);return e.disallowEmpty&&(t=qn(t,Wc,$t)),t}case"Multiplier":return XR(e);case"Boolean":{let t=ka(e.term),n=ka(ai([ai([{type:"Keyword",name:"not"},{type:"Type",name:"!boolean-group"}]),ai([{type:"Type",name:"!boolean-group"},ai([{type:"Multiplier",comma:!1,min:0,max:0,term:ai([{type:"Keyword",name:"and"},{type:"Type",name:"!boolean-group"}])},{type:"Multiplier",comma:!1,min:0,max:0,term:ai([{type:"Keyword",name:"or"},{type:"Type",name:"!boolean-group"}])}],"|")])],"|")),r=ka(ai([{type:"Type",name:"!term"},ai([{type:"Token",value:"("},{type:"Type",name:"!self"},{type:"Token",value:")"}]),{type:"Type",name:"general-enclosed"}],"|"));return Ls(r,{"!term":t,"!self":n}),Ls(n,{"!boolean-group":r}),n}case"Type":case"Property":return{type:e.type,name:e.name,syntax:e};case"Keyword":return{type:e.type,name:e.name.toLowerCase(),syntax:e};case"AtKeyword":return{type:e.type,name:"@"+e.name.toLowerCase(),syntax:e};case"Function":return{type:e.type,name:e.name.toLowerCase()+"(",syntax:e};case"String":return e.value.length===3?{type:"Token",value:e.value.charAt(1),syntax:e}:{type:e.type,value:e.value.substr(1,e.value.length-2).replace(/\\'/g,"'"),syntax:e};case"Token":return{type:e.type,value:e.value,syntax:e};case"Comma":return{type:e.type,syntax:e};default:throw new Error("Unknown node type:",e.type)}}function Bs(e,t){return typeof e=="string"&&(e=Ps(e)),{type:"MatchGraph",match:ka(e),syntax:t||null,source:e}}var Ft,$t,Wc,YR,KR,hg=$(()=>{"use strict";pg();Ft={type:"Match"},$t={type:"Mismatch"},Wc={type:"DisallowEmpty"},YR=40,KR=41});function nA(e){let t=null,n=null,r=e;for(;r!==null;)n=r.prev,r.prev=t,t=r,r=n;return t}function xg(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 rA(e){return e.type!==9?!1:e.value!=="?"}function m2(e){return e===null?!0:e.type===18||e.type===2||e.type===21||e.type===19||e.type===23||rA(e)}function h2(e){return e===null?!0:e.type===22||e.type===20||e.type===24||e.type===9&&e.value==="/"}function oA(e,t,n){function r(){do x++,S=x<e.length?e[x]:null;while(S!==null&&(S.type===13||S.type===25))}function o(O){let L=x+O;return L<e.length?e[L]:null}function i(O,L){return{nextState:O,matchStack:z,syntaxStack:p,thenStack:g,tokenIndex:x,prev:L}}function a(O){g={nextState:O,matchStack:z,syntaxStack:p,prev:g}}function s(O){d=i(O,d)}function u(){z={type:QR,syntax:t.syntax,token:S,prev:z},r(),f=null,x>M&&(M=x)}function l(){p={syntax:t.syntax,opts:t.syntax.opts||p!==null&&p.opts||null,prev:p},z={type:yg,syntax:t.syntax,token:z.token,prev:z}}function c(){z.type===yg?z=z.prev:z={type:x2,syntax:p.syntax,token:z.token,prev:z},p=p.prev}let p=null,g=null,d=null,f=null,y=0,I=null,S=null,x=-1,M=0,z={type:JR,syntax:null,token:null,prev:null};for(r();I===null&&++y<f2;)switch(t.type){case"Match":if(g===null){if(S!==null&&(x!==e.length-1||S.value!=="\\0"&&S.value!=="\\9")){t=$t;break}I=g2;break}if(t=g.nextState,t===Wc)if(g.matchStack===z){t=$t;break}else t=Ft;for(;g.syntaxStack!==p;)c();g=g.prev;break;case"Mismatch":if(f!==null&&f!==!1)(d===null||x>d.tokenIndex)&&(d=f,f=!1);else if(d===null){I=ZR;break}t=d.nextState,g=d.thenStack,p=d.syntaxStack,z=d.matchStack,x=d.tokenIndex,S=x<e.length?e[x]:null,d=d.prev;break;case"MatchGraph":t=t.match;break;case"If":t.else!==$t&&s(t.else),t.then!==Ft&&a(t.then),t=t.match;break;case"MatchOnce":t={type:"MatchOnceBuffer",syntax:t,index:0,mask:0};break;case"MatchOnceBuffer":{let _=t.syntax.terms;if(t.index===_.length){if(t.mask===0||t.syntax.all){t=$t;break}t=Ft;break}if(t.mask===(1<<_.length)-1){t=Ft;break}for(;t.index<_.length;t.index++){let m=1<<t.index;if((t.mask&m)===0){s(t),a({type:"AddMatchOnce",syntax:t.syntax,mask:t.mask|m}),t=_[t.index++];break}}break}case"AddMatchOnce":t={type:"MatchOnceBuffer",syntax:t.syntax,index:0,mask:t.mask};break;case"Enum":if(S!==null){let _=S.value.toLowerCase();if(_.indexOf("\\")!==-1&&(_=_.replace(/\\[09].*$/,"")),p2.call(t.map,_)){t=t.map[_];break}}t=$t;break;case"Generic":{let _=p!==null?p.opts:null,m=x+Math.floor(t.fn(S,o,_));if(!isNaN(m)&&m>x){for(;x<m;)u();t=Ft}else t=$t;break}case"Type":case"Property":{let _=t.type==="Type"?"types":"properties",m=p2.call(n,_)?n[_][t.name]:null;if(!m||!m.match)throw new Error("Bad syntax reference: "+(t.type==="Type"?"<"+t.name+">":"<'"+t.name+"'>"));if(f!==!1&&S!==null&&t.type==="Type"&&(t.name==="custom-ident"&&S.type===1||t.name==="length"&&S.value==="0")){f===null&&(f=i(t,d)),t=$t;break}l(),t=m.matchRef||m.match;break}case"Keyword":{let _=t.name;if(S!==null){let m=S.value;if(m.indexOf("\\")!==-1&&(m=m.replace(/\\[09].*$/,"")),xg(m,_)){u(),t=Ft;break}}t=$t;break}case"AtKeyword":case"Function":if(S!==null&&xg(S.value,t.name)){u(),t=Ft;break}t=$t;break;case"Token":if(S!==null&&S.value===t.value){u(),t=Ft;break}t=$t;break;case"Comma":S!==null&&S.type===18?m2(z.token)?t=$t:(u(),t=h2(S)?$t:Ft):t=m2(z.token)||h2(S)?Ft:$t;break;case"String":let O="",L=x;for(;L<e.length&&O.length<t.value.length;L++)O+=e[L].value;if(xg(O,t.value)){for(;x<L;)u();t=Ft}else t=$t;break;default:throw new Error("Unknown node type: "+t.type)}switch(tA+=y,I){case null:console.warn("[csstree-match] BREAK after "+f2+" iterations"),I=eA,z=null;break;case g2:for(;p!==null;)c();break;default:z=null}return{tokens:e,reason:I,iterations:y,match:z,longestMatch:M}}function bg(e,t,n){let r=oA(e,t,n||{});if(r.match===null)return r;let o=r.match,i=r.match={syntax:t.syntax||null,match:[]},a=[i];for(o=nA(o).prev;o!==null;){switch(o.type){case yg:i.match.push(i={syntax:o.syntax,match:[]}),a.push(i);break;case x2:a.pop(),i=a[a.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 p2,JR,QR,yg,x2,g2,ZR,eA,f2,tA,y2=$(()=>{"use strict";hg();({hasOwnProperty:p2}=Object.prototype),JR=0,QR=1,yg=2,x2=3,g2="Match",ZR="Mismatch",eA="Maximum iteration number exceeded (please fill an issue on https://github.com/csstree/csstree/issues)",f2=15e3,tA=0});var vg={};Ae(vg,{getTrace:()=>b2,isKeyword:()=>sA,isProperty:()=>aA,isType:()=>iA});function b2(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 iA(e,t){return wg(this,e,n=>n.type==="Type"&&n.name===t)}function aA(e,t){return wg(this,e,n=>n.type==="Property"&&n.name===t)}function sA(e){return wg(this,e,t=>t.type==="Keyword")}function wg(e,t,n){let r=b2.call(e,t);return r===null?!1:r.some(n)}var w2=$(()=>{"use strict"});function v2(e){return"node"in e?e.node:v2(e.match[0])}function S2(e){return"node"in e?e.node:S2(e.match[e.match.length-1])}function Sg(e,t,n,r,o){function i(s){if(s.syntax!==null&&s.syntax.type===r&&s.syntax.name===o){let u=v2(s),l=S2(s);e.syntax.walk(t,function(c,p,g){if(c===u){let d=new Sr;do{if(d.appendData(p.data),p.data===l)break;p=p.next}while(p!==null);a.push({parent:g,nodes:d})}})}Array.isArray(s.match)&&s.match.forEach(i)}let a=[];return n.matched!==null&&i(n.matched),a}var k2=$(()=>{"use strict";Ss()});function kg(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e&&e>=0}function C2(e){return!!e&&kg(e.offset)&&kg(e.line)&&kg(e.column)}function lA(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 a=!0;if(zs.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(!C2(r.loc.start))i+=".start";else if(!C2(r.loc.end))i+=".end";else continue;a=!1}else if(t.hasOwnProperty(i)){a=!1;for(let s=0;!a&&s<t[i].length;s++){let u=t[i][s];switch(u){case String:a=typeof r[i]=="string";break;case Boolean:a=typeof r[i]=="boolean";break;case null:a=r[i]===null;break;default:typeof u=="string"?a=r[i]&&r[i].type===u:Array.isArray(u)&&(a=r[i]instanceof Sr)}}}else o(r,"Unknown field `"+i+"` for "+e+" node type");a||o(r,"Bad value for `"+e+"."+i+"`")}}for(let i in t)zs.call(t,i)&&zs.call(r,i)===!1&&o(r,"Field `"+e+"."+i+"` is missed")}}function I2(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<"+(I2(o,t)||"any")+">");else throw new Error("Wrong value `"+o+"` in `"+t+"` structure definition")}return n.join(" | ")}function cA(e,t){let n=t.structure,r={type:String,loc:!0},o={type:'"'+e+'"'};for(let i in n){if(zs.call(n,i)===!1)continue;let a=r[i]=Array.isArray(n[i])?n[i].slice():[n[i]];o[i]=I2(a,e+"."+i)}return{docs:o,check:lA(e,r)}}function T2(e){let t={};if(e.node){for(let n in e.node)if(zs.call(e.node,n)){let r=e.node[n];if(r.structure)t[n]=cA(n,r);else throw new Error("Missed `structure` field in `"+n+"` node type definition")}}return t}var zs,E2=$(()=>{"use strict";Ss();({hasOwnProperty:zs}=Object.prototype)});function Cg(e,t,n){let r={};for(let o in e)e[o].syntax&&(r[o]=n?e[o].syntax:xa(e[o].syntax,{compact:t}));return r}function uA(e,t,n){let r={};for(let[o,i]of Object.entries(e))r[o]={prelude:i.prelude&&(n?i.prelude.syntax:xa(i.prelude.syntax,{compact:t})),descriptors:i.descriptors&&Cg(i.descriptors,t,n)};return r}function dA(e){for(let t=0;t<e.length;t++)if(e[t].value.toLowerCase()==="var(")return!0;return!1}function pA(e){let t=e.terms[0];return e.explicit===!1&&e.terms.length===1&&t.type==="Multiplier"&&t.comma===!0}function Zr(e,t,n){return{matched:e,iterations:n,error:t,...vg}}function Ca(e,t,n,r){let o=l2(n,e.syntax),i;return dA(o)?Zr(null,new Error("Matching for a tree with var() is not supported")):(r&&(i=bg(o,e.cssWideKeywordsSyntax,e)),(!r||!i.match)&&(i=bg(o,t.match,e),!i.match)?Zr(null,new Fb(i.reason,t.syntax,n,i),i.iterations):Zr(i.match,null,i.iterations))}var Ds,R2=$(()=>{"use strict";Pb();zc();Dc();Vb();Wb();fg();c2();hg();y2();w2();k2();E2();Ds=class{constructor(t,n,r){if(this.cssWideKeywords=wa,this.syntax=n,this.generic=!1,this.units={...Oc},this.atrules=Object.create(null),this.properties=Object.create(null),this.types=Object.create(null),this.structure=r||T2(t),t){if(t.cssWideKeywords&&(this.cssWideKeywords=t.cssWideKeywords),t.units)for(let o of Object.keys(Oc))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(jb(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=Bs(this.cssWideKeywords.join(" | "))}checkStructure(t){function n(i,a){o.push({node:i,message:a})}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},a={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"?a.match=Bs(t,i):(typeof t=="string"?Object.defineProperty(a,"syntax",{get(){return Object.defineProperty(a,"syntax",{value:Ps(t)}),a.syntax}}):a.syntax=t,Object.defineProperty(a,"match",{get(){return Object.defineProperty(a,"match",{value:Bs(a.syntax,i)}),a.match}}),n==="Property"&&Object.defineProperty(a,"matchRef",{get(){let s=a.syntax,u=pA(s)?Bs({...s,terms:[s.terms[0].term]},i):null;return Object.defineProperty(a,"matchRef",{value:u}),u}})),a}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 ya("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&&!Ca(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=Lc(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 ya("Unknown at-rule descriptor",n)}checkPropertyName(t){if(!this.getProperty(t))return new ya("Unknown property",t)}matchAtrulePrelude(t,n){let r=this.checkAtrulePrelude(t,n);if(r)return Zr(null,r);let o=this.getAtrule(t);return o.prelude?Ca(this,o.prelude,n||"",!1):Zr(null,null)}matchAtruleDescriptor(t,n,r){let o=this.checkAtruleDescriptorName(t,n);if(o)return Zr(null,o);let i=this.getAtrule(t),a=Lc(n);return Ca(this,i.descriptors[a.name]||i.descriptors[a.basename],r,!1)}matchDeclaration(t){return t.type!=="Declaration"?Zr(null,new Error("Not a Declaration node")):this.matchProperty(t.property,t.value)}matchProperty(t,n){if(Gp(t).custom)return Zr(null,new Error("Lexer matching doesn't applicable for custom properties"));let r=this.checkPropertyName(t);return r?Zr(null,r):Ca(this,this.getProperty(t),n,!0)}matchType(t,n){let r=this.getType(t);return r?Ca(this,r,n,!1):Zr(null,new ya("Unknown type",t))}match(t,n){return typeof t!="string"&&(!t||!t.type)?Zr(null,new ya("Bad syntax")):((typeof t=="string"||!t.match)&&(t=this.createDescriptor(t,"Type","anonymous")),Ca(this,t,n,!1))}findValueFragments(t,n,r,o){return Sg(this,n,this.matchProperty(t,n),r,o)}findDeclarationValueFragments(t,n,r){return Sg(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=Lc(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=Gp(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,l){return l?`<${u}>`:`<'${u}'>`}function n(u,l,c,p){if(c.has(l))return c.get(l);c.set(l,!1),p.syntax!==null&&gg(p.syntax,function(g){if(g.type!=="Type"&&g.type!=="Property")return;let d=g.type==="Type"?u.types:u.properties,f=g.type==="Type"?o:i;hasOwnProperty.call(d,g.name)?n(u,g.name,f,d[g.name])&&(r.push(`${t(l,c===o)} used broken syntax definition ${t(g.name,g.type==="Type")}`),c.set(l,!0)):(r.push(`${t(l,c===o)} used missed syntax definition ${t(g.name,g.type==="Type")}`),c.set(l,!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 a=[...o.keys()].filter(u=>o.get(u)),s=[...i.keys()].filter(u=>i.get(u));return a.length||s.length?{errors:r,types:a,properties:s}:null}dump(t,n){return{generic:this.generic,cssWideKeywords:this.cssWideKeywords,units:this.units,types:Cg(this.types,!n,t),properties:Cg(this.properties,!n,t),atrules:uA(this.atrules,!n,t)}}toString(){return JSON.stringify(this.dump())}}});function Ig(e,t){return typeof t=="string"&&/^\s*\|/.test(t)?typeof e=="string"?e+t:t.replace(/^\s*\|\s*/,""):t||null}function gA(e,t){let n=Object.create(null);for(let r of Object.keys(e))t.includes(r)&&(n[r]=e[r]);return n}function Tg(e,t,n){let r={...e};for(let[o,i]of Object.entries(t))r[o]={...r[o],...n?gA(i,n):i};return r}function _s(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,a]of Object.entries(o))n[r][i]=Array.isArray(a)?a:[];break;case"atrules":n[r]={...e[r]};for(let[i,a]of Object.entries(o)){let s=n[r][i]||{},u=n[r][i]={prelude:s.prelude||null,descriptors:{...s.descriptors}};if(a){u.prelude=a.prelude?Ig(u.prelude,a.prelude):u.prelude||null;for(let[l,c]of Object.entries(a.descriptors||{}))u.descriptors[l]=c?Ig(u.descriptors[l],c):null;Object.keys(u.descriptors).length||(u.descriptors=null)}}break;case"types":case"properties":n[r]={...e[r]};for(let[i,a]of Object.entries(o))n[r][i]=Ig(n[r][i],a);break;case"parseContext":n[r]={...e[r],...o};break;case"scope":case"features":n[r]=Tg(e[r],o);break;case"atrule":case"pseudo":n[r]=Tg(e[r],o,["parse"]);break;case"node":n[r]=Tg(e[r],o,["name","structure","parse","generate","walkContext"]);break}return n}var A2=$(()=>{"use strict"});function F2(e){let t=Wy(e),n=Eb(e),r=bb(e),{fromPlainObject:o,toPlainObject:i}=vb(n),a={lexer:null,createLexer:s=>new Ds(s,a,a.lexer.structure),tokenize:oi,parse:t,generate:r,walk:n,find:n.find,findLast:n.findLast,findAll:n.findAll,fromPlainObject:o,toPlainObject:i,fork(s){let u=_s({},e);return F2(typeof s=="function"?s(u):_s(u,s))}};return a.lexer=new Ds({generic:e.generic,cssWideKeywords:e.cssWideKeywords,units:e.units,types:e.types,atrules:e.atrules,properties:e.properties,node:e.node},a),a}var P2,M2=$(()=>{"use strict";Br();Gy();wb();Sb();Rb();R2();A2();P2=e=>F2(_s({},e))});var L2,B2=$(()=>{"use strict";L2={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 Ag={};Ae(Ag,{generate:()=>xA,name:()=>mA,parse:()=>Rg,structure:()=>hA});function qc(e,t){let n=this.tokenStart+e,r=this.charCodeAt(n);for((r===yo||r===kr)&&(t&&this.error("Number sign is not allowed"),n++);n<this.tokenEnd;n++)pn(this.charCodeAt(n))||this.error("Integer is expected",n)}function Ia(e){return qc.call(this,0,e)}function si(e,t){if(!this.cmpChar(this.tokenStart+e,t)){let n="";switch(t){case Gc:n="N is expected";break;case kr:n="HyphenMinus is expected";break}this.error(n,this.tokenStart+e)}}function Eg(){let e=0,t=0,n=this.tokenType;for(;n===13||n===25;)n=this.lookupType(++e);if(n!==10)if(this.isDelim(yo,e)||this.isDelim(kr,e)){t=this.isDelim(yo,e)?yo:kr;do n=this.lookupType(++e);while(n===13||n===25);n!==10&&(this.skip(e),Ia.call(this,_i))}else return null;return e>0&&this.skip(e),t===0&&(n=this.charCodeAt(this.tokenStart),n!==yo&&n!==kr&&this.error("Number sign is expected")),Ia.call(this,t!==0),t===kr?"-"+this.consume(10):this.consume(10)}function Rg(){let e=this.tokenStart,t=null,n=null;if(this.tokenType===10)Ia.call(this,fA),n=this.consume(10);else if(this.tokenType===1&&this.cmpChar(this.tokenStart,kr))switch(t="-1",si.call(this,1,Gc),this.tokenEnd-this.tokenStart){case 2:this.next(),n=Eg.call(this);break;case 3:si.call(this,2,kr),this.next(),this.skipSC(),Ia.call(this,_i),n="-"+this.consume(10);break;default:si.call(this,2,kr),qc.call(this,3,_i),this.next(),n=this.substrToCursor(e+2)}else if(this.tokenType===1||this.isDelim(yo)&&this.lookupType(1)===1){let r=0;switch(t="1",this.isDelim(yo)&&(r=1,this.next()),si.call(this,0,Gc),this.tokenEnd-this.tokenStart){case 1:this.next(),n=Eg.call(this);break;case 2:si.call(this,1,kr),this.next(),this.skipSC(),Ia.call(this,_i),n="-"+this.consume(10);break;default:si.call(this,1,kr),qc.call(this,2,_i),this.next(),n=this.substrToCursor(e+r+1)}}else if(this.tokenType===12){let r=this.charCodeAt(this.tokenStart),o=r===yo||r===kr,i=this.tokenStart+o;for(;i<this.tokenEnd&&pn(this.charCodeAt(i));i++);i===this.tokenStart+o&&this.error("Integer is expected",this.tokenStart+o),si.call(this,i-this.tokenStart,Gc),t=this.substring(e,i),i+1===this.tokenEnd?(this.next(),n=Eg.call(this)):(si.call(this,i-this.tokenStart+1,kr),i+2===this.tokenEnd?(this.next(),this.skipSC(),Ia.call(this,_i),n="-"+this.consume(10)):(qc.call(this,i-this.tokenStart+2,_i),this.next(),n=this.substrToCursor(i+1)))}else this.error();return t!==null&&t.charCodeAt(0)===yo&&(t=t.substr(1)),n!==null&&n.charCodeAt(0)===yo&&(n=n.substr(1)),{type:"AnPlusB",loc:this.getLocation(e,this.tokenStart),a:t,b:n}}function xA(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 yo,kr,Gc,_i,fA,mA,hA,Fg=$(()=>{"use strict";Br();yo=43,kr=45,Gc=110,_i=!0,fA=!1;mA="AnPlusB",hA={a:[String,null],b:[String,null]}});var Mg={};Ae(Mg,{generate:()=>SA,name:()=>bA,parse:()=>Pg,structure:()=>vA,walkContext:()=>wA});function z2(){return this.Raw(this.consumeUntilLeftCurlyBracketOrSemicolon,!0)}function yA(){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 Pg(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),z2):o=z2.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(yA.call(this));break}return{type:"Atrule",loc:this.getLocation(t,this.tokenStart),name:n,prelude:o,block:i}}function SA(e){this.token(3,"@"+e.name),e.prelude!==null&&this.node(e.prelude),e.block?this.node(e.block):this.token(17,";")}var bA,wA,vA,Lg=$(()=>{"use strict";bA="Atrule",wA="atrule",vA={name:String,prelude:["AtrulePrelude","Raw",null],block:["Block",null]}});var zg={};Ae(zg,{generate:()=>TA,name:()=>kA,parse:()=>Bg,structure:()=>IA,walkContext:()=>CA});function Bg(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 TA(e){this.children(e)}var kA,CA,IA,Dg=$(()=>{"use strict";kA="AtrulePrelude",CA="atrulePrelude",IA={children:[[]]}});var Og={};Ae(Og,{generate:()=>BA,name:()=>MA,parse:()=>Ng,structure:()=>LA});function FA(){this.eof&&this.error("Unexpected end of input");let e=this.tokenStart,t=!1;return this.isDelim(D2)?(t=!0,this.next()):this.isDelim(_g)||this.eat(1),this.isDelim(_g)?this.charCodeAt(this.tokenStart+1)!==Yc?(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 PA(){let e=this.tokenStart,t=this.charCodeAt(e);return t!==Yc&&t!==AA&&t!==RA&&t!==EA&&t!==D2&&t!==_g&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),t!==Yc&&(this.isDelim(Yc)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(e)}function Ng(){let e=this.tokenStart,t,n=null,r=null,o=null;return this.eat(19),this.skipSC(),t=FA.call(this),this.skipSC(),this.tokenType!==20&&(this.tokenType!==1&&(n=PA.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 BA(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 EA,D2,Yc,RA,_g,AA,MA,LA,$g=$(()=>{"use strict";EA=36,D2=42,Yc=61,RA=94,_g=124,AA=126;MA="AttributeSelector",LA={name:"Identifier",matcher:[String,null],value:["String","Identifier",null],flags:[String,null]}});var Ug={};Ae(Ug,{generate:()=>$A,name:()=>_A,parse:()=>Hg,structure:()=>OA,walkContext:()=>NA});function O2(){return this.Raw(null,!0)}function _2(){return this.parseWithFallback(this.Rule,O2)}function N2(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function DA(){if(this.tokenType===17)return N2.call(this,this.tokenIndex);let e=this.parseWithFallback(this.Declaration,N2);return this.tokenType===17&&this.next(),e}function Hg(e){let t=e?DA:_2,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),O2));break;default:e&&this.isDelim(zA)?r.push(_2.call(this)):r.push(t.call(this))}return this.eof||this.eat(24),{type:"Block",loc:this.getLocation(n,this.tokenStart),children:r}}function $A(e){this.token(23,"{"),this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")}),this.token(24,"}")}var zA,_A,NA,OA,jg=$(()=>{"use strict";zA=38;_A="Block",NA="block",OA={children:[["Atrule","Rule","Declaration"]]}});var Wg={};Ae(Wg,{generate:()=>jA,name:()=>HA,parse:()=>Vg,structure:()=>UA});function Vg(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 jA(e){this.token(9,"["),this.children(e),this.token(9,"]")}var HA,UA,Gg=$(()=>{"use strict";HA="Brackets",UA={children:[[]]}});var Yg={};Ae(Yg,{generate:()=>GA,name:()=>VA,parse:()=>qg,structure:()=>WA});function qg(){let e=this.tokenStart;return this.eat(15),{type:"CDC",loc:this.getLocation(e,this.tokenStart)}}function GA(){this.token(15,"-->")}var VA,WA,Kg=$(()=>{"use strict";VA="CDC",WA=[]});var Jg={};Ae(Jg,{generate:()=>KA,name:()=>qA,parse:()=>Xg,structure:()=>YA});function Xg(){let e=this.tokenStart;return this.eat(14),{type:"CDO",loc:this.getLocation(e,this.tokenStart)}}function KA(){this.token(14,"<!--")}var qA,YA,Qg=$(()=>{"use strict";qA="CDO",YA=[]});var ef={};Ae(ef,{generate:()=>ZA,name:()=>JA,parse:()=>Zg,structure:()=>QA});function Zg(){return this.eatDelim(XA),{type:"ClassSelector",loc:this.getLocation(this.tokenStart-1,this.tokenEnd),name:this.consume(1)}}function ZA(e){this.token(9,"."),this.token(1,e.name)}var XA,JA,QA,tf=$(()=>{"use strict";XA=46,JA="ClassSelector",QA={name:String}});var rf={};Ae(rf,{generate:()=>iF,name:()=>rF,parse:()=>nf,structure:()=>oF});function nf(){let e=this.tokenStart,t;switch(this.tokenType){case 13:t=" ";break;case 9:switch(this.charCodeAt(this.tokenStart)){case tF:case eF:case nF:this.next();break;case $2:this.next(),this.eatIdent("deep"),this.eatDelim($2);break;default:this.error("Combinator is expected")}t=this.substrToCursor(e);break}return{type:"Combinator",loc:this.getLocation(e,this.tokenStart),name:t}}function iF(e){this.tokenize(e.name)}var eF,$2,tF,nF,rF,oF,of=$(()=>{"use strict";eF=43,$2=47,tF=62,nF=126,rF="Combinator",oF={name:String}});var sf={};Ae(sf,{generate:()=>uF,name:()=>lF,parse:()=>af,structure:()=>cF});function af(){let e=this.tokenStart,t=this.tokenEnd;return this.eat(25),t-e+2>=2&&this.charCodeAt(t-2)===aF&&this.charCodeAt(t-1)===sF&&(t-=2),{type:"Comment",loc:this.getLocation(e,this.tokenStart),value:this.substring(e+2,t)}}function uF(e){this.token(25,"/*"+e.value+"*/")}var aF,sF,lF,cF,lf=$(()=>{"use strict";aF=42,sF=47,lF="Comment",cF={value:String}});var uf={};Ae(uf,{generate:()=>mF,name:()=>pF,parse:()=>cf,structure:()=>gF});function H2(e){return this.lookupTypeNonSC(1)===1&&dF.has(this.lookupTypeNonSC(2))?this.Feature(e):this.FeatureRange(e)}function cf(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(()=>fF[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 mF(e){e.children.forEach(t=>{t.type==="Condition"?(this.token(21,"("),this.node(t),this.token(22,")")):this.node(t)})}var dF,pF,gF,fF,df=$(()=>{"use strict";dF=new Set([16,22,0]),pF="Condition",gF={kind:String,children:[["Identifier","Feature","FeatureFunction","FeatureRange","SupportsDeclaration"]]};fF={media:H2,container:H2,supports(){return this.SupportsDeclaration()}}});var gf={};Ae(gf,{generate:()=>EF,name:()=>CF,parse:()=>pf,structure:()=>TF,walkContext:()=>IF});function vF(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!0)}function SF(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1)}function kF(){let e=this.tokenIndex,t=this.Value();return t.type!=="Raw"&&this.eof===!1&&this.tokenType!==17&&this.isDelim(j2)===!1&&this.isBalanceEdge(e)===!1&&this.error(),t}function pf(){let e=this.tokenStart,t=this.tokenIndex,n=RF.call(this),r=Bc(n),o=r?this.parseCustomProperty:this.parseValue,i=r?SF:vF,a=!1,s;this.skipSC(),this.eat(16);let u=this.tokenIndex;if(r||this.skipSC(),o?s=this.parseWithFallback(kF,i):s=i.call(this,this.tokenIndex),r&&s.type==="Value"&&s.children.isEmpty){for(let l=u-this.tokenIndex;l<=0;l++)if(this.lookupType(l)===13){s.children.appendData({type:"WhiteSpace",loc:null,value:" "});break}}return this.isDelim(j2)&&(a=AF.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:a,property:n,value:s}}function EF(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 RF(){let e=this.tokenStart;if(this.tokenType===9)switch(this.charCodeAt(this.tokenStart)){case bF:case xF:case wF:case hF:case yF:this.next();break;case U2:this.next(),this.isDelim(U2)&&this.next();break}return this.tokenType===4?this.eat(4):this.eat(1),this.substrToCursor(e)}function AF(){this.eat(9),this.skipSC();let e=this.consume(1);return e==="important"?!0:e}var j2,hF,xF,yF,bF,wF,U2,CF,IF,TF,ff=$(()=>{"use strict";zc();j2=33,hF=35,xF=36,yF=38,bF=42,wF=43,U2=47;CF="Declaration",IF="declaration",TF={important:[Boolean,String],property:String,value:["Value","Raw"]}});var xf={};Ae(xf,{generate:()=>LF,name:()=>PF,parse:()=>hf,structure:()=>MF});function mf(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function hf(){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),mf));break;default:this.isDelim(FF)?e.push(this.parseWithFallback(this.Rule,mf)):e.push(this.parseWithFallback(this.Declaration,mf))}return{type:"DeclarationList",loc:this.getLocationFromList(e),children:e}}function LF(e){this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")})}var FF,PF,MF,yf=$(()=>{"use strict";FF=38;PF="DeclarationList",MF={children:[["Declaration","Atrule","Rule"]]}});var wf={};Ae(wf,{generate:()=>DF,name:()=>BF,parse:()=>bf,structure:()=>zF});function bf(){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 DF(e){this.token(12,e.value+e.unit)}var BF,zF,vf=$(()=>{"use strict";BF="Dimension",zF={value:String,unit:String}});var kf={};Ae(kf,{generate:()=>$F,name:()=>NF,parse:()=>Sf,structure:()=>OF});function Sf(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(_F)&&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 $F(e){this.token(21,"("),this.token(1,e.name),e.value!==null&&(this.token(16,":"),this.node(e.value)),this.token(22,")")}var _F,NF,OF,Cf=$(()=>{"use strict";_F=47,NF="Feature",OF={kind:String,name:String,value:["Identifier","Number","Dimension","Ratio","Function",null]}});var Tf={};Ae(Tf,{generate:()=>VF,name:()=>HF,parse:()=>If,structure:()=>UF});function jF(e,t){let r=(this.features[e]||{})[t];return typeof r!="function"&&this.error(`Unknown feature ${t}()`),r}function If(e="unknown"){let t=this.tokenStart,n=this.consumeFunctionName(),r=jF.call(this,e,n.toLowerCase());this.skipSC();let o=this.parseWithFallback(()=>{let i=this.tokenIndex,a=r.call(this);return this.eof===!1&&this.isBalanceEdge(i)===!1&&this.error(),a},()=>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 VF(e){this.token(2,e.feature+"("),this.node(e.value),this.token(22,")")}var HF,UF,Ef=$(()=>{"use strict";HF="FeatureFunction",UF={kind:String,feature:String,value:["Declaration","Selector"]}});var Ff={};Ae(Ff,{generate:()=>KF,name:()=>qF,parse:()=>Af,structure:()=>YF});function Rf(){switch(this.skipSC(),this.tokenType){case 10:return this.isDelim(V2,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(V2)&&this.error(),e},()=>this.Ratio());default:this.error("Number, dimension, ratio or identifier is expected")}}function G2(e){if(this.skipSC(),this.isDelim(WF)||this.isDelim(GF)){let t=this.source[this.tokenStart];return this.next(),this.isDelim(W2)?(this.next(),t+"="):t}if(this.isDelim(W2))return"=";this.error(`Expected ${e?'":", ':""}"<", ">", "=" or ")"`)}function Af(e="unknown"){let t=this.tokenStart;this.skipSC(),this.eat(21);let n=Rf.call(this),r=G2.call(this,n.type==="Identifier"),o=Rf.call(this),i=null,a=null;return this.lookupNonWSType(0)!==22&&(i=G2.call(this),a=Rf.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:a}}function KF(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 V2,WF,W2,GF,qF,YF,Pf=$(()=>{"use strict";V2=47,WF=60,W2=61,GF=62,qF="FeatureRange",YF={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 Lf={};Ae(Lf,{generate:()=>ZF,name:()=>XF,parse:()=>Mf,structure:()=>QF,walkContext:()=>JF});function Mf(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 ZF(e){this.token(2,e.name+"("),this.children(e),this.token(22,")")}var XF,JF,QF,Bf=$(()=>{"use strict";XF="Function",JF="function",QF={name:String,children:[[]]}});var Df={};Ae(Df,{generate:()=>nP,name:()=>eP,parse:()=>zf,structure:()=>tP});function zf(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 nP(e){e.function?this.token(2,e.function+"("):this.token(21,"("),this.children(e),this.token(22,")")}var eP,tP,_f=$(()=>{"use strict";eP="GeneralEnclosed",tP={kind:String,function:[String,null],children:[[]]}});var Of={};Ae(Of,{generate:()=>aP,name:()=>oP,parse:()=>Nf,structure:()=>iP,xxx:()=>rP});function Nf(){let e=this.tokenStart;return this.eat(4),{type:"Hash",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e+1)}}function aP(e){this.token(4,"#"+e.value)}var rP,oP,iP,$f=$(()=>{"use strict";rP="XXX",oP="Hash",iP={value:String}});var Uf={};Ae(Uf,{generate:()=>cP,name:()=>sP,parse:()=>Hf,structure:()=>lP});function Hf(){return{type:"Identifier",loc:this.getLocation(this.tokenStart,this.tokenEnd),name:this.consume(1)}}function cP(e){this.token(1,e.name)}var sP,lP,jf=$(()=>{"use strict";sP="Identifier",lP={name:String}});var Wf={};Ae(Wf,{generate:()=>pP,name:()=>uP,parse:()=>Vf,structure:()=>dP});function Vf(){let e=this.tokenStart;return this.eat(4),{type:"IdSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e+1)}}function pP(e){this.token(9,"#"+e.name)}var uP,dP,Gf=$(()=>{"use strict";uP="IdSelector",dP={name:String}});var Yf={};Ae(Yf,{generate:()=>hP,name:()=>fP,parse:()=>qf,structure:()=>mP});function qf(){let e=this.tokenStart,t=this.consume(1);for(;this.isDelim(gP);)this.eat(9),t+="."+this.consume(1);return{type:"Layer",loc:this.getLocation(e,this.tokenStart),name:t}}function hP(e){this.tokenize(e.name)}var gP,fP,mP,Kf=$(()=>{"use strict";gP=46,fP="Layer",mP={name:String}});var Jf={};Ae(Jf,{generate:()=>bP,name:()=>xP,parse:()=>Xf,structure:()=>yP});function Xf(){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 bP(e){this.children(e,()=>this.token(18,","))}var xP,yP,Qf=$(()=>{"use strict";xP="LayerList",yP={children:[["Layer"]]}});var e0={};Ae(e0,{generate:()=>SP,name:()=>wP,parse:()=>Zf,structure:()=>vP});function Zf(){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 SP(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 wP,vP,t0=$(()=>{"use strict";wP="MediaQuery",vP={modifier:[String,null],mediaType:[String,null],condition:["Condition",null]}});var r0={};Ae(r0,{generate:()=>IP,name:()=>kP,parse:()=>n0,structure:()=>CP});function n0(){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 IP(e){this.children(e,()=>this.token(18,","))}var kP,CP,o0=$(()=>{"use strict";kP="MediaQueryList",CP={children:[["MediaQuery"]]}});var a0={};Ae(a0,{generate:()=>AP,name:()=>EP,parse:()=>i0,structure:()=>RP});function i0(){let e=this.tokenStart;return this.eatDelim(TP),{type:"NestingSelector",loc:this.getLocation(e,this.tokenStart)}}function AP(){this.token(9,"&")}var TP,EP,RP,s0=$(()=>{"use strict";TP=38,EP="NestingSelector",RP={}});var c0={};Ae(c0,{generate:()=>MP,name:()=>FP,parse:()=>l0,structure:()=>PP});function l0(){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 MP(e){this.node(e.nth),e.selector!==null&&(this.token(1,"of"),this.node(e.selector))}var FP,PP,u0=$(()=>{"use strict";FP="Nth",PP={nth:["AnPlusB","Identifier"],selector:["SelectorList",null]}});var p0={};Ae(p0,{generate:()=>zP,name:()=>LP,parse:()=>d0,structure:()=>BP});function d0(){return{type:"Number",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consume(10)}}function zP(e){this.token(10,e.value)}var LP,BP,g0=$(()=>{"use strict";LP="Number",BP={value:String}});var m0={};Ae(m0,{generate:()=>NP,name:()=>DP,parse:()=>f0,structure:()=>_P});function f0(){let e=this.tokenStart;return this.next(),{type:"Operator",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function NP(e){this.tokenize(e.value)}var DP,_P,h0=$(()=>{"use strict";DP="Operator",_P={value:String}});var y0={};Ae(y0,{generate:()=>HP,name:()=>OP,parse:()=>x0,structure:()=>$P});function x0(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 HP(e){this.token(21,"("),this.children(e),this.token(22,")")}var OP,$P,b0=$(()=>{"use strict";OP="Parentheses",$P={children:[[]]}});var v0={};Ae(v0,{generate:()=>VP,name:()=>UP,parse:()=>w0,structure:()=>jP});function w0(){return{type:"Percentage",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consumeNumber(11)}}function VP(e){this.token(11,e.value+"%")}var UP,jP,S0=$(()=>{"use strict";UP="Percentage",jP={value:String}});var C0={};Ae(C0,{generate:()=>YP,name:()=>WP,parse:()=>k0,structure:()=>qP,walkContext:()=>GP});function k0(){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 YP(e){this.token(16,":"),e.children===null?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"))}var WP,GP,qP,I0=$(()=>{"use strict";WP="PseudoClassSelector",GP="function",qP={name:String,children:[["Raw"],null]}});var E0={};Ae(E0,{generate:()=>QP,name:()=>KP,parse:()=>T0,structure:()=>JP,walkContext:()=>XP});function T0(){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 QP(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 KP,XP,JP,R0=$(()=>{"use strict";KP="PseudoElementSelector",XP="function",JP={name:String,children:[["Raw"],null]}});var F0={};Ae(F0,{generate:()=>tM,name:()=>ZP,parse:()=>A0,structure:()=>eM});function Y2(){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 A0(){let e=this.tokenStart,t=Y2.call(this),n=null;return this.skipSC(),this.isDelim(q2)&&(this.eatDelim(q2),n=Y2.call(this)),{type:"Ratio",loc:this.getLocation(e,this.tokenStart),left:t,right:n}}function tM(e){this.node(e.left),this.token(9,"/"),e.right?this.node(e.right):this.node(10,1)}var q2,ZP,eM,P0=$(()=>{"use strict";q2=47;ZP="Ratio",eM={left:["Number","Function"],right:["Number","Function",null]}});var L0={};Ae(L0,{generate:()=>iM,name:()=>rM,parse:()=>M0,structure:()=>oM});function nM(){return this.tokenIndex>0&&this.lookupType(-1)===13?this.tokenIndex>1?this.getTokenStart(this.tokenIndex-1):this.firstCharOffset:this.tokenStart}function M0(e,t){let n=this.getTokenStart(this.tokenIndex),r;return this.skipUntilBalanced(this.tokenIndex,e||this.consumeUntilBalanceEnd),t&&this.tokenStart>n?r=nM.call(this):r=this.tokenStart,{type:"Raw",loc:this.getLocation(n,r),value:this.substring(n,r)}}function iM(e){this.tokenize(e.value)}var rM,oM,B0=$(()=>{"use strict";rM="Raw",oM={value:String}});var D0={};Ae(D0,{generate:()=>uM,name:()=>sM,parse:()=>z0,structure:()=>cM,walkContext:()=>lM});function K2(){return this.Raw(this.consumeUntilLeftCurlyBracket,!0)}function aM(){let e=this.SelectorList();return e.type!=="Raw"&&this.eof===!1&&this.tokenType!==23&&this.error(),e}function z0(){let e=this.tokenIndex,t=this.tokenStart,n,r;return this.parseRulePrelude?n=this.parseWithFallback(aM,K2):n=K2.call(this,e),r=this.Block(!0),{type:"Rule",loc:this.getLocation(t,this.tokenStart),prelude:n,block:r}}function uM(e){this.node(e.prelude),this.node(e.block)}var sM,lM,cM,_0=$(()=>{"use strict";sM="Rule",lM="rule",cM={prelude:["SelectorList","Raw"],block:["Block"]}});var O0={};Ae(O0,{generate:()=>gM,name:()=>dM,parse:()=>N0,structure:()=>pM});function N0(){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 gM(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 dM,pM,$0=$(()=>{"use strict";dM="Scope",pM={root:["SelectorList","Raw",null],limit:["SelectorList","Raw",null]}});var U0={};Ae(U0,{generate:()=>hM,name:()=>fM,parse:()=>H0,structure:()=>mM});function H0(){let e=this.readSequence(this.scope.Selector);return this.getFirstListNode(e)===null&&this.error("Selector is expected"),{type:"Selector",loc:this.getLocationFromList(e),children:e}}function hM(e){this.children(e)}var fM,mM,j0=$(()=>{"use strict";fM="Selector",mM={children:[["TypeSelector","IdSelector","ClassSelector","AttributeSelector","PseudoClassSelector","PseudoElementSelector","Combinator"]]}});var W0={};Ae(W0,{generate:()=>wM,name:()=>xM,parse:()=>V0,structure:()=>bM,walkContext:()=>yM});function V0(){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 wM(e){this.children(e,()=>this.token(18,","))}var xM,yM,bM,G0=$(()=>{"use strict";xM="SelectorList",yM="selector",bM={children:[["Selector","Raw"]]}});function Kc(e){let t=e.length,n=e.charCodeAt(0),r=n===X2||n===J2?1:0,o=r===1&&t>1&&e.charCodeAt(t-1)===n?t-2:t-1,i="";for(let a=r;a<=o;a++){let s=e.charCodeAt(a);if(s===q0){if(a===o){a!==t-1&&(i=e.substr(a+1));break}if(s=e.charCodeAt(++a),ar(q0,s)){let u=a-1,l=zo(e,u);a=l-1,i+=yc(e.substring(u+1,l))}else s===13&&e.charCodeAt(a+1)===10&&a++}else i+=e[a]}return i}function Q2(e,t){let n=t?"'":'"',r=t?J2:X2,o="",i=!1;for(let a=0;a<e.length;a++){let s=e.charCodeAt(a);if(s===0){o+="\uFFFD";continue}if(s<=31||s===127){o+="\\"+s.toString(16),i=!0;continue}s===r||s===q0?(o+="\\"+e.charAt(a),i=!1):(i&&(sr(s)||ho(s))&&(o+=" "),o+=e.charAt(a),i=!1)}return n+o+n}var q0,X2,J2,Xc=$(()=>{"use strict";Br();q0=92,X2=34,J2=39});var K0={};Ae(K0,{generate:()=>kM,name:()=>vM,parse:()=>Y0,structure:()=>SM});function Y0(){return{type:"String",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:Kc(this.consume(5))}}function kM(e){this.token(5,Q2(e.value))}var vM,SM,X0=$(()=>{"use strict";Xc();vM="String",SM={value:String}});var Q0={};Ae(Q0,{generate:()=>RM,name:()=>IM,parse:()=>J0,structure:()=>EM,walkContext:()=>TM});function ew(){return this.Raw(null,!1)}function J0(){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)!==CM){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,ew);break;default:n=this.parseWithFallback(this.Rule,ew)}t.push(n)}return{type:"StyleSheet",loc:this.getLocation(e,this.tokenStart),children:t}}function RM(e){this.children(e)}var CM,IM,TM,EM,Z0=$(()=>{"use strict";CM=33;IM="StyleSheet",TM="stylesheet",EM={children:[["Comment","CDO","CDC","Atrule","Rule","Raw"]]}});var tm={};Ae(tm,{generate:()=>PM,name:()=>AM,parse:()=>em,structure:()=>FM});function em(){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 PM(e){this.token(21,"("),this.node(e.declaration),this.token(22,")")}var AM,FM,nm=$(()=>{"use strict";AM="SupportsDeclaration",FM={declaration:"Declaration"}});var im={};Ae(im,{generate:()=>zM,name:()=>LM,parse:()=>om,structure:()=>BM});function rm(){this.tokenType!==1&&this.isDelim(MM)===!1&&this.error("Identifier or asterisk is expected"),this.next()}function om(){let e=this.tokenStart;return this.isDelim(tw)?(this.next(),rm.call(this)):(rm.call(this),this.isDelim(tw)&&(this.next(),rm.call(this))),{type:"TypeSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function zM(e){this.tokenize(e.name)}var MM,tw,LM,BM,am=$(()=>{"use strict";MM=42,tw=124;LM="TypeSelector",BM={name:String}});var cm={};Ae(cm,{generate:()=>$M,name:()=>NM,parse:()=>lm,structure:()=>OM});function Ns(e,t){let n=0;for(let r=this.tokenStart+e;r<this.tokenEnd;r++){let o=this.charCodeAt(r);if(o===rw&&t&&n!==0)return Ns.call(this,e+n+1,!1),-1;sr(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 Jc(e){let t=0;for(;this.isDelim(sm);)++t>e&&this.error("Too many question marks"),this.next()}function DM(e){this.charCodeAt(this.tokenStart)!==e&&this.error((e===nw?"Plus sign":"Hyphen minus")+" is expected")}function _M(){let e=0;switch(this.tokenType){case 10:if(e=Ns.call(this,1,!0),this.isDelim(sm)){Jc.call(this,6-e);break}if(this.tokenType===12||this.tokenType===10){DM.call(this,rw),Ns.call(this,1,!1);break}break;case 12:e=Ns.call(this,1,!0),e>0&&Jc.call(this,6-e);break;default:if(this.eatDelim(nw),this.tokenType===1){e=Ns.call(this,0,!0),e>0&&Jc.call(this,6-e);break}if(this.isDelim(sm)){this.next(),Jc.call(this,5);break}this.error("Hex digit or question mark is expected")}}function lm(){let e=this.tokenStart;return this.eatIdent("u"),_M.call(this),{type:"UnicodeRange",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function $M(e){this.tokenize(e.value)}var nw,rw,sm,NM,OM,um=$(()=>{"use strict";Br();nw=43,rw=45,sm=63;NM="UnicodeRange",OM={value:String}});function iw(e){let t=e.length,n=4,r=e.charCodeAt(t-1)===ow?t-2:t-1,o="";for(;n<r&&ho(e.charCodeAt(n));)n++;for(;n<r&&ho(e.charCodeAt(r));)r--;for(let i=n;i<=r;i++){let a=e.charCodeAt(i);if(a===dm){if(i===r){i!==t-1&&(o=e.substr(i+1));break}if(a=e.charCodeAt(++i),ar(dm,a)){let s=i-1,u=zo(e,s);i=u-1,o+=yc(e.substring(s+1,u))}else a===13&&e.charCodeAt(i+1)===10&&i++}else o+=e[i]}return o}function aw(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===HM||o===dm||o===UM||o===jM||o===VM||o===ow?(t+="\\"+e.charAt(r),n=!1):(n&&sr(o)&&(t+=" "),t+=e.charAt(r),n=!1)}return"url("+t+")"}var HM,dm,UM,jM,VM,ow,pm=$(()=>{"use strict";Br();HM=32,dm=92,UM=34,jM=39,VM=40,ow=41});var fm={};Ae(fm,{generate:()=>qM,name:()=>WM,parse:()=>gm,structure:()=>GM});function gm(){let e=this.tokenStart,t;switch(this.tokenType){case 7:t=iw(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=Kc(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 qM(e){this.token(7,aw(e.value))}var WM,GM,mm=$(()=>{"use strict";pm();Xc();WM="Url",GM={value:String}});var xm={};Ae(xm,{generate:()=>XM,name:()=>YM,parse:()=>hm,structure:()=>KM});function hm(){let e=this.tokenStart,t=this.readSequence(this.scope.Value);return{type:"Value",loc:this.getLocation(e,this.tokenStart),children:t}}function XM(e){this.children(e)}var YM,KM,ym=$(()=>{"use strict";YM="Value",KM={children:[[]]}});var wm={};Ae(wm,{generate:()=>eL,name:()=>QM,parse:()=>bm,structure:()=>ZM});function bm(){return this.eat(13),JM}function eL(e){this.token(13,e.value)}var JM,QM,ZM,vm=$(()=>{"use strict";JM=Object.freeze({type:"WhiteSpace",loc:null,value:" "}),QM="WhiteSpace",ZM={value:String}});var Os={};Ae(Os,{AnPlusB:()=>Ag,Atrule:()=>Mg,AtrulePrelude:()=>zg,AttributeSelector:()=>Og,Block:()=>Ug,Brackets:()=>Wg,CDC:()=>Yg,CDO:()=>Jg,ClassSelector:()=>ef,Combinator:()=>rf,Comment:()=>sf,Condition:()=>uf,Declaration:()=>gf,DeclarationList:()=>xf,Dimension:()=>wf,Feature:()=>kf,FeatureFunction:()=>Tf,FeatureRange:()=>Ff,Function:()=>Lf,GeneralEnclosed:()=>Df,Hash:()=>Of,IdSelector:()=>Wf,Identifier:()=>Uf,Layer:()=>Yf,LayerList:()=>Jf,MediaQuery:()=>e0,MediaQueryList:()=>r0,NestingSelector:()=>a0,Nth:()=>c0,Number:()=>p0,Operator:()=>m0,Parentheses:()=>y0,Percentage:()=>v0,PseudoClassSelector:()=>C0,PseudoElementSelector:()=>E0,Ratio:()=>F0,Raw:()=>L0,Rule:()=>D0,Scope:()=>O0,Selector:()=>U0,SelectorList:()=>W0,String:()=>K0,StyleSheet:()=>Q0,SupportsDeclaration:()=>tm,TypeSelector:()=>im,UnicodeRange:()=>cm,Url:()=>fm,Value:()=>xm,WhiteSpace:()=>wm});var Sm=$(()=>{"use strict";Fg();Lg();Dg();$g();jg();Gg();Kg();Qg();tf();of();lf();df();ff();yf();vf();Cf();Ef();Pf();Bf();_f();$f();jf();Gf();Kf();Qf();t0();o0();s0();u0();g0();h0();b0();S0();I0();R0();P0();B0();_0();$0();j0();G0();X0();Z0();nm();am();um();mm();ym();vm()});var lw,cw=$(()=>{"use strict";Dc();B2();Sm();lw={generic:!0,cssWideKeywords:wa,...L2,node:Os}});function $s(e){switch(this.tokenType){case 4:return this.Hash();case 18:return this.Operator();case 21:return this.Parentheses(this.readSequence,e.recognizer);case 19:return this.Brackets(this.readSequence,e.recognizer);case 5:return this.String();case 12:return this.Dimension();case 11:return this.Percentage();case 10:return this.Number();case 2:return this.cmpStr(this.tokenStart,this.tokenEnd,"url(")?this.Url():this.Function(this.readSequence,e.recognizer);case 7:return this.Url();case 1:return this.cmpChar(this.tokenStart,iL)&&this.cmpChar(this.tokenStart+1,uw)?this.UnicodeRange():this.Identifier();case 9:{let t=this.charCodeAt(this.tokenStart);if(t===oL||t===nL||t===uw||t===rL)return this.Operator();t===tL&&this.error("Hex or identifier is expected",this.tokenStart+1);break}}}var tL,nL,uw,rL,oL,iL,km=$(()=>{"use strict";tL=35,nL=42,uw=43,rL=45,oL=47,iL=117});var dw,pw=$(()=>{"use strict";km();dw={getNode:$s}});function fL(e,t){t.last!==null&&t.last.type!=="Combinator"&&e!==null&&e.type!=="Combinator"&&t.push({type:"Combinator",loc:null,name:" "})}function mL(){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)===gw&&this.error("Identifier is expected",this.tokenStart+1);break;case 9:{switch(this.charCodeAt(this.tokenStart)){case cL:case dL:case gL:case uL:return this.Combinator();case gw:return this.ClassSelector();case lL:case pL:return this.TypeSelector();case aL:return this.IdSelector();case sL:return this.NestingSelector()}break}}}var aL,sL,lL,cL,uL,gw,dL,pL,gL,fw,mw=$(()=>{"use strict";aL=35,sL=38,lL=42,cL=43,uL=47,gw=46,dL=62,pL=124,gL=126;fw={onWhiteSpace:fL,getNode:mL}});function hw(){return this.createSingleNodeList(this.Raw(null,!1))}var xw=$(()=>{"use strict"});function yw(){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 bw=$(()=>{"use strict"});function ww(e){return e!==null&&e.type==="Operator"&&(e.value[e.value.length-1]==="-"||e.value[e.value.length-1]==="+")}var vw,Sw=$(()=>{"use strict";km();xw();bw();vw={getNode:$s,onWhiteSpace(e,t){ww(e)&&(e.value=" "+e.value),ww(t.last)&&(t.last.value+=" ")},expression:hw,var:yw}});var Cm={};Ae(Cm,{AtrulePrelude:()=>dw,Selector:()=>fw,Value:()=>vw});var kw=$(()=>{"use strict";pw();mw();Sw()});var hL,Cw,Iw=$(()=>{"use strict";hL=new Set(["none","and","not","or"]),Cw={parse:{prelude(){let e=this.createList();if(this.tokenType===1){let t=this.substring(this.tokenStart,this.tokenEnd);hL.has(t.toLowerCase())||e.push(this.Identifier())}return e.push(this.Condition("container")),e},block(e=!1){return this.Block(e)}}}});var Tw,Ew=$(()=>{"use strict";Tw={parse:{prelude:null,block(){return this.Block(!0)}}}});function Im(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 Rw,Aw,Fw=$(()=>{"use strict";Rw={layer(){this.skipSC();let e=this.createList(),t=Im.call(this,this.Layer);return(t.type!=="Raw"||t.value!=="")&&e.push(t),e},supports(){this.skipSC();let e=this.createList(),t=Im.call(this,this.Declaration,()=>Im.call(this,()=>this.Condition("supports")));return(t.type!=="Raw"||t.value!=="")&&e.push(t),e}},Aw={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,Rw)),this.skipSC(),this.tokenType===2&&this.cmpStr(this.tokenStart,this.tokenEnd,"supports(")&&e.push(this.Function(null,Rw)),(this.lookupNonWSType(0)===1||this.lookupNonWSType(0)===21)&&e.push(this.MediaQueryList()),e},block:null}}});var Pw,Mw=$(()=>{"use strict";Pw={parse:{prelude(){return this.createSingleNodeList(this.LayerList())},block(){return this.Block(!1)}}}});var Lw,Bw=$(()=>{"use strict";Lw={parse:{prelude(){return this.createSingleNodeList(this.MediaQueryList())},block(e=!1){return this.Block(e)}}}});var zw,Dw=$(()=>{"use strict";zw={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}}});var _w,Nw=$(()=>{"use strict";_w={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}}});var Ow,$w=$(()=>{"use strict";Ow={parse:{prelude(){return this.createSingleNodeList(this.Scope())},block(e=!1){return this.Block(e)}}}});var Hw,Uw=$(()=>{"use strict";Hw={parse:{prelude:null,block(e=!1){return this.Block(e)}}}});var jw,Vw=$(()=>{"use strict";jw={parse:{prelude(){return this.createSingleNodeList(this.Condition("supports"))},block(e=!1){return this.Block(e)}}}});var Ww,Gw=$(()=>{"use strict";Iw();Ew();Fw();Mw();Bw();Dw();Nw();$w();Uw();Vw();Ww={container:Cw,"font-face":Tw,import:Aw,layer:Pw,media:Lw,nest:zw,page:_w,scope:Ow,"starting-style":Hw,supports:jw}});function qw(){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 Yw=$(()=>{"use strict"});var Ni,Tm,xL,yL,Qc,Kw,Xw=$(()=>{"use strict";Yw();Ni={parse(){return this.createSingleNodeList(this.SelectorList())}},Tm={parse(){return this.createSingleNodeList(this.Selector())}},xL={parse(){return this.createSingleNodeList(this.Identifier())}},yL={parse:qw},Qc={parse(){return this.createSingleNodeList(this.Nth())}},Kw={dir:xL,has:Ni,lang:yL,matches:Ni,is:Ni,"-moz-any":Ni,"-webkit-any":Ni,where:Ni,not:Ni,"nth-child":Qc,"nth-last-child":Qc,"nth-last-of-type":Qc,"nth-of-type":Qc,slotted:Tm,host:Tm,"host-context":Tm}});var Em={};Ae(Em,{AnPlusB:()=>Rg,Atrule:()=>Pg,AtrulePrelude:()=>Bg,AttributeSelector:()=>Ng,Block:()=>Hg,Brackets:()=>Vg,CDC:()=>qg,CDO:()=>Xg,ClassSelector:()=>Zg,Combinator:()=>nf,Comment:()=>af,Condition:()=>cf,Declaration:()=>pf,DeclarationList:()=>hf,Dimension:()=>bf,Feature:()=>Sf,FeatureFunction:()=>If,FeatureRange:()=>Af,Function:()=>Mf,GeneralEnclosed:()=>zf,Hash:()=>Nf,IdSelector:()=>Vf,Identifier:()=>Hf,Layer:()=>qf,LayerList:()=>Xf,MediaQuery:()=>Zf,MediaQueryList:()=>n0,NestingSelector:()=>i0,Nth:()=>l0,Number:()=>d0,Operator:()=>f0,Parentheses:()=>x0,Percentage:()=>w0,PseudoClassSelector:()=>k0,PseudoElementSelector:()=>T0,Ratio:()=>A0,Raw:()=>M0,Rule:()=>z0,Scope:()=>N0,Selector:()=>H0,SelectorList:()=>V0,String:()=>Y0,StyleSheet:()=>J0,SupportsDeclaration:()=>em,TypeSelector:()=>om,UnicodeRange:()=>lm,Url:()=>gm,Value:()=>hm,WhiteSpace:()=>bm});var Jw=$(()=>{"use strict";Fg();Lg();Dg();$g();jg();Gg();Kg();Qg();tf();of();lf();df();ff();yf();vf();Cf();Ef();Pf();Bf();_f();$f();jf();Gf();Kf();Qf();t0();o0();s0();u0();g0();h0();b0();S0();I0();R0();P0();B0();_0();$0();j0();G0();X0();Z0();nm();am();um();mm();ym();vm()});var Qw,Zw=$(()=>{"use strict";kw();Gw();Xw();Jw();Qw={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:Cm,atrule:Ww,pseudo:Kw,node:Em}});var ev,tv=$(()=>{"use strict";Sm();ev={node:Os}});var nv,rv=$(()=>{"use strict";M2();cw();Zw();tv();nv=P2({...lw,...Qw,...ev})});var ov=$(()=>{"use strict"});var iv=$(()=>{"use strict"});var Zre,av,eoe,toe,noe,sv,roe,ooe,ioe,aoe,soe,loe,lv=$(()=>{"use strict";rv();ov();fg();zc();iv();Xc();pm();({tokenize:Zre,parse:av,generate:eoe,lexer:toe,createLexer:noe,walk:sv,find:roe,findLast:ooe,findAll:ioe,toPlainObject:aoe,fromPlainObject:soe,fork:loe}=nv)});function SL(e){return e.toLowerCase().replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function uv(e){try{let t=av(e.trim(),{context:"value"}),n=[];return sv(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 kL(e,t){let n=SL(e);if(!vL.has(n))return t;let r=uv(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 cv(e,t){let n=t.trim();if(!n)return"";let r=kL(e,n);return uv(r).map(i=>i==="0"?"0px":i).join(" ")}function dv(e,t,n){let r=cv(e,t),o=cv(e,n);return r!==""&&o!==""&&r===o}var vL,pv=$(()=>{"use strict";lv();vL=new Set(["padding","margin","border-radius","borderradius","inset","border-width","borderwidth"])});function CL(e){let t=e.toLowerCase();return t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t}function IL(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 gv(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=IL(n[0]);if(i)return i}let r=t.match(/#([0-9a-fA-F]{3,8})/);if(r)return CL(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 Oi(e,t,n){if(!e||!t)return!1;let r=String(e),o=String(t),i=r.toLowerCase(),a=o.toLowerCase(),s=i.includes("none"),u=a.includes("none");if(s!==u)return!1;let l=/\b(fill|stroke)\s*:/i,c=l.test(r),p=l.test(o);if(c!==p)return!1;let g=gv(r),d=gv(o);return!!(g===d||n&&dv(n,r,o))}var Rm=$(()=>{"use strict";pv()});function Am(e){let t=e.trim().match(/^#?([0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/);if(!t)return null;let n=t[1];return n.length===3||n.length===4?n=n.slice(0,3).split("").map(r=>r+r).join(""):n.length===8&&(n=n.slice(0,6)),[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16)]}function TL(e){let t=e.trim().match(/^rgba?\(\s*([^)]+)\)$/i);if(!t)return null;let n=t[1].replace(/\//g," ").split(/[\s,]+/).filter(Boolean);if(n.length<3)return null;let r=u=>u.endsWith("%")?Math.round(parseFloat(u)/100*255):Math.round(parseFloat(u)),o=r(n[0]),i=r(n[1]),a=r(n[2]);if([o,i,a].some(u=>isNaN(u)))return null;let s=u=>Math.max(0,Math.min(255,u));return[s(o),s(i),s(a)]}function EL(e,t,n){let r=(1-Math.abs(2*n-1))*t,o=(e%360+360)%360/60,i=r*(1-Math.abs(o%2-1)),a=0,s=0,u=0;o<1?[a,s,u]=[r,i,0]:o<2?[a,s,u]=[i,r,0]:o<3?[a,s,u]=[0,r,i]:o<4?[a,s,u]=[0,i,r]:o<5?[a,s,u]=[i,0,r]:[a,s,u]=[r,0,i];let l=n-r/2;return[Math.round((a+l)*255),Math.round((s+l)*255),Math.round((u+l)*255)]}function RL(e){let t=e.trim().match(/^hsla?\(\s*([^)]+)\)$/i);if(!t)return null;let n=t[1].replace(/\//g," ").split(/[\s,]+/).filter(Boolean);if(n.length<3)return null;let r=parseFloat(n[0]),o=parseFloat(n[1]),i=parseFloat(n[2]);return[r,o,i].some(a=>isNaN(a))?null:EL(r,o/100,i/100)}function FL(e){return AL[e.trim().toLowerCase()]??null}function fv(e){return e?Am(e)??TL(e)??RL(e)??Fm(e)??FL(e):null}function Fm(e){let t=e.trim().match(/^color\(\s*display-p3\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*[\d.]+)?\s*\)$/);if(!t)return null;let n=parseFloat(t[1]),r=parseFloat(t[2]),o=parseFloat(t[3]);if(isNaN(n)||isNaN(r)||isNaN(o))return null;let i=d=>d<=.04045?d/12.92:Math.pow((d+.055)/1.055,2.4),a=i(n),s=i(r),u=i(o),l=1.2249*a-.2247*s+0*u,c=-.042*a+1.0419*s+0*u,p=-.0197*a-.0786*s+1.0983*u,g=d=>{let f=Math.max(0,Math.min(1,d));return f<=.0031308?12.92*f:1.055*Math.pow(f,1/2.4)-.055};return[Math.round(g(l)*255),Math.round(g(c)*255),Math.round(g(p)*255)]}function mv(e,t,n){let r=S=>{let x=S/255;return x<=.04045?x/12.92:Math.pow((x+.055)/1.055,2.4)},o=r(e),i=r(t),a=r(n),s=o*.4124564+i*.3575761+a*.1804375,u=o*.2126729+i*.7151522+a*.072175,l=o*.0193339+i*.119192+a*.9503041,c=.95047,p=1,g=1.08883,d=S=>S>.008856?Math.cbrt(S):7.787*S+16/116,f=d(s/c),y=d(u/p),I=d(l/g);return[116*y-16,500*(f-y),200*(y-I)]}function hv(e,t){let[n,r,o]=mv(...e),[i,a,s]=mv(...t),u=(n+i)/2,l=Math.sqrt(r*r+o*o),c=Math.sqrt(a*a+s*s),p=(l+c)/2,g=.5*(1-Math.sqrt(Math.pow(p,7)/(Math.pow(p,7)+Math.pow(25,7)))),d=(1+g)*r,f=(1+g)*a,y=Math.sqrt(d*d+o*o),I=Math.sqrt(f*f+s*s),S=(y+I)/2,x=(Math.atan2(o,d)*180/Math.PI+360)%360,M=(Math.atan2(s,f)*180/Math.PI+360)%360,z=M-x;Math.abs(z)>180&&(z-=Math.sign(z)*360);let O=i-n,L=I-y,_=2*Math.sqrt(y*I)*Math.sin(z*Math.PI/360),m=Math.abs(x-M)>180?(x+M+360)/2:(x+M)/2,k=1-.17*Math.cos((m-30)*Math.PI/180)+.24*Math.cos(2*m*Math.PI/180)+.32*Math.cos((3*m+6)*Math.PI/180)-.2*Math.cos((4*m-63)*Math.PI/180),C=1+.015*Math.pow(u-50,2)/Math.sqrt(20+Math.pow(u-50,2)),E=1+.045*S,h=1+.015*S*k,b=-2*Math.sqrt(Math.pow(S,7)/(Math.pow(S,7)+Math.pow(25,7)))*Math.sin(60*Math.exp(-Math.pow((m-275)/25,2))*Math.PI/180);return Math.sqrt(Math.pow(O/C,2)+Math.pow(L/E,2)+Math.pow(_/h,2)+b*(L/E)*(_/h))}function xv(e){let t=(e.property||"").toLowerCase();if(!(t.includes("color")||t==="fill"||t==="background"||t==="backgroundcolor"))return!1;let r=String(e.expected||e.suggestedValue||""),o=String(e.actual||e.currentValue||""),i=Am(r)??Am(o),a=Fm(r)??Fm(o);return!i||!a||r===o?!1:hv(i,a)<5}function Hs(e){let t=String(e.expected??e.suggestedValue??""),n=String(e.actual??e.currentValue??"");if(!t||!n||t===n)return null;let r=fv(t),o=fv(n);return!r||!o?null:hv(r,o)}function Us(e){let t=e.severity||"minor";if(t==="minor")return t;if(xv(e))return"minor";let n=Hs(e);if(n!==null)return n<2?"minor":n<5&&t==="critical"?"major":t;let r=["width","height","size","dimension","dimensions","r","cx","cy"],o=["dimension","layout"],i=new Set((e.property||"").replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean)),a=(e.type||"").toLowerCase();if(!(r.some(d=>i.has(d))||o.some(d=>a===d)))return t;let u=String(e.expected||e.suggestedValue||""),l=String(e.actual||e.currentValue||""),c=parseFloat(u.replace(/[^0-9.-]/g,"")),p=parseFloat(l.replace(/[^0-9.-]/g,""));if(isNaN(c)||isNaN(p))return t;let g=Math.abs(c-p);return g<5?"minor":g<10&&t==="critical"?"major":t}function Zc(e,t,n){return e>0?"D":t>0?"C":n>0?"B":"A"}function eu(e){let t=e.filter(n=>!n.dismissed).map(n=>Us(n));return Zc(t.filter(n=>n==="critical").length,t.filter(n=>n==="major").length,t.filter(n=>n==="minor").length)}function Ho(e,t,n){let r=100-n*1-t*3-e*10,o=js[Zc(e,t,n)];return Math.max(0,Math.min(o,r))}var AL,js,Pm=$(()=>{"use strict";AL={white:[255,255,255],black:[0,0,0],red:[255,0,0],green:[0,128,0],blue:[0,0,255],yellow:[255,255,0],cyan:[0,255,255],aqua:[0,255,255],magenta:[255,0,255],fuchsia:[255,0,255],gray:[128,128,128],grey:[128,128,128],silver:[192,192,192],maroon:[128,0,0],olive:[128,128,0],lime:[0,255,0],teal:[0,128,128],navy:[0,0,128],purple:[128,0,128],orange:[255,165,0],pink:[255,192,203],brown:[165,42,42],gold:[255,215,0],beige:[245,245,220],ivory:[255,255,240],indigo:[75,0,130],violet:[238,130,238],coral:[255,127,80],salmon:[250,128,114],khaki:[240,230,140],crimson:[220,20,60],turquoise:[64,224,208],lightgray:[211,211,211],lightgrey:[211,211,211],darkgray:[169,169,169],darkgrey:[169,169,169],whitesmoke:[245,245,245],gainsboro:[220,220,220]};js={A:100,B:99,C:89,D:69}});function Ta(e,t={}){if(e==null)return"";let n=String(e).split(",")[0].trim().replace(/['"]/g,"").toLowerCase();return t.stripSeparators&&(n=n.replace(/[\s_-]/g,"")),n}function wv(e,t){let n=Ta(e,{stripSeparators:!0}),r=Ta(t,{stripSeparators:!0});return!n||!r||n===r?!1:PL.some(o=>o.has(n)&&o.has(r))}function bv(e){if(e==null)return null;let t=String(e).trim().toLowerCase();if(!t)return null;let n=t.replace(/[\s_-]/g,"");if(n in yv)return yv[n];let r=parseFloat(t.replace(/[^0-9.-]/g,""));return isNaN(r)?null:r}function vv(e,t){let n=bv(e),r=bv(t);return n==null||r==null?!1:Math.round(n/100)===Math.round(r/100)}var PL,yv,tu=$(()=>{"use strict";PL=[new Set(["applesystem","blinkmacsystemfont","systemui","webkitsystemfont","sfpro","sfprotext","sfprodisplay","sanfrancisco","sanfranciscopro","sanfranciscotext","sanfranciscodisplay"])];yv={thin:100,hairline:100,extralight:200,ultralight:200,light:300,normal:400,regular:400,book:400,medium:500,semibold:600,demibold:600,demi:600,bold:700,extrabold:800,ultrabold:800,black:900,heavy:900}});function Tv(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=a=>/^#[0-9a-f]{3,8}$/i.test(a)||a.includes("rgb")||["white","black","red","blue","green","orange","yellow","transparent"].includes(a);return!!(i(r)||i(o)||e.relatedProperties?.some(a=>{let s=a.property?.toLowerCase()||"";return s.includes("color")||s.includes("fill")||s.includes("background")}))}function DL(e){if(!Tv(e))return!1;let t=Hs(e);return t!==null&&t<2}function Sv(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 _L(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",a=t.includes("gap")||o.includes("gap");return i&&a}function NL(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&&Tv(n)||Sv(r)||Sv(o)||n&&_L(n))return!1;let i=parseFloat(r),a=parseFloat(o);if(isNaN(i)||isNaN(a))return!1;let s=Math.abs(i-a);if(r.includes("px")||o.includes("px")){let u=n?.property?.toLowerCase()||"";return u==="width"||u==="height"||u.includes("width")||u.includes("height")?s<Cv:s<kv}return r.includes("%")||o.includes("%")?s<1:!1}function OL(e){let t=`${e.description||""} ${e.title||""} ${e.suggestedFix||""}`.toLowerCase();if(zL.some(a=>t.includes(a))||!LL.some(a=>t.includes(a)))return!1;let o=e.expected||e.suggestedValue,i=e.actual||e.currentValue;return!(o&&i&&!Oi(o,i,e.property))}function $L(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 a=`${e.description||""} ${e.title||""}`.toLowerCase();return a.includes("container")||a.includes("svg ")||a.includes("<svg")||a.includes("wrapper")}function HL(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||"",a=e.actual||e.currentValue||"",s=parseFloat(i),u=parseFloat(a);return isNaN(s)||isNaN(u)?!1:Math.abs(s-u)<Iv}function UL(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(!BL.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 s=n.includes("hug")||n.includes("auto"),u=/\d+\.?\d*px/.test(r);if(!s||!u)return!1;let l=n.match(/(\d+\.?\d*)px/),c=r.match(/(\d+\.?\d*)px/);return!(l&&c&&Math.abs(parseFloat(l[1])-parseFloat(c[1]))>ML)}function jL(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 Ev(e){return(e||"").toLowerCase().replace(/[\s_-]/g,"")==="fontfamily"}function VL(e){return(e||"").toLowerCase().replace(/[\s_-]/g,"")==="fontweight"}function WL(e,t,n){if(!Ev(n))return!1;let r=Ta(e,{stripSeparators:!0}),o=Ta(t,{stripSeparators:!0});return r.length>0&&o.length>0&&r===o}function GL(e,t,n){return Ev(n)?wv(e,t):!1}function qL(e,t,n){return VL(n)?vv(e,t):!1}function Vs(e){let t=e.expected||e.suggestedValue,n=e.actual||e.currentValue;if(WL(t,n,e.property))return{dismissed:!0,dismissReason:"Auto-dismissed: font-family naming difference (same font)",dismissedBy:"post-ai-validation"};if(GL(t,n,e.property))return{dismissed:!0,dismissReason:"Auto-dismissed: system font stack equivalence (-apple-system renders as SF Pro)",dismissedBy:"post-ai-validation"};if(qL(t,n,e.property))return{dismissed:!0,dismissReason:"Auto-dismissed: font weight renders identically (same named weight)",dismissedBy:"post-ai-validation"};if(e.programmaticallyVerified)return{dismissed:!1};if(e.fixRequired===!1)return{dismissed:!0,dismissReason:"Auto-dismissed: FixRequired is false (no code change needed)",dismissedBy:"post-ai-validation"};if(Oi(t,n,e.property))return{dismissed:!0,dismissReason:"Auto-dismissed: expected equals actual (identical values)",dismissedBy:"post-ai-validation"};if(DL(e))return{dismissed:!0,dismissReason:`Auto-dismissed: imperceptible color difference (\u0394E < ${2})`,dismissedBy:"post-ai-validation"};if(e.fixRequired===!0)return{dismissed:!1};if(HL(e))return{dismissed:!0,dismissReason:`Auto-dismissed: text dimension variance (<${Iv}px) - font rendering difference, not actionable`,dismissedBy:"post-ai-validation"};if(NL(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")?Cv:kv}px)`,dismissedBy:"post-ai-validation"}}return jL(e)?{dismissed:!0,dismissReason:"Auto-dismissed: no measurable values to compare",dismissedBy:"post-ai-validation"}:OL(e)?{dismissed:!0,dismissReason:"Auto-dismissed: no fix needed",dismissedBy:"post-ai-validation"}:UL(e)?{dismissed:!0,dismissReason:"Auto-dismissed: HUG sizing - CSS auto-sizes content without explicit dimensions",dismissedBy:"post-ai-validation"}:$L(e)?{dismissed:!0,dismissReason:"Auto-dismissed: SVG container fill - child elements use their own fills",dismissedBy:"post-ai-validation"}:{dismissed:!1}}var kv,Cv,Iv,ML,LL,BL,zL,Rv=$(()=>{"use strict";Rm();Pm();tu();kv=.5,Cv=2,Iv=2,ML=5,LL=["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"],BL=["hug","auto (hug)","should be hug","fixed pixel values are being rendered","fixed values are being rendered"],zL=["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"]});var Av=$(()=>{"use strict"});var Fv=$(()=>{"use strict"});var nu=$(()=>{"use strict";Rm();Rv();Pm();Av();Fv()});var tB,nB,Roe,Lm=$(()=>{"use strict";tB=["flex","inline-flex"],nB=["grid","inline-grid"],Roe=[...tB,...nB]});var Mv=$(()=>{"use strict";nu();Lm()});var Lv=$(()=>{"use strict"});var Bv=$(()=>{"use strict"});var zv=$(()=>{"use strict"});var Bm=$(()=>{"use strict";tu()});var Dv=$(()=>{"use strict";Bm();nu()});var _v=$(()=>{"use strict"});var Nv=$(()=>{"use strict"});function ru(e){return typeof e=="string"&&e.startsWith("element:")}function $v(e){return!e||e.length===0?"":` (${e.slice(0,Ov).join(", ")}${e.length>Ov?", \u2026":""})`}function Hv(e){let t=String(e.property).slice(8),[n,r]=oB[t]??[t,`${t}s`],o=Number(e.expected),i=Number(e.actual),a=o>i,s=Math.abs(o-i),u=l=>l===1?n:r;return{title:`${a?"Missing":"Extra"} ${s===1?n:`${s} ${r}`} in code`,description:`Design has ${o} ${u(o)}${$v(e.elements?.figma)}; code renders ${i}${$v(e.elements?.code)}. `+(a?`${s===1?"One is":`${s} are`} in the design but not implemented.`:`${s===1?"One is":`${s} are`} rendered but not in the design.`),suggested:`${o} ${u(o)}`,current:`${i} ${u(i)}`}}var oB,Ov,Uv=$(()=>{"use strict";oB={icon:["icon","icons"],text:["text element","text elements"],image:["image","images"],shape:["shape","shapes"]},Ov=4});var jv=$(()=>{"use strict"});function Vv(e,t){let n=e?.split("/").pop()?.trim();return n||(t?.trim()??"")}var Wv=$(()=>{"use strict"});var Gv=$(()=>{"use strict"});var qv=$(()=>{"use strict";Bv();zv();Bm();Dv();_v();Nv();Uv();jv();Wv();Gv()});var Yv=$(()=>{"use strict";tu()});var Ws,Kv=$(()=>{"use strict";Ws={admin:{enableFixGeneration:!1,enableFixApply:!0,enableAutoMap:!0,enableAutoFigmaLinking:!0,enableReviewBadges:!0,showCosts:!0,enableParallelReview:!0,enableModelSelection:!0},beta:{enableFixGeneration:!1,enableFixApply:!1,enableAutoMap:!1,enableAutoFigmaLinking:!0,enableReviewBadges:!0,showCosts:!1,enableParallelReview:!0,enableModelSelection:!1},anonymous:{enableFixGeneration:!1,enableFixApply:!1,enableAutoMap:!1,enableAutoFigmaLinking:!0,enableReviewBadges:!0,showCosts:!1,enableParallelReview:!0,enableModelSelection:!1}}});var on=$(()=>{"use strict";kp();Ry();Ay();nu();Lm();Mv();Lv();qv();Yv();Kv()});function iB(e){let{aiPrompt:t,aiResponse:n,...r}=e;return r}function Cr(e){try{let t=e.map(iB),n=JSON.stringify(t,aB);sessionStorage.setItem(zm,n)}catch(t){w.error("[SessionStorage] Failed to save review history:",t)}}function Dm(){try{let e=sessionStorage.getItem(zm);if(!e)return[];let t=JSON.parse(e,sB);return Array.isArray(t)?t:[]}catch(e){return w.error("[SessionStorage] Failed to load review history:",e),[]}}function Xv(){try{let e=Dm();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,...a}=r;return a}return r});t&&(Cr(n),w.debug("[SessionStorage] Stripped aiPrompt/aiResponse from existing review history"))}catch(e){w.error("[SessionStorage] Failed to strip sensitive fields:",e)}}function Jv(){try{sessionStorage.removeItem(zm),w.debug("[SessionStorage] Review history cleared")}catch(e){w.error("[SessionStorage] Failed to clear review history:",e)}}function aB(e,t){return t instanceof Date?{__type:"Date",value:t.toISOString()}:t}function sB(e,t){return t&&t.__type==="Date"?new Date(t.value):t}var zm,_m=$(()=>{"use strict";He();zm="uicopilot_review_history"});import lB,{createContext as cB,useContext as uB,useReducer as dB,useMemo as Qv,useRef as pB,useEffect as gB}from"react";function ou(e){let t=e.length>Zv?e.slice(e.length-Zv):e,n=Math.max(0,t.length-fB);return n===0?t:t.map((r,o)=>{if(o>=n)return r;let i=r.storybookImageData?.startsWith("data:"),a=r.figmaImageData?.startsWith("data:");return!i&&!a?r:{...r,storybookImageData:i?void 0:r.storybookImageData,figmaImageData:a?void 0:r.figmaImageData}})}function mB(e,t){switch(t.type){case"SET_STATE":return{...e,...t.payload};case"REQUEST_REVIEW_RETRY":return{...e,reviewRetryNonce:e.reviewRetryNonce+1};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:t.payload.storybookImageData||e.storybookImageUrl||void 0,figmaImageData:t.payload.figmaImageData||e.figmaImageUrl||void 0,figmaComponentProperties:t.payload.figmaComponentProperties,aiPrompt:n&&e.fullPrompt||void 0,aiResponse:n&&e.fullResponse||void 0,costUsd:t.payload.costUsd,inputTokens:t.payload.inputTokens,outputTokens:t.payload.outputTokens,reviewDurationMs:t.payload.reviewDurationMs},o=e.reviewHistory.findIndex(a=>a.id===t.payload.id),i;return o>=0?i=e.reviewHistory.map((a,s)=>s===o?r:a):i=[...e.reviewHistory,r],i=ou(i),Cr(i),{...e,reviewResults:t.payload,reviewHistory:i,currentReviewId:t.payload.id,isNewReviewMode:!1}}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":{if(t.payload.length===0)return e;let n=new Map(e.reviewHistory.map(a=>[a.id,a])),r=!1,o=e.reviewHistory.slice();for(let a of t.payload){let s=n.get(a.id);if(!s){o.push(a),r=!0;continue}let u=a.issues?.length??0,l=s.issues?.length??0;if(u>l){let c=o.indexOf(s);c!==-1&&(o[c]=a,r=!0)}}if(!r)return e;let i=ou(o);return Cr(i),{...e,reviewHistory:i}}case"ADD_REVIEW":{let n=ou([...e.reviewHistory,t.payload]);return Cr(n),{...e,reviewHistory:n,currentReviewId:t.payload.id,isNewReviewMode:!1}}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 Cr(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 Cr(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 Cr(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 a=n.get(i.id);return a?{...i,generatedFix:i.generatedFix?{...i.generatedFix,...a}:a,selectedForFix:a?.status==="failed"?!1:i.selectedForFix}:i})});return Cr(r),{...e,reviewHistory:r}}case"DISMISS_ISSUE":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>{if(r.id!==e.currentReviewId)return r;let o=r.issues.map(l=>l.id===t.payload.issueId?{...l,dismissed:!0,dismissReason:t.payload.reason,dismissedAt:new Date,dismissedBy:t.payload.dismissedBy}:l),i=o.filter(l=>!l.dismissed),a=i.filter(l=>l.severity==="critical").length,s=i.filter(l=>l.severity==="major").length,u=i.filter(l=>l.severity==="minor").length;return{...r,issues:o,complianceScore:Ho(a,s,u),issuesCount:i.length}});return Cr(n),{...e,reviewHistory:n}}case"UNDISMISS_ISSUE":{if(!e.currentReviewId)return e;let n=e.reviewHistory.map(r=>{if(r.id!==e.currentReviewId)return r;let o=r.issues.map(l=>l.id===t.payload?{...l,dismissed:!1,dismissReason:void 0,dismissedAt:void 0}:l),i=o.filter(l=>!l.dismissed),a=i.filter(l=>l.severity==="critical").length,s=i.filter(l=>l.severity==="major").length,u=i.filter(l=>l.severity==="minor").length;return{...r,issues:o,complianceScore:Ho(a,s,u),issuesCount:i.length}});return Cr(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(l=>!l.dismissed),i=o.filter(l=>l.severity==="critical").length,a=o.filter(l=>l.severity==="major").length,s=o.filter(l=>l.severity==="minor").length,u=Ho(i,a,s);return w.debug(`[recalculateScore] Active: ${o.length}, score: ${u}`),{...r,complianceScore:u,issuesCount:o.length}});return Cr(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 Cr(n),{...e,reviewHistory:n}}case"CLEAR_ALL_REVIEWS":return Jv(),{...e,reviewHistory:[],currentReviewId:null};case"CLEAR_STALE_REVIEWS":return{...e,currentReviewId:null,reviewResults:null,isNewReviewMode:!1};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 Om({children:e}){let[t,n]=dB(mB,wB),r=pB(t);gB(()=>{r.current=t},[t]);let o=Qv(()=>({setIsReviewing:a=>n({type:"SET_STATE",payload:{isReviewing:a}}),setReviewingStoryId:a=>n({type:"SET_STATE",payload:{reviewingStoryId:a}}),setReviewError:a=>n({type:"SET_STATE",payload:{reviewError:a}}),requestReviewRetry:()=>n({type:"REQUEST_REVIEW_RETRY"}),bulkAddReviews:a=>n({type:"BULK_ADD_REVIEWS",payload:a}),setReviewResults:a=>n({type:"SET_REVIEW_RESULTS",payload:a}),setMultiModelResults:a=>n({type:"SET_STATE",payload:{multiModelResults:a}}),updateMultiModelStreamingMessages:(a,s)=>n({type:"UPDATE_MULTI_MODEL_STREAMING",payload:{modelId:a,messages:s}}),setModelCompleted:a=>n({type:"SET_MODEL_COMPLETED",payload:a}),setActiveModelId:a=>{let s=r.current;s.multiModelResults&&n({type:"SET_STATE",payload:{multiModelResults:{...s.multiModelResults,activeModelId:a}}})},setShowReviewMenu:a=>n({type:"SET_STATE",payload:{showReviewMenu:a}}),setSeverityFilter:a=>n({type:"SET_STATE",payload:{severityFilter:a}}),setShowStreamingPanel:a=>n({type:"SET_STATE",payload:{showStreamingPanel:a}}),setStreamingPanelCollapsed:a=>n({type:"SET_STATE",payload:{streamingPanelCollapsed:a}}),addStreamingMessage:a=>n({type:"ADD_STREAMING_MESSAGE",payload:a}),updateStreamingMessage:(a,s)=>n({type:"UPDATE_STREAMING_MESSAGE",payload:{index:a,content:s}}),clearStreamingMessages:()=>n({type:"CLEAR_STREAMING_MESSAGES"}),setStreamingProgress:a=>n({type:"SET_STATE",payload:{streamingProgress:a}}),setStreamingStatus:a=>n({type:"SET_STATE",payload:{streamingStatus:a}}),setReviewDetailTab:a=>n({type:"SET_STATE",payload:{reviewDetailTab:a}}),setFullPrompt:a=>n({type:"SET_STATE",payload:{fullPrompt:a}}),setFullResponse:a=>n({type:"SET_STATE",payload:{fullResponse:a}}),setFigmaImageUrl:a=>n({type:"SET_STATE",payload:{figmaImageUrl:a}}),setStorybookImageUrl:a=>n({type:"SET_STATE",payload:{storybookImageUrl:a}}),setFigmaDimensions:a=>n({type:"SET_STATE",payload:{figmaDimensions:a}}),setSelectedModels:a=>n({type:"SET_STATE",payload:{selectedModels:a}}),toggleModel:a=>n({type:"TOGGLE_MODEL",payload:a}),setModelComparisonView:a=>n({type:"SET_STATE",payload:{modelComparisonView:a}}),resetReview:()=>n({type:"RESET_REVIEW"}),addReview:a=>n({type:"ADD_REVIEW",payload:a}),getCurrentReview:()=>{let a=r.current;return a.currentReviewId&&a.reviewHistory.find(s=>s.id===a.currentReviewId)||null},getReviewById:a=>r.current.reviewHistory.find(s=>s.id===a)||null,getParentReview:()=>{let a=r.current,s=a.reviewHistory.find(u=>u.id===a.currentReviewId);return s?.parentReviewId&&a.reviewHistory.find(u=>u.id===s.parentReviewId)||null},hasAppliedFixes:()=>{let a=r.current,s=a.reviewHistory.find(u=>u.id===a.currentReviewId);return!s||!Array.isArray(s.issues)||s.issues.length===0?!1:s.issues.some(u=>u.status==="applied"||u.generatedFix?.status==="applied")},toggleIssueSelection:a=>n({type:"TOGGLE_ISSUE_SELECTION",payload:a}),updateIssueStatus:(a,s,u)=>n({type:"UPDATE_ISSUE_STATUS",payload:{issueId:a,status:s,error:u}}),updateIssueGeneratedFix:(a,s)=>n({type:"UPDATE_ISSUE_GENERATED_FIX",payload:{issueId:a,generatedFix:s}}),batchUpdateIssueGeneratedFixes:a=>n({type:"BATCH_UPDATE_ISSUE_GENERATED_FIXES",payload:a}),dismissIssue:(a,s,u)=>n({type:"DISMISS_ISSUE",payload:{issueId:a,reason:s,dismissedBy:u}}),undismissIssue:a=>n({type:"UNDISMISS_ISSUE",payload:a}),recalculateScore:()=>n({type:"RECALCULATE_SCORE"}),updateReviewScore:(a,s)=>n({type:"UPDATE_REVIEW_SCORE",payload:{reviewId:a,newScore:s}}),clearAllReviews:()=>n({type:"CLEAR_ALL_REVIEWS"}),clearStaleReviewsForStory:a=>n({type:"CLEAR_STALE_REVIEWS",payload:a}),setIsApplying:a=>n({type:"SET_STATE",payload:{isApplying:a}}),setApplyFixesResult:a=>n({type:"SET_STATE",payload:{applyFixesResult:a}}),setIncludeComponentIssues:a=>n({type:"SET_STATE",payload:{includeComponentIssues:a}}),setIncludeTextComparison:a=>n({type:"SET_STATE",payload:{includeTextComparison:a}}),setUsePromptCache:a=>n({type:"SET_STATE",payload:{usePromptCache:a}}),setIsValidating:a=>n({type:"SET_STATE",payload:{isValidating:a}}),setIsSpecChecking:a=>n({type:"SET_STATE",payload:{isSpecChecking:a}}),setReviewHistoryLoading:a=>n({type:"SET_STATE",payload:{reviewHistoryLoading:a}}),setValidationUsage:a=>n({type:"SET_STATE",payload:{validationUsage:a}}),setWorkspacePath:a=>n({type:"SET_STATE",payload:{workspacePath:a}}),triggerScreenshotRefresh:()=>n({type:"TRIGGER_SCREENSHOT_REFRESH"}),setHoveredIssueId:a=>n({type:"SET_STATE",payload:{hoveredIssueId:a}}),setNewReviewMode:a=>n({type:"SET_STATE",payload:{isNewReviewMode:a}}),setPendingSettingsOpen:a=>n({type:"SET_STATE",payload:{pendingSettingsOpen:a}}),setFeatureFlags:a=>n({type:"SET_STATE",payload:{featureFlags:a}}),setUserRole:a=>n({type:"SET_STATE",payload:{userRole:a}}),setRoleOverride:a=>{try{a?localStorage.setItem("uicopilot_role_override",a):localStorage.removeItem("uicopilot_role_override")}catch{}n({type:"SET_STATE",payload:{roleOverride:a}})},setReviewAllConcurrency:a=>{let s=Math.max(1,Math.min(5,a));try{localStorage.setItem("uicopilot_review_all_concurrency",String(s))}catch{}n({type:"SET_STATE",payload:{reviewAllConcurrency:s}})},setIsGenerating:a=>n({type:"SET_STATE",payload:{isGenerating:a}}),setGeneratedPrompt:a=>n({type:"SET_STATE",payload:{generatedPrompt:a}}),setPromptError:a=>n({type:"SET_STATE",payload:{promptError:a}}),resetPrompt:()=>n({type:"RESET_PROMPT"})}),[]),i=Qv(()=>({...t,...o}),[t,o]);return lB.createElement(eS.Provider,{value:i},e)}function ge(){let e=uB(eS);if(!e)throw new Error("useReviewStore must be used within a ReviewProvider");return e}var Zv,fB,hB,xB,Nm,yB,bB,wB,eS,$m=$(()=>{"use strict";on();_m();He();Zv=20,fB=5;hB=()=>{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},xB=()=>{if(typeof localStorage>"u")return null;try{let e=localStorage.getItem("uicopilot_role_override");if(e==="admin"||e==="beta")return e}catch{}return null},Nm={enableFixGeneration:!1,enableFixApply:!1,enableAutoMap:!1,enableAutoFigmaLinking:!1,enableReviewBadges:!1,showCosts:!1,enableParallelReview:!1,enableModelSelection:!1},yB=()=>{if(typeof localStorage>"u")return Nm;try{let e=localStorage.getItem("uicopilot_feature_flags");if(!e)return Nm;let t=JSON.parse(e);return{enableFixGeneration:!!t.enableFixGeneration,enableFixApply:!!t.enableFixApply,enableAutoMap:!!t.enableAutoMap,enableAutoFigmaLinking:!!t.enableAutoFigmaLinking,enableReviewBadges:!!t.enableReviewBadges,showCosts:!!t.showCosts,enableParallelReview:!!t.enableParallelReview,enableModelSelection:!!t.enableModelSelection}}catch{}return Nm},bB=()=>{if(typeof localStorage>"u")return"beta";try{let e=localStorage.getItem("uicopilot_user_role");if(e==="admin"||e==="beta")return e}catch{}return"beta"},wB={isReviewing:!1,reviewingStoryId:null,reviewError:null,reviewRetryNonce:0,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-6"],modelComparisonView:"side-by-side",reviewHistory:ou(Dm()),currentReviewId:null,includeComponentIssues:!0,includeTextComparison:!1,usePromptCache:!1,isApplying:!1,applyFixesResult:null,screenshotRefreshKey:0,isValidating:!1,isSpecChecking:!1,reviewHistoryLoading:!1,validationUsage:null,lastAiCallTimestamp:null,aiRateLimitSeconds:0,isGenerating:!1,generatedPrompt:null,promptError:null,workspacePath:null,userRole:bB(),roleOverride:xB(),featureFlags:yB(),reviewAllConcurrency:hB(),hoveredIssueId:null,isNewReviewMode:!1,pendingSettingsOpen:!1},eS=cB(null)});import Gs,{useMemo as vB}from"react";function Um({children:e}){return Gs.createElement(xp,null,Gs.createElement(bp,null,Gs.createElement(vp,null,Gs.createElement(Om,null,Gs.createElement(SB,null),e))))}function tS(e){let t=ye(),n=Ke(),r=pt(),o=ge(),i=vB(()=>({...t,...n,...r,...o}),[t,n,r,o]);return e?e(i):i}function SB(){return Hm=tS(),null}var Hm,St,nS=$(()=>{"use strict";yp();wp();Sp();$m();Hm=null,St=Object.assign(tS,{getState:()=>{if(!Hm)throw new Error("Store not initialized. Make sure StoreProvider is mounted.");return Hm}})});var ke=$(()=>{"use strict";nS();yp();wp();Sp();$m()});function K(){return(process.env.STORYBOOK_UICOPILOT_URL||kB).replace(/\/$/,"")}var kB,rS,De=$(()=>{"use strict";kB="https://app.uiparity.com";rS=3.6});async function Z(e,t,n=3e4){let r=new AbortController,o=setTimeout(()=>r.abort(),n);try{return await fetch(e,{...t,signal:r.signal})}catch(i){throw i instanceof DOMException&&i.name==="AbortError"?new Error(`Request timed out after ${n}ms: ${e}`):i}finally{clearTimeout(o)}}var ct=$(()=>{"use strict"});import{useEffect as li,useState as cu,useRef as vS,useCallback as Km}from"react";import{addons as Xm}from"storybook/manager-api";async function Bz(e,t,n){let r=`${e}:${t}`,o=Jm.get(r);if(o)return w.debug("[useReviewScreenshots] Reusing in-flight Figma image fetch for",r),o;let i=(async()=>{let a=await Z(`${TS}/api/figma/image?projectId=${e}&nodeId=${t}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`}});return a.ok?a.json():{imageUrl:null}})().finally(()=>{Jm.delete(r)});return Jm.set(r,i),i}function zz(e,t,n){try{sessionStorage.setItem(`${uu}${e}`,JSON.stringify({figmaNodeId:t,imageUrl:n,timestamp:Date.now()}))}catch{}}function Dz(e,t){try{let n=sessionStorage.getItem(`${uu}${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(`${uu}${e}`)}catch{}return null}function _z(e){try{let t=sessionStorage.getItem(`${uu}${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 SS,kS,CS,IS,Aa,TS,Yn,Qm,Jm,uu,ES,RS,$i,Fa=$(()=>{"use strict";ke();Zm();He();De();ct();SS="storyArgsUpdated",kS="storyRendered",CS="forceRemount",IS=null,Aa=()=>IS,TS=K(),Yn=new Map,Qm=null,Jm=new Map;uu="uicopilot-figma-image-";ES=(e,t,n)=>{let r=Yn.get(e);r?(r.storybookImageUrl=t,n&&(r.figmaImageUrl=n)):Yn.set(e,{storybookImageUrl:t,figmaImageUrl:n??null}),w.debug("[useReviewScreenshots] Populated historical screenshots for story:",e)},RS=(e,t,n)=>{Qm=t;let r=Yn.get(e);r?r.figmaImageUrl=n:Yn.set(e,{storybookImageUrl:null,figmaImageUrl:n}),w.debug("[useReviewScreenshots] Pre-set Figma image for mapping:",{storyId:e,figmaNodeId:t,imageUrl:n.substring(0,50)+"..."})},$i=()=>{let[e,t]=cu(!1),[n,r]=cu(!1),[o,i]=cu(!1),[a,s]=cu(null),u=vS(null),{screenshotRefreshKey:l,triggerScreenshotRefresh:c}=ge(),p=Km(()=>{let L=St.getState().currentStoryId;L&&(w.debug("[useReviewScreenshots] Refreshing screenshots for story:",L),Yn.delete(L),u.current=null,i(!0),c())},[c]),g=Km(()=>{let L=St.getState().currentStoryId;if(L){w.debug("[useReviewScreenshots] Refreshing Storybook screenshot only for story:",L);let _=Yn.get(L);_&&(_.storybookImageUrl=null),u.current=null,i(!0),c()}},[c]),{sessionToken:d}=ye(),{selectedProjectId:f}=Ke(),{currentStoryId:y,currentMapping:I,loadingMapping:S}=pt(),{setStorybookImageUrl:x,setFigmaImageUrl:M}=ge(),z=vS(null);li(()=>{y&&z.current&&z.current!==y&&(w.debug("[useReviewScreenshots] Story switched, clearing images"),x(""),M("")),z.current=y},[y,x,M]),li(()=>{!y||S||I||M("")},[y,I,S,M]),li(()=>{if(!y)return;let L=_z(y);L&&(w.debug("[useReviewScreenshots] Quick-restored Figma image for:",y),M(L))},[y,M]),li(()=>{if(!y||S)return;let L=I?.figmaFileUrl;if(L){w.debug("[useReviewScreenshots] Restoring Figma image from mapping.figmaFileUrl for:",y),M(L);let _=Yn.get(y);_?_.figmaImageUrl=L:Yn.set(y,{storybookImageUrl:null,figmaImageUrl:L})}},[y,I,S,M]),li(()=>{let L=!1;return(async()=>{if(!d||!f||!y){w.debug("[useReviewScreenshots] Missing required context, skipping auto-load");return}u.current&&u.current!==y&&(w.debug("[useReviewScreenshots] Story changed, clearing stale screenshots"),x(""),M(""));let m=St.getState();if(u.current===y&&m.storybookImageUrl&&m.figmaImageUrl){w.debug("[useReviewScreenshots] Screenshots already loaded for this story, skipping capture");return}let k=I?.figmaNodeId??null;if(k!==Qm){w.debug("[useReviewScreenshots] Figma mapping changed, invalidating Figma image only for story:",y);let B=Yn.get(y);B&&(B.figmaImageUrl=null),Qm=k,u.current=null}let C=I?.figmaNodeId;if(C&&!Yn.get(y)?.figmaImageUrl){let B=Dz(y,C);if(B){w.debug("[useReviewScreenshots] Hydrated Figma image from sessionStorage for story:",y),M(B);let P=Yn.get(y);P?P.figmaImageUrl=B:Yn.set(y,{storybookImageUrl:null,figmaImageUrl:B})}}let E=Yn.get(y),h=E&&E.storybookImageUrl&&E.figmaImageUrl,b=E&&E.storybookImageUrl&&!E.figmaImageUrl,R=E&&!E.storybookImageUrl&&E.figmaImageUrl;if(h){w.debug("[useReviewScreenshots] Using fully cached screenshots for story:",y),x(E.storybookImageUrl),M(E.figmaImageUrl),u.current=y;return}let v=b&&I?.figmaNodeId;v&&(w.debug("[useReviewScreenshots] Using cached Storybook, fetching new Figma for story:",y),x(E.storybookImageUrl));let A=R;if(A&&(w.debug("[useReviewScreenshots] Using cached Figma, recapturing Storybook for story:",y),M(E.figmaImageUrl)),u.current===y&&I?.figmaNodeId){w.debug("[useReviewScreenshots] Screenshots already loaded for this story, skipping");return}try{if(s(null),v?r(!0):(A||(t(!0),r(!0)),i(!0)),u.current=y,L)return;let B=A?E.figmaImageUrl:null,P;if(A)w.debug("[useReviewScreenshots] Figma cached (storybookOnlyRefresh), skipping fetch"),r(!1);else if(C){w.debug("[useReviewScreenshots] Found Figma node ID from mapping:",C);let T=null;try{w.debug("[useReviewScreenshots] Fetching Figma image (with caching)...");let D=await Bz(f,C,d);T=D.imageUrl||null;let H=D.cached?"(cached)":"(fresh)";w.debug(`[useReviewScreenshots] Figma image fetched ${H}:`,T?"success":"not found")}catch(D){w.warn("[useReviewScreenshots] Failed to fetch Figma image:",D)}if(T)try{w.debug("[useReviewScreenshots] Fetching Figma image via proxy...");let D=`${TS}/api/proxy/image?url=${encodeURIComponent(T)}`,H=await Z(D);if(H.ok){let F=await H.blob(),re=new FileReader,j=await new Promise((J,ne)=>{re.onloadend=()=>J(re.result),re.onerror=ne,re.readAsDataURL(F)});B=j,M(j),w.debug("[useReviewScreenshots] Figma image loaded via proxy");let Y=new Image;await new Promise(J=>{Y.onload=()=>{P={width:Y.naturalWidth,height:Y.naturalHeight},w.debug("[useReviewScreenshots] Figma dimensions:",P),J()},Y.onerror=()=>J(),Y.src=j})}else B=T,M(T),w.warn("[useReviewScreenshots] Proxy failed, using direct URL as fallback")}catch(D){w.warn("[useReviewScreenshots] Proxy error, using direct URL as fallback:",D),B=T,M(T)}else w.warn("[useReviewScreenshots] No thumbnail found for node:",C),M(null);B&&C&&zz(y,C,B),r(!1)}else w.debug("[useReviewScreenshots] No Figma mapping exists for this component"),M(null),r(!1);let N=E?.storybookImageUrl||null;if(N)w.debug("[useReviewScreenshots] Using cached Storybook screenshot"),i(!1);else{w.debug("[useReviewScreenshots] Capturing Storybook screenshot for story:",y);let T=await du({storyId:y,sessionToken:d||void 0,...P&&{figmaWidth:P.width,figmaHeight:P.height}});T&&!L?(N=T,x(T),w.debug("[useReviewScreenshots] Storybook screenshot captured at dimensions:",P||"natural")):w.warn("[useReviewScreenshots] Failed to capture Storybook screenshot"),i(!1)}Yn.set(y,{storybookImageUrl:N,figmaImageUrl:B}),w.debug("[useReviewScreenshots] Screenshots cached for story:",y)}catch(B){w.error("[useReviewScreenshots] Error loading screenshots:",B),s(B instanceof Error?B.message:"Failed to load screenshots"),u.current=null,r(!1),i(!1)}finally{t(!1)}})(),()=>{L=!0}},[d,f,y,I?.figmaNodeId,l]),li(()=>{let L=Xm.getChannel(),_=null,m=k=>{IS=k.args,w.debug("[useReviewScreenshots] Args updated for story:",k.storyId,"args:",k.args),_&&clearTimeout(_),_=setTimeout(()=>{w.debug("[useReviewScreenshots] Story args changed, refreshing screenshot"),p()},500)};return L.on(SS,m),()=>{L.off(SS,m),_&&clearTimeout(_)}},[p]),li(()=>{let L=Xm.getChannel(),_=!1,m=null,k=()=>{w.debug("[useReviewScreenshots] FORCE_REMOUNT detected, showing Storybook loader"),_=!0,i(!0)},C=()=>{_&&(w.debug("[useReviewScreenshots] STORY_RENDERED after remount, waiting for styles to settle..."),m&&clearTimeout(m),m=setTimeout(()=>{_=!1,w.debug("[useReviewScreenshots] Refreshing Storybook screenshot after HMR (preserving Figma)"),g()},500))};return L.on(CS,k),L.on(kS,C),()=>{L.off(CS,k),L.off(kS,C),m&&clearTimeout(m)}},[g]),li(()=>{let L=Xm.getChannel(),_=async m=>{if(!m?.snapshot?.html){w.debug("[useReviewScreenshots] DOM mutated but no snapshot available");return}w.debug("[useReviewScreenshots] DOM mutated, capturing snapshot screenshot"),i(!0);try{let k=St.getState().currentStoryId,C=await fetch("/__uicopilot/screenshot-snapshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...m.snapshot,storyId:k})});if(C.ok){let E=await C.json();if(E.screenshot){x(E.screenshot);let h=St.getState().currentStoryId;if(h){let b=Yn.get(h);b?b.storybookImageUrl=E.screenshot:Yn.set(h,{storybookImageUrl:E.screenshot,figmaImageUrl:null})}}}else w.error("[useReviewScreenshots] Snapshot screenshot failed:",await C.text())}catch(k){w.error("[useReviewScreenshots] Snapshot screenshot error:",k)}finally{i(!1)}};return L.on("UICOPILOT/STORY_DOM_MUTATED",_),()=>{L.off("UICOPILOT/STORY_DOM_MUTATED",_)}},[]);let O=Km((L,_,m)=>{w.debug("[useReviewScreenshots] setFigmaImageDirect called - bypassing load"),RS(L,_,m),M(m),r(!1),u.current=L},[M]);return{isLoadingScreenshots:e,isLoadingFigma:n,isLoadingStorybook:o,screenshotError:a,refreshScreenshots:p,refreshStorybookOnly:g,setFigmaImageDirect:O}}});function pu(e){let r=e.ownerDocument?.defaultView;if(!r)return e.firstElementChild??e;let o=e.getBoundingClientRect(),i=u=>{let l=r.getComputedStyle(u);if(l.position==="fixed"||l.display==="none"||l.visibility==="hidden")return!0;let c=u.getBoundingClientRect();return c.width===0||c.height===0||u.children.length===0&&!(u.textContent??"").trim()},a=u=>{if(o.width===0||o.height===0)return!1;let l=u.getBoundingClientRect();return l.width>=o.width*.9&&l.height>=o.height*.9},s=e;for(let u=0;u<6;u+=1){let l=Array.from(s.children).filter(c=>!i(c));if(l.length!==1||s!==e&&!a(s))break;s=l[0]}return s===e?e.firstElementChild??e:s}var eh=$(()=>{"use strict"});function Oz(){return!K().startsWith("http://localhost")}function $z(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 AS(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=$z(o,t,n);return r.set(o,i),i})}async function Hz(){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.getElementById("storybook-root")||t.contentDocument.getElementById("root");if(!n)throw new Error("Story root not found in iframe");let r=pu(n);if(!r)throw new Error("Story element not found in iframe");let o=t.contentWindow,i=t.contentDocument;return(await e(r,{useCORS:!0,logging:!1,backgroundColor:null,scale:1,onclone:s=>{s.querySelectorAll("style").forEach(l=>{let c=l.textContent||"";/(?:color|oklch|oklab|lab|lch)\(/.test(c)&&(l.textContent=AS(c,i,o))});let u=Array.from(i.styleSheets);s.querySelectorAll('link[rel="stylesheet"]').forEach(l=>{let c=l.href,p=u.find(g=>g.href===c);if(p)try{let g="";for(let d of Array.from(p.cssRules))g+=d.cssText+`
|
|
13
13
|
`;if(/(?:color|oklch|oklab|lab|lch)\(/.test(g)){let d=s.createElement("style");d.textContent=AS(g,i,o),l.replaceWith(d)}}catch{}})}})).toDataURL("image/png")}function Uz(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 jz(e,t){w.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 Z(`${Nz}/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 Vz(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),a=r.slice(o+1);typeof a=="string"&&(a==="!true"?a=!0:a==="!false"?a=!1:!isNaN(Number(a))&&a!==""?a=Number(a):a=decodeURIComponent(a.replace(/\+/g," "))),t[i]=a}return t}function Wz(e){let t=new URLSearchParams(window.location.search),n=e;if(n||(n=(t.get("path")||"").replace("/story/","").replace("/docs/",""),w.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}`,a=Aa();if(!a||Object.keys(a).length===0){let s=t.get("args");s&&(a=Vz(s),w.debug("[Screenshot] Parsed args from URL:",a))}if(a&&Object.keys(a).length>0){let s=Uz(a);i+=`&args=${s}`,w.debug("[Screenshot] Using URL with current args:",i)}else w.debug("[Screenshot] No current args, using default URL:",i);return i}async function Gz(e){try{let t=await fetch(`/__uicopilot/screenshot?storyId=${encodeURIComponent(e)}`);if(t.status===501)return w.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 w.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 du(e){let t=e?.storyId||qz();if(t){let n=th.get(t);if(n)return w.debug("[Screenshot] Reusing in-flight capture for",t),n;let r=FS(t,e).finally(()=>{th.delete(t)});return th.set(t,r),r}return FS(void 0,e)}async function FS(e,t){try{if(e){let n=await Gz(e);if(n)return n}if(!Oz()){let n=Wz(t?.storyId);return await jz(n,{...t,selector:"#storybook-root > *"})}return w.info("[Screenshot] Using client-side capture (html2canvas fallback)"),await Hz()}catch(n){throw w.error("Error capturing screenshot:",n),new Error(`Failed to capture screenshot: ${n instanceof Error?n.message:"Unknown error"}`)}}function qz(){return(new URLSearchParams(window.location.search).get("path")||"").replace("/story/","").replace("/docs/","")||void 0}var Nz,th,Zm=$(()=>{"use strict";De();Fa();He();ct();eh();Nz=K();th=new Map});function er(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,a=i?parseFloat(i):1;return a<1?`rgba(${n}, ${r}, ${o}, ${a})`:`#${[n,r,o].map(u=>parseInt(u).toString(16).padStart(2,"0")).join("")}`}function dr(e,t){let r={backgroundColor:["transparent","rgba(0, 0, 0, 0)"],border:["none","0px none","0px none rgb(0, 0, 0)"],borderRadius:["0px"],boxShadow:["none"],opacity:["1"],gap:["normal","0px"],flexDirection:["row"],justifyContent:["normal","flex-start"],alignItems:["normal","stretch"],textAlign:["start","left"],letterSpacing:["normal","0px"],margin:["0px","0px 0px 0px 0px"],padding:["0px","0px 0px 0px 0px"]}[e];return r?r.includes(t):!1}function Qs(e){return e.split(",").map(n=>n.trim().replace(/['"]/g,""))[0]||e}function PS(e){let t=e.ownerDocument,r=(t.defaultView||window).getComputedStyle(e);if("fonts"in t){let I=r.fontSize||"16px",S=r.fontWeight||"400";if(r.fontFamily.includes("Roboto")){let x=t.fonts.check(`${S} ${I} Roboto`);if(w.debug("[computedStyles] Roboto check:",{cssFamily:r.fontFamily,robotoLoaded:x,fontWeight:S,fontSize:I,isIframe:t!==document,fontStatus:Array.from(t.fonts).map(M=>({family:M.family,status:M.status}))}),x)return"Roboto"}}let o="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",a=t.createElement("canvas").getContext("2d");if(!a)return"unknown";let s=r.fontSize,u=r.fontWeight,l=r.fontStyle,c=r.fontFamily.split(",").map(I=>I.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([...c,...p])];a.font=`${l} ${u} ${s} monospace`;let d=a.measureText(o).width,f="unknown",y=new Map;for(let I of g){a.font=`${l} ${u} ${s} "${I}", monospace`;let S=a.measureText(o).width;if(y.set(I,S),S!==d){a.font=`${l} ${u} ${s} "${I}"`;let x=a.measureText(o).width;a.font=`${l} ${u} ${s} ${r.fontFamily}`;let M=a.measureText(o).width;if(Math.abs(x-M)<.1){f=I;break}}}return w.debug("[computedStyles] Font detection:",{declared:r.fontFamily,detected:f,declaredFonts:c,fontWidths:Array.from(y.entries()),isIframe:t!==document}),f}var Zs=$(()=>{"use strict";He()});function Pa(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 nh(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e);return w.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:er(n.color),backgroundColor:er(n.backgroundColor),borderColor:er(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:PS(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 rh(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 a=i.cssRules||i.rules;if(!a)continue;for(let s of Array.from(a))if(s.type===1){let u=s;try{if(e.matches(u.selectorText)){let l=u.style;l.width&&(n.width=l.width),l.height&&(n.height=l.height),l.minWidth&&(n.minWidth=l.minWidth),l.minHeight&&(n.minHeight=l.minHeight),l.maxWidth&&(n.maxWidth=l.maxWidth),l.maxHeight&&(n.maxHeight=l.maxHeight),l.display&&(n.display=l.display),l.flexGrow&&(n.flexGrow=l.flexGrow),l.flexShrink&&(n.flexShrink=l.flexShrink),l.flexBasis&&(n.flexBasis=l.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){w.error("Error extracting declared styles:",r)}return n}var gu=$(()=>{"use strict";He();Zs()});function Yz(e){let t=[],n=new Set,r=MS.join(", "),o=e.querySelectorAll(r);for(let i of Array.from(o)){let a=`${i.tagName.toLowerCase()}.${i.className}`;n.has(a)||(n.add(a),t.push(i))}if(MS.includes(e.tagName.toLowerCase())){let i=`${e.tagName.toLowerCase()}.${e.className}`;n.has(i)||t.unshift(e)}return t}function Kz(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:Pa(r,i),tagName:r,className:i,styles:{fontSize:n.fontSize,fontFamily:Qs(n.fontFamily),fontWeight:n.fontWeight,lineHeight:n.lineHeight,letterSpacing:n.letterSpacing,color:er(n.color),textAlign:n.textAlign,textTransform:n.textTransform}}}function Xz(e,t=2){let n=[e],r=new Set,o=a=>{let s=a.className;return typeof s=="string"?s:s?.baseVal||""};r.add(`${e.tagName}.${o(e)}`);function i(a,s){if(s>=t)return;let u=Array.from(a.children);for(let l of u){let c=l.tagName.toLowerCase();if(["script","style","link","meta","br","hr"].includes(c))continue;let p=`${l.tagName}.${o(l)}`;r.has(p)||(r.add(p),n.push(l),i(l,s+1))}}return i(e,0),n}function Jz(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e),r=e.tagName.toLowerCase(),o=e.className,i=typeof o=="string"?o:o?.baseVal||"",a=n.borderWidth!=="0px",s=n.backgroundColor!=="transparent"&&n.backgroundColor!=="rgba(0, 0, 0, 0)",u=n.borderRadius!=="0px",l=n.gap!=="normal"&&n.gap!=="0px";if(!a&&!s&&!u&&!l)return null;let c=n.borderWidth,p=n.borderStyle,g=er(n.borderColor),d=a?`${c} ${p} ${g}`:"none";return{selector:Pa(r,i),className:i,border:d,borderRadius:n.borderRadius,backgroundColor:er(n.backgroundColor),gap:n.gap}}function el(){w.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=Xz(r,2),i=o.map(Jz).filter(s=>s!==null);w.debug("[computedStyles] Extracted visual styles from nested elements:",{total:o.length,withVisuals:i.length,elements:i.map(s=>({selector:s.selector,border:s.border,background:s.backgroundColor,borderRadius:s.borderRadius}))});let a=[];try{let s=Yz(r);a=s.map(Kz),w.debug("[computedStyles] Text elements found:",{count:s.length,elements:a.map(u=>({selector:u.selector,fontSize:u.styles.fontSize,fontWeight:u.styles.fontWeight}))})}catch(s){w.error("[computedStyles] Error extracting text elements:",s)}return{computed:nh(r),declared:rh(r,t),markup:r.outerHTML,textElementStyles:a,nestedElementStyles:i}}catch(e){return w.error("Error extracting computed styles:",e),null}}var MS,LS=$(()=>{"use strict";He();Zs();gu();MS=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});function oh(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 Zz(e,t,n){if(!(e==="0px"||t==="none"))return`${e} ${t} ${n}`}function eD(e){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e),r={},o=er(n.backgroundColor);dr("backgroundColor",o)||(r.backgroundColor=o);let i=Zz(n.borderWidth,n.borderStyle,er(n.borderColor));i&&(r.border=i),dr("borderRadius",n.borderRadius)||(r.borderRadius=n.borderRadius),dr("boxShadow",n.boxShadow)||(r.boxShadow=n.boxShadow),dr("opacity",n.opacity)||(r.opacity=n.opacity);let a=e.tagName.toLowerCase(),s=["svg","circle","rect","ellipse","line","polyline","polygon","path","text","tspan","g","use","defs","clipPath","mask"];if(e instanceof SVGElement||s.includes(a)){for(let I=0;I<e.attributes.length;I++){let S=e.attributes[I];if(["class","style","id","xmlns","xmlns:xlink"].includes(S.name))continue;let x=S.name.replace(/-([a-z])/g,(z,O)=>O.toUpperCase()),M=S.value.startsWith("rgb")?er(S.value):S.value;x==="d"&&M.length>100?r[x]=M.substring(0,100)+"...":r[x]=M}let d=n.getPropertyValue("fill"),f=n.getPropertyValue("stroke");if(d&&d!=="none"&&(r.fill=d.startsWith("rgb")?er(d):d),f&&f!=="none"&&(r.stroke=f.startsWith("rgb")?er(f):f),["circle","ellipse","rect","path","line","polyline","polygon"].includes(a)){let I=e.getBoundingClientRect();I.width>0&&(r.width=`${Math.round(I.width*100)/100}px`),I.height>0&&(r.height=`${Math.round(I.height*100)/100}px`)}}let l=e.textContent&&e.textContent.trim().length>0,c=Qz.includes(e.tagName.toLowerCase());(l||c)&&(r.fontSize=n.fontSize,r.fontFamily=Qs(n.fontFamily),r.fontWeight=n.fontWeight,r.lineHeight=n.lineHeight,r.color=er(n.color),dr("letterSpacing",n.letterSpacing)||(r.letterSpacing=n.letterSpacing),dr("textAlign",n.textAlign)||(r.textAlign=n.textAlign)),r.display=n.display;let p=oh(n.paddingTop,n.paddingRight,n.paddingBottom,n.paddingLeft);dr("padding",p)||(r.padding=p);let g=oh(n.marginTop,n.marginRight,n.marginBottom,n.marginLeft);return dr("margin",g)||(r.margin=g),dr("gap",n.gap)||(r.gap=n.gap),(n.display==="flex"||n.display==="inline-flex")&&(dr("flexDirection",n.flexDirection)||(r.flexDirection=n.flexDirection),dr("justifyContent",n.justifyContent)||(r.justifyContent=n.justifyContent),dr("alignItems",n.alignItems)||(r.alignItems=n.alignItems)),r.width||(r.width=n.width),r.height||(r.height=n.height),r}function BS(e){let t=1;for(let n of e.children)t+=BS(n);return t}function zS(e,t=4){function n(o,i){let a=o.tagName.toLowerCase(),s=o.className,u=typeof s=="string"?s:s?.baseVal||"",l=o.id||void 0,c=o.getAttribute("role")||void 0,p;for(let y of Array.from(o.childNodes))if(y.nodeType===Node.TEXT_NODE){let I=y.textContent?.trim();if(I){p=I.length>50?I.substring(0,50)+"...":I;break}}let g=a;l?g=`${a}#${l}`:u&&(g=Pa(a,u));let d=eD(o),f=[];if(i<t){let y=Array.from(o.children);for(let I of y){let S=I.tagName.toLowerCase();if(["script","style","link","meta","br","hr","noscript"].includes(S))continue;let M=(I.ownerDocument.defaultView||window).getComputedStyle(I);M.display==="none"||M.visibility==="hidden"||f.push(n(I,i+1))}}return{selector:g,tagName:a,className:u,id:l,role:c,textContent:p,styles:d,children:f}}w.debug("[computedStyles] Extracting DOM tree with maxDepth:",t);let r=n(e,0);return w.debug("[computedStyles] DOM tree extracted:",{rootSelector:r.selector,childrenCount:r.children.length,totalNodes:BS(r)}),r}function tl(e=4){w.debug("[extractStoryDOMTree] Starting DOM tree extraction...");try{let t=document.getElementById("storybook-preview-iframe");if(w.debug("[extractStoryDOMTree] iframe found:",!!t),!t)throw new Error("Storybook preview iframe not found");if(w.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(w.debug("[extractStoryDOMTree] storyRoot found:",!!n),!n)throw new Error("Story root element not found");let r=pu(n);if(w.debug("[extractStoryDOMTree] componentElement found:",!!r,r?.tagName),!r)throw new Error("Component element not found in story root");let o=zS(r,e);return w.debug("[extractStoryDOMTree] DOM tree extracted successfully:",{selector:o.selector,childrenCount:o.children.length}),o}catch(t){return w.error("[extractStoryDOMTree] Error extracting DOM tree:",t),null}}var Qz,DS=$(()=>{"use strict";He();Zs();gu();eh();Qz=["input","textarea","button","select","label","span","a","p","h1","h2","h3","h4","h5","h6"]});var fu=$(()=>{"use strict";Zs();gu();LS();DS()});var l4=Fr((cle,s4)=>{"use strict";s4.exports={compareTwoStrings:a4,findBestMatch:ID};function a4(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),a=n.has(i)?n.get(i)+1:1;n.set(i,a)}let r=0;for(let o=0;o<t.length-1;o++){let i=t.substring(o,o+2),a=n.has(i)?n.get(i):0;a>0&&(n.set(i,a-1),r++)}return 2*r/(e.length+t.length-2)}function ID(e,t){if(!TD(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 a=t[i],s=a4(e,a);n.push({target:a,rating:s}),s>n[r].rating&&(r=i)}let o=n[r];return{ratings:n,bestMatch:o,bestMatchIndex:r}}function TD(e,t){return!(typeof e!="string"||!Array.isArray(t)||!t.length||t.find(function(n){return typeof n!="string"}))}});var N7=Fr((jxe,_7)=>{"use strict";var L7=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,_V=/\n/g,NV=/^\s*/,OV=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,$V=/^:\s*/,HV=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,UV=/^[;\s]*/,jV=/^\s+|\s+$/g,VV=`
|
|
14
|
-
`,B7="/",z7="*",Zi="",WV="comment",GV="declaration";function qV(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function o(f){var y=f.match(_V);y&&(n+=y.length);var I=f.lastIndexOf(VV);r=~I?f.length-I:r+f.length}function i(){var f={line:n,column:r};return function(y){return y.position=new a(f),l(),y}}function a(f){this.start=f,this.end={line:n,column:r},this.source=t.source}a.prototype.content=e;function s(f){var y=new Error(t.source+":"+n+":"+r+": "+f);if(y.reason=f,y.filename=t.source,y.line=n,y.column=r,y.source=e,!t.silent)throw y}function u(f){var y=f.exec(e);if(y){var I=y[0];return o(I),e=e.slice(I.length),y}}function l(){u(NV)}function c(f){var y;for(f=f||[];y=p();)y!==!1&&f.push(y);return f}function p(){var f=i();if(!(B7!=e.charAt(0)||z7!=e.charAt(1))){for(var y=2;Zi!=e.charAt(y)&&(z7!=e.charAt(y)||B7!=e.charAt(y+1));)++y;if(y+=2,Zi===e.charAt(y-1))return s("End of comment missing");var I=e.slice(2,y-2);return r+=2,o(I),e=e.slice(y),r+=2,f({type:WV,comment:I})}}function g(){var f=i(),y=u(OV);if(y){if(p(),!u($V))return s("property missing ':'");var I=u(HV),S=f({type:GV,property:D7(y[0].replace(L7,Zi)),value:I?D7(I[0].replace(L7,Zi)):Zi});return u(UV),S}}function d(){var f=[];c(f);for(var y;y=g();)y!==!1&&(f.push(y),c(f));return f}return l(),d()}function D7(e){return e?e.replace(jV,Zi):Zi}_7.exports=qV});var O7=Fr(Rl=>{"use strict";var YV=Rl&&Rl.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Rl,"__esModule",{value:!0});Rl.default=XV;var KV=YV(N7());function XV(e,t){let n=null;if(!e||typeof e!="string")return n;let r=(0,KV.default)(e),o=typeof t=="function";return r.forEach(i=>{if(i.type!=="declaration")return;let{property:a,value:s}=i;o?t(a,s,i):s&&(n=n||{},n[a]=s)}),n}});var H7=Fr(vd=>{"use strict";Object.defineProperty(vd,"__esModule",{value:!0});vd.camelCase=void 0;var JV=/^--[a-zA-Z0-9_-]+$/,QV=/-([a-z])/g,ZV=/^[^-]+$/,eW=/^-(webkit|moz|ms|o|khtml)-/,tW=/^-(ms)-/,nW=function(e){return!e||ZV.test(e)||JV.test(e)},rW=function(e,t){return t.toUpperCase()},$7=function(e,t){return"".concat(t,"-")},oW=function(e,t){return t===void 0&&(t={}),nW(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(tW,$7):e=e.replace(eW,$7),e.replace(QV,rW))};vd.camelCase=oW});var j7=Fr((C5,U7)=>{"use strict";var iW=C5&&C5.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},aW=iW(O7()),sW=H7();function k5(e,t){var n={};return!e||typeof e!="string"||(0,aW.default)(e,function(r,o){r&&o&&(n[(0,sW.camelCase)(r,t)]=o)}),n}k5.default=k5;U7.exports=k5});var h8=Fr((ySe,m8)=>{"use strict";var Vd=Object.prototype.hasOwnProperty,f8=Object.prototype.toString,l8=Object.defineProperty,c8=Object.getOwnPropertyDescriptor,u8=function(t){return typeof Array.isArray=="function"?Array.isArray(t):f8.call(t)==="[object Array]"},d8=function(t){if(!t||f8.call(t)!=="[object Object]")return!1;var n=Vd.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&Vd.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var o;for(o in t);return typeof o>"u"||Vd.call(t,o)},p8=function(t,n){l8&&n.name==="__proto__"?l8(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},g8=function(t,n){if(n==="__proto__")if(Vd.call(t,n)){if(c8)return c8(t,n).value}else return;return t[n]};m8.exports=function e(){var t,n,r,o,i,a,s=arguments[0],u=1,l=arguments.length,c=!1;for(typeof s=="boolean"&&(c=s,s=arguments[1]||{},u=2),(s==null||typeof s!="object"&&typeof s!="function")&&(s={});u<l;++u)if(t=arguments[u],t!=null)for(n in t)r=g8(s,n),o=g8(t,n),s!==o&&(c&&o&&(d8(o)||(i=u8(o)))?(i?(i=!1,a=r&&u8(r)?r:[]):a=r&&d8(r)?r:{},p8(s,{name:n,newValue:e(c,a,o)})):typeof o<"u"&&p8(s,{name:n,newValue:o}));return s}});import Fi from"react";import{addons as ap,types as Yx,experimental_getStatusStore as Kx}from"storybook/manager-api";import{AddonPanel as hZ}from"storybook/internal/components";import{styled as xZ}from"storybook/theming";import{styled as tn}from"storybook/theming";var W="#ea580c",ei="#c2410c",lp="#ff6b35",Xx="#A259FF",Jx="#8a3de8",Qx=W,Zx="#d1d5db",nc="#7c3aed",Ye={red:"#ef4444",amber:"#f59e0b",green:"#16a34a",redText:"#b91c1c",amberText:"#b45309",greenText:"#16a34a",criticalRail:"#dc2626",criticalLabel:"#dc2626",majorLabel:"#f59e0b",minorLabel:"#f59e0b",minorRail:"#fbbf24"},ey={color:{text:"#1d4ed8",bg:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.25)"},spacing:{text:"#c2410c",bg:"rgba(249, 115, 22, 0.1)",border:"rgba(249, 115, 22, 0.25)"},typography:{text:"#be185d",bg:"rgba(236, 72, 153, 0.1)",border:"rgba(236, 72, 153, 0.25)"},border:{text:"#047857",bg:"rgba(16, 185, 129, 0.1)",border:"rgba(16, 185, 129, 0.25)"},layout:{text:"#0f766e",bg:"rgba(20, 184, 166, 0.1)",border:"rgba(20, 184, 166, 0.25)"},sizing:{text:"#6d28d9",bg:"rgba(139, 92, 246, 0.1)",border:"rgba(139, 92, 246, 0.25)"}},cp={spec:"#c2410c",ai:"#6d28d9"},te={card:"#ffffff",green:"#10b981",border:"#e5e7eb",track:"#f1f5f9",muted:"#6b7280",locked:"#9ca3af",text:"#111827",subText:"#374151",formBg:"#fafafa",lockedBtnBg:"#f3f4f6",calloutBg:"#fffbeb",calloutText:"#b45309",accentTint:"#fff7ed"},Mi={pillBg:"#fff7ed",pillBorder:"#f5d0b5",iconFrom:"#d97706",iconTo:ei,badgeBg:"#fef3c7",badgeText:"#92400e"};var ty=tn.div(({theme:e})=>({fontFamily:e.typography.fonts.base,height:"100%",display:"flex",flexDirection:"column",backgroundColor:e.background.content,color:e.color.defaultText})),ny=tn.div(({theme:e})=>({flex:1,overflow:"auto",padding:"6px 12px 12px",backgroundColor:e.background.app})),rc=tn.div({marginBottom:"20px"}),oc=tn.label(({theme:e})=>({display:"block",marginBottom:`${e.layoutMargin*.6}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),ps=tn.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*2,backgroundColor:e.input.background,color:e.color.defaultText,"&:focus":{outline:"none",borderColor:e.color.secondary,boxShadow:`0 0 0 2px ${e.color.secondary}20`}})),ir=tn.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*2,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"}})),ry=tn(ir)(({theme:e})=>({width:"auto",padding:`${e.layoutMargin*.6}px 28px ${e.layoutMargin*.6}px ${e.layoutMargin}px`,fontSize:e.typography.size.s1})),ic=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*2,cursor:"pointer",transition:"all 0.15s","&:disabled":{opacity:.5,cursor:"not-allowed"}}),Po=tn.button(({theme:e})=>({...ic(e),backgroundColor:e.color.secondary,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),Qt=tn.button(({theme:e})=>({...ic(e),backgroundColor:W,color:e.color.inverseText,boxShadow:`0 2px 4px ${W}4d`,"&:hover:not(:disabled)":{backgroundColor:ei,transform:"translateY(-1px)",boxShadow:`0 4px 8px ${W}66`}})),mo=tn.button(({theme:e})=>({...ic(e),backgroundColor:"transparent",border:`1px solid ${e.appBorderColor}`,color:e.color.defaultText,"&:hover:not(:disabled)":{backgroundColor:e.background.hoverable}})),oy=tn.button(({theme:e})=>({...ic(e),backgroundColor:e.color.negative,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),br=tn.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"}})),up=tn.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"}})),ti=tn.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}})),ni=tn(ps)(({theme:e})=>({paddingLeft:`${e.layoutMargin*3}px`,backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:`${e.layoutMargin}px center`,backgroundSize:"14px"})),TZ=tn.div(({theme:e})=>({padding:`${e.layoutMargin*1.6}px`,borderRadius:e.appBorderRadius*2.5,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content})),iy=tn.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})),EZ=tn.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})),dp=tn.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})),RZ=tn.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%)"}}})),ay=tn.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}}),AZ=tn.div(({theme:e})=>({padding:"40px 20px",textAlign:"center",color:e.color.mediumdark})),FZ=tn.div(({theme:e})=>({fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,marginBottom:`${e.layoutMargin*.8}px`,color:e.color.defaultText})),PZ=tn.div(({theme:e})=>({fontSize:e.typography.size.s2,color:e.color.mediumdark}));import st,{useState as NQ,useEffect as JT}from"react";import{styled as nr}from"storybook/theming";import sy from"react";var pp=({header:e,children:t,footer:n})=>sy.createElement(ty,null,e,sy.createElement(ny,null,t),n);import RE from"react";import{styled as AE}from"storybook/theming";var FE=AE.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})),gp=({toolbar:e})=>RE.createElement(FE,null,e);import HZ from"react";import{styled as ac}from"storybook/theming";var VZ=ac.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})),WZ=ac.div({display:"flex",flex:1}),GZ=ac(ti)(({theme:e,disabled:t})=>({padding:"6px 12px",...t?{color:e.color.mediumlight,cursor:"not-allowed",opacity:.5,"&:hover":{}}:{}})),qZ=ac.div({display:"flex",gap:"8px",alignItems:"center"});import xt,{useState as iu,useCallback as Vm,useEffect as Wm,useRef as fz}from"react";import{styled as Sn}from"storybook/theming";import Ce from"react";var ly=()=>Ce.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"},Ce.createElement("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),Ce.createElement("circle",{cx:"12",cy:"12",r:"3"})),gs=()=>Ce.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"},Ce.createElement("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),Ce.createElement("circle",{cx:"12",cy:"7",r:"4"})),Mr={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"},fs=()=>Ce.createElement("svg",{...Mr},Ce.createElement("circle",{cx:"11",cy:"11",r:"8"}),Ce.createElement("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})),cy=()=>Ce.createElement("svg",{...Mr},Ce.createElement("path",{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07l-1.71 1.71"}),Ce.createElement("path",{d:"M5.17 11.75l-1.71 1.71a5 5 0 0 0 7.07 7.07l1.71-1.71"}),Ce.createElement("line",{x1:"8",y1:"2",x2:"8",y2:"5"}),Ce.createElement("line",{x1:"2",y1:"8",x2:"5",y2:"8"}),Ce.createElement("line",{x1:"16",y1:"22",x2:"16",y2:"19"}),Ce.createElement("line",{x1:"22",y1:"16",x2:"19",y2:"16"})),uy=()=>Ce.createElement("svg",{...Mr},Ce.createElement("polyline",{points:"23 4 23 10 17 10"}),Ce.createElement("polyline",{points:"1 20 1 14 7 14"}),Ce.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 fp=()=>Ce.createElement("svg",{...Mr},Ce.createElement("circle",{cx:"12",cy:"12",r:"3"}),Ce.createElement("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})),sc=()=>Ce.createElement("svg",{...Mr},Ce.createElement("path",{d:"M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3z"}),Ce.createElement("path",{d:"M19 14l.7 1.9L21.6 17l-1.9.7L19 19.6l-.7-1.9L16.4 17l1.9-.7L19 14z"})),dy=()=>Ce.createElement("svg",{...Mr},Ce.createElement("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),Ce.createElement("polyline",{points:"12 5 19 12 12 19"})),py=()=>Ce.createElement("svg",{...Mr},Ce.createElement("path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72Z"}),Ce.createElement("path",{d:"m14 7 3 3"}),Ce.createElement("path",{d:"M5 6v4"}),Ce.createElement("path",{d:"M19 14v4"}),Ce.createElement("path",{d:"M10 2v2"}),Ce.createElement("path",{d:"M7 8H3"}),Ce.createElement("path",{d:"M21 16h-4"}),Ce.createElement("path",{d:"M11 3H9"})),gy=()=>Ce.createElement("svg",{...Mr},Ce.createElement("polyline",{points:"6 9 12 15 18 9"})),fy=()=>Ce.createElement("svg",{...Mr},Ce.createElement("polyline",{points:"20 6 9 17 4 12"})),my=()=>Ce.createElement("svg",{...Mr},Ce.createElement("path",{d:"M7 10v12"}),Ce.createElement("path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z"})),hy=()=>Ce.createElement("svg",{...Mr},Ce.createElement("path",{d:"M3 3v5h5"}),Ce.createElement("path",{d:"M3.05 13A9 9 0 1 0 6 5.3L3 8"}),Ce.createElement("path",{d:"M12 7v5l4 2"})),mp=()=>Ce.createElement("svg",{...Mr},Ce.createElement("path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5a2 2 0 0 0 2 2h1"}),Ce.createElement("path",{d:"M16 3h1a2 2 0 0 1 2 2v5a2 2 0 0 0 2 2 2 2 0 0 0-2 2v5a2 2 0 0 1-2 2h-1"})),Mo=()=>Ce.createElement("svg",{width:"10",height:"15",viewBox:"0 0 38 57","aria-label":"Figma",role:"img"},Ce.createElement("path",{fill:"#1abcfe",d:"M19 28.5a9.5 9.5 0 1 1 19 0 9.5 9.5 0 0 1-19 0z"}),Ce.createElement("path",{fill:"#0acf83",d:"M0 47.5A9.5 9.5 0 0 1 9.5 38H19v9.5a9.5 9.5 0 1 1-19 0z"}),Ce.createElement("path",{fill:"#ff7262",d:"M19 0v19h9.5a9.5 9.5 0 1 0 0-19H19z"}),Ce.createElement("path",{fill:"#f24e1e",d:"M0 9.5A9.5 9.5 0 0 0 9.5 19H19V0H9.5A9.5 9.5 0 0 0 0 9.5z"}),Ce.createElement("path",{fill:"#a259ff",d:"M0 28.5A9.5 9.5 0 0 0 9.5 38H19V19H9.5A9.5 9.5 0 0 0 0 28.5z"})),hp=()=>Ce.createElement("svg",{width:"13",height:"13",viewBox:"0 0 64 64","aria-label":"Storybook",role:"img"},Ce.createElement("path",{fill:"#ff4785",d:"M8 4l1.5 56L56 62l2-58z"}),Ce.createElement("path",{fill:"#fff",d:"M40.5 18.2c-.2 1.5-3.6 2.4-7.6 2.1-4-.3-7-1.6-6.9-3.1.1-1.4 2.4-2 5.3-2 .8 0 1.2-.4 1.2-1.1 0-1.6-3.6-2.6-7-2.6-7 0-10.6 3.8-10.6 7.6 0 6.6 8.9 7 11.4 7.2 5.5.4 6.9 1.5 6.9 3 0 1.6-2.1 2.6-5 2.6-3.8 0-5.6-1.4-5.7-3.1 0-.6-.4-1-1-1l-3.5.1c-.6 0-1 .4-1 1 .2 4.7 4.3 7.6 11.3 7.6 6.7 0 11.2-3.1 11.2-7.6 0-5.7-5-7-11.1-7.5-4.2-.3-6.5-.6-6.5-2 0-1 1.8-1.8 4.4-1.8 2.5 0 4.2.6 4.4 1.7.1.6.5 1 1.1 1l3.5-.1c.6-.1 1-.5 1-1.1z"}));import Le,{useEffect as oS}from"react";import{styled as kt}from"storybook/theming";ke();De();He();ct();var iS=kt.div({position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:1e4}),aS=kt.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})),CB=kt.div({display:"flex",alignItems:"center",gap:"12px",padding:"16px 16px 12px"}),IB=kt.div({width:"36px",height:"36px",borderRadius:"50%",backgroundColor:W,display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:"14px",fontWeight:700,flexShrink:0}),TB=kt.div({display:"flex",flexDirection:"column",gap:"4px"}),EB=kt.div(({theme:e})=>({fontSize:"15px",fontWeight:600,color:e.color.defaultText,lineHeight:1.2})),RB=kt.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"}),AB=kt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px 8px",fontSize:"14px",color:e.color.defaultText})),FB=kt.span(({theme:e})=>({color:e.textMutedColor,fontSize:"13px"})),PB=kt.span(({theme:e})=>({color:e.color.defaultText,fontSize:"15px",fontWeight:600})),MB=kt.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"})),LB=kt.div(({percent:e})=>({height:"100%",width:`${Math.min(100,Math.max(0,e))}%`,background:`linear-gradient(90deg, #f59e0b 0%, ${W} 100%)`,transition:"width 0.3s ease"})),BB=kt.div(({theme:e})=>({padding:"0 16px 14px",fontSize:"12px",color:e.textMutedColor})),zB=kt.div(({theme:e})=>({height:"1px",backgroundColor:e.appBorderColor})),DB=kt.button({width:"100%",padding:"14px 16px",background:"transparent",border:"none",color:W,fontSize:"14px",fontWeight:500,textAlign:"left",cursor:"pointer",display:"flex",alignItems:"center",gap:"6px","&:hover":{backgroundColor:"rgba(0, 0, 0, 0.03)"}}),sS=kt.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}})),_B=kt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px",borderBottom:`1px solid ${e.appBorderColor}`})),NB=kt.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"10px",color:e.color.defaultText,fontSize:"14px",fontWeight:500})),OB=kt.div(({theme:e})=>({width:"32px",height:"32px",borderRadius:"50%",backgroundColor:W,display:"flex",alignItems:"center",justifyContent:"center",color:e.color.inverseText,fontSize:"14px",fontWeight:600})),$B=kt.div({display:"flex",gap:"8px"}),lS=kt(br)({fontSize:"18px"}),HB=kt.div({padding:"20px 16px"}),UB=kt.div(({theme:e})=>({padding:"16px",borderRadius:"8px",background:"linear-gradient(135deg, #10B981 0%, #3B82F6 100%)",marginBottom:"16px",color:"#fff"})),jB=kt.div({fontSize:"12px",fontWeight:500,opacity:.9,marginBottom:"4px"}),VB=kt.div({fontSize:"28px",fontWeight:700}),WB=kt.div({fontSize:"11px",opacity:.8,marginTop:"4px"}),GB=kt.div(({theme:e})=>({padding:"16px",borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),qB=kt.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),YB=kt.div({display:"flex",alignItems:"center",gap:"8px"}),KB=kt.span(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),XB=kt.span(({theme:e})=>({fontSize:"10px",fontWeight:600,padding:"2px 6px",borderRadius:"4px",backgroundColor:W,color:e.color.inverseText})),JB=kt.button(({theme:e})=>({background:"none",border:"none",color:W,fontSize:"12px",cursor:"pointer","&:hover":{textDecoration:"underline"}})),QB=kt.div(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),ZB=kt.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"?W:e.background.hoverable,color:t==="primary"?e.color.inverseText:e.color.defaultText,"&:hover":{opacity:.9}})),ez=30*1e3,cS=({onClose:e})=>{let{sessionToken:t,resetAuth:n,usageData:r,usageLastFetched:o,setUsageData:i}=ye(),{featureFlags:a}=ge(),s=a.showCosts,u=r,l=!r&&t,c=async(f=!1)=>{if(!t)return;let y=o&&Date.now()-o<ez;if(!(!f&&y&&r))try{let I=K(),S=await Z(`${I}/api/addon/account`,{headers:{Authorization:`Bearer ${t}`}});if(S.ok){let x=await S.json();i(x)}}catch(I){w.error("Failed to fetch usage:",I)}};oS(()=>{c()},[t]),oS(()=>{let f=()=>{document.visibilityState==="visible"&&(w.debug("[TokenUsageModal] Tab visible, refreshing balance..."),c(!0))};return document.addEventListener("visibilitychange",f),()=>document.removeEventListener("visibilitychange",f)},[t]);let p=async()=>{if(t){let f=K();try{await fetch(`${f}/api/addon/auth/sign-out`,{method:"POST",headers:{Authorization:`Bearer ${t}`}})}catch{}}n(),e()},g=()=>{let f=K();window.open(`${f}/pricing`,"_blank")},d=()=>{let f=K();window.open(`${f}/pricing#add-credits`,"_blank")};if(t&&!s&&!l){let f=Math.floor(u?.creditBalance??0),I=Math.max(f,10),S=Math.max(0,I-f),x=I>0?f/I*100:0;return Le.createElement(Le.Fragment,null,Le.createElement(iS,{onClick:e}),Le.createElement(aS,{onClick:M=>M.stopPropagation(),style:{width:"320px"}},Le.createElement(CB,null,Le.createElement(IB,null,(u?.name||u?.email||"U")[0].toUpperCase()),Le.createElement(TB,null,Le.createElement(EB,null,u?.name||u?.email||"Your account"),Le.createElement(RB,null,(u?.plan||"FREE").toUpperCase())),Le.createElement("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"2px"}},Le.createElement(sS,{onClick:p,title:"Sign out",style:{position:"static"}},Le.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},Le.createElement("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),Le.createElement("polyline",{points:"16 17 21 12 16 7"}),Le.createElement("line",{x1:"21",y1:"12",x2:"9",y2:"12"}))),Le.createElement(sS,{onClick:e,title:"Close",style:{position:"static"}},"\xD7"))),Le.createElement(AB,null,Le.createElement(FB,null,"Credits"),Le.createElement(PB,null,f," left")),Le.createElement(MB,null,Le.createElement(LB,{percent:x})),Le.createElement(BB,null,S," used \xB7 ",f," remaining"),Le.createElement(zB,null),Le.createElement(DB,{onClick:()=>window.open("mailto:hello@uiparity.com?subject=Credits request","_blank")},"Contact us for credits \u2192")))}return Le.createElement(Le.Fragment,null,Le.createElement(iS,{onClick:e}),Le.createElement(aS,{onClick:f=>f.stopPropagation()},Le.createElement(_B,null,Le.createElement(NB,null,Le.createElement(OB,null,u?.email?u.email[0].toUpperCase():"U"),Le.createElement("span",null,u?.email||"Loading...")),Le.createElement($B,null,Le.createElement(lS,{onClick:p,title:"Sign out"},Le.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},Le.createElement("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),Le.createElement("polyline",{points:"16 17 21 12 16 7"}),Le.createElement("line",{x1:"21",y1:"12",x2:"9",y2:"12"}))),Le.createElement(lS,{onClick:e,title:"Close"},"\xD7"))),Le.createElement(HB,null,l?Le.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Loading..."):t?Le.createElement(Le.Fragment,null,Le.createElement(UB,null,Le.createElement(jB,null,"Credit Balance"),Le.createElement(VB,null,"$",(u?.creditBalance??0).toFixed(2)),Le.createElement(WB,null,(u?.creditBalance??0)<2?"Low balance - consider topping up":"Pay only for what you use")),Le.createElement(GB,null,Le.createElement(qB,null,Le.createElement(YB,null,Le.createElement(KB,null,"Current Plan"),Le.createElement(XB,null,u?.plan||"Free")),Le.createElement(JB,{onClick:g},"View detail >")),Le.createElement(QB,null,"~$0.02-0.05 per review depending on complexity"),Le.createElement(ZB,{onClick:d,style:{marginTop:"16px"}},"Add Credits"))):Le.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Please sign in to view usage"))))};on();ke();import Ea from"react";import{styled as uS}from"storybook/theming";De();ke();ct();He();var tz=uS.div({display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"}),nz=uS.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark})),dS=()=>{let{userRole:e,roleOverride:t,setRoleOverride:n,setFeatureFlags:r}=ge(),{sessionToken:o}=ye();return e!=="admin"?null:Ea.createElement(tz,null,Ea.createElement(nz,null,"View as:"),Ea.createElement(ry,{value:t??e,onChange:s=>{let u=s.target.value;if(u===e)n(null),o&&Z(`${K()}/api/addon/flags`,{headers:{Authorization:`Bearer ${o}`}}).then(l=>l.json()).then(l=>{let c={enableFixGeneration:!!l.enableFixGeneration,enableFixApply:!!l.enableFixApply,enableAutoMap:!!l.enableAutoMap,enableAutoFigmaLinking:!!l.enableAutoFigmaLinking,enableReviewBadges:!!l.enableReviewBadges,showCosts:!!l.showCosts,enableParallelReview:!!l.enableParallelReview,enableModelSelection:!!l.enableModelSelection};r(c);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(c))}catch{}}).catch(l=>w.warn("[RoleSwitcher] Failed to re-fetch flags:",l.message));else{n(u);let l=Ws[u];r(l);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(l))}catch{}}},style:{width:"auto",minWidth:"100px"}},Ea.createElement("option",{value:"admin"},"Admin"),Ea.createElement("option",{value:"beta"},"Regular user")),t&&Ea.createElement(ay,{variant:"warning"},"Previewing as"," ",t==="beta"?"regular user":t))};De();ke();ct();import Bt,{useState as qs,useCallback as jm}from"react";import{styled as eo}from"storybook/theming";var rz="0.5.7",oz=[{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"}],iz=eo.div({position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center"}),az=eo.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)"})),sz=eo.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px 12px",borderBottom:`1px solid ${e.appBorderColor}`})),lz=eo.h3(({theme:e})=>({margin:0,fontSize:"15px",fontWeight:600,color:e.color.defaultText,display:"flex",alignItems:"center",gap:"8px"})),cz=eo.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}})),uz=eo.div({padding:"16px 20px",display:"flex",flexDirection:"column",gap:"14px"}),dz=eo.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:W}})),pS=eo.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 20px 16px",borderTop:`1px solid ${e.appBorderColor}`,gap:"8px"})),gS=eo.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s1,color:e.color.mediumdark,lineHeight:1.4})),pz=eo.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s1,color:e.color.negative})),gz=eo.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 fS({isOpen:e,onClose:t}){let{sessionToken:n,isConnected:r}=ye(),{selectedProjectId:o}=Ke(),{currentStoryId:i}=pt(),[a,s]=qs("other"),[u,l]=qs(""),[c,p]=qs(!1),[g,d]=qs(!1),[f,y]=qs(null),I=jm(()=>{l(""),s("other"),d(!1),y(null),p(!1)},[]),S=jm(()=>{I(),t()},[I,t]),x=jm(async M=>{if(M.preventDefault(),!u.trim()){y("Please write a message.");return}if(!r||!n){y("Sign in to send feedback.");return}p(!0),y(null);try{let z=await Z(`${K()}/api/feedback`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({message:u.trim(),severity:a,projectId:o||void 0,storyId:i||void 0,addonVersion:rz})});if(!z.ok){let O=await z.json().catch(()=>({}));throw new Error(O.error||`Request failed (${z.status})`)}d(!0)}catch(z){y(z instanceof Error?z.message:"Something went wrong")}finally{p(!1)}},[u,a,n,r,o,i]);return e?Bt.createElement(iz,{onClick:S},Bt.createElement(az,{onClick:M=>M.stopPropagation()},Bt.createElement(sz,null,Bt.createElement(lz,null,Bt.createElement("span",null,"\u{1F4AC}"),"Send feedback"),Bt.createElement(cz,{onClick:S,"aria-label":"Close"},"\xD7")),g?Bt.createElement(Bt.Fragment,null,Bt.createElement(gz,null,Bt.createElement("h4",null,"Thanks \u2014 got it."),Bt.createElement("p",null,"We read every message. If it's a bug, we'll likely follow up by email.")),Bt.createElement(pS,null,Bt.createElement("span",null),Bt.createElement(Po,{onClick:S},"Close"))):Bt.createElement("form",{onSubmit:x},Bt.createElement(uz,null,Bt.createElement(rc,null,Bt.createElement(oc,{htmlFor:"feedback-severity"},"Type"),Bt.createElement(ir,{id:"feedback-severity",value:a,onChange:M=>s(M.target.value),disabled:c},oz.map(M=>Bt.createElement("option",{key:M.value,value:M.value},M.label)))),Bt.createElement(rc,null,Bt.createElement(oc,{htmlFor:"feedback-message"},"What happened?"),Bt.createElement(dz,{id:"feedback-message",value:u,onChange:M=>l(M.target.value),placeholder:"Tell us what you were doing, what you expected, and what happened.",disabled:c,autoFocus:!0,maxLength:5e3})),Bt.createElement(gS,null,"We auto-attach your current story and project so we can reproduce it. No screenshots sent."),f&&Bt.createElement(pz,null,f)),Bt.createElement(pS,null,Bt.createElement(gS,null,i?`Context: ${i}`:"No story selected"),Bt.createElement("div",{style:{display:"flex",gap:"8px"}},Bt.createElement(Po,{type:"button",onClick:S,disabled:c},"Cancel"),Bt.createElement(Qt,{type:"submit",disabled:c||!u.trim()},c?"Sending\u2026":"Send")))))):null}ke();De();ct();on();var mz=Sn.div({display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",gap:"8px"}),hz=Sn.div({display:"inline-flex",alignItems:"center",gap:"6px",flexShrink:0,userSelect:"none"}),xz=Sn.span(({theme:e})=>({width:"20px",height:"20px",display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:"5px",background:`linear-gradient(135deg, ${lp} 0%, ${W} 100%)`,color:e.color.lightest,fontSize:"11px",fontWeight:900,letterSpacing:"-0.5px",boxShadow:"0 1px 2px rgba(0,0,0,0.15)"})),yz=Sn.span(({theme:e})=>({fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,letterSpacing:"-0.2px",color:e.color.defaultText})),bz=Sn.span(({theme:e})=>({fontSize:"10px",fontFamily:e.typography.fonts.mono,color:e.color.mediumdark,opacity:.8,marginLeft:"2px"})),wz=Sn.div({display:"flex",alignItems:"center",gap:"6px",flexShrink:0}),vz=Sn.span(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"999px",fontSize:"10px",fontWeight:e.typography.weight.bold,lineHeight:1.6,color:e.color.mediumdark,backgroundColor:e.background.hoverable,border:`1px solid ${e.appBorderColor}`,userSelect:"none",cursor:"default","& svg":{width:"11px",height:"11px"}})),Sz=Sn.div({position:"relative"}),kz=Sn.button(({theme:e})=>({width:"22px",height:"22px",padding:0,background:e.background.app,border:`1px solid ${e.appBorderColor}`,borderRadius:"50%",color:e.color.defaultText,cursor:"pointer",fontSize:"10px",fontWeight:600,display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s","&:hover":{backgroundColor:e.background.hoverable}})),Cz=Sn.div(({theme:e})=>({position:"absolute",top:"calc(100% + 6px)",right:0,minWidth:"220px",backgroundColor:e.background.content,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,boxShadow:"0 8px 24px rgba(0,0,0,0.14)",zIndex:1e3,overflow:"hidden",padding:"4px"})),Iz=Sn.div(({theme:e})=>({padding:"8px 10px 10px",borderBottom:`1px solid ${e.appBorderColor}`,marginBottom:"4px"})),Tz=Sn.div(({theme:e})=>({fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),Ez=Sn.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:"2px"})),Gm=Sn.button(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",width:"100%",padding:"7px 10px",border:"none",borderRadius:e.appBorderRadius,background:"transparent",color:e.color.defaultText,fontSize:e.typography.size.s2,textAlign:"left",cursor:"pointer",transition:"background 0.12s","&:hover":{backgroundColor:e.background.hoverable}})),Rz=Sn.div(({theme:e})=>({height:"1px",margin:"4px 0",backgroundColor:e.appBorderColor})),mS=Sn.button(({theme:e,isLow:t})=>({display:"flex",alignItems:"center",gap:"6px",padding:"4px 8px",background:"transparent",border:"none",borderRadius:e.appBorderRadius,color:t?e.color.warning:Ye.green,cursor:"pointer",fontFamily:e.typography.fonts.mono,fontSize:"11px",fontWeight:e.typography.weight.bold,transition:"background 0.15s","&:hover":{backgroundColor:e.background.hoverable}})),hS=Sn.span(({theme:e,isLow:t})=>({width:"6px",height:"6px",borderRadius:"50%",flexShrink:0,backgroundColor:t?e.color.warning:Ye.green})),Az=Sn.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)"}}}),Fz=Sn.button(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",width:"28px",height:"28px",border:"none",borderRadius:e.appBorderRadius,backgroundColor:"transparent",color:e.color.mediumdark,cursor:"pointer",transition:"all 0.15s","& svg":{width:"14px",height:"14px"},"&:hover":{backgroundColor:e.background.hoverable,color:e.color.defaultText}})),Pz=Sn.button({position:"fixed",bottom:"20px",right:"20px",width:"48px",height:"48px",borderRadius:"50%",backgroundColor:W,color:"white",border:"none",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"22px",cursor:"pointer",boxShadow:`0 4px 14px ${W}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 ${W}88, 0 3px 6px rgba(0,0,0,0.15)`},"&:active":{transform:"scale(0.96)"}}),Mz=30*1e3,qm=({onOpenSettings:e})=>{let[t,n]=iu(!1),[r,o]=iu(!1),[i,a]=iu(!1),[s,u]=iu(!1),l=fz(null),{usageData:c,usageLastFetched:p,setUsageData:g,sessionToken:d,resetAuth:f}=ye(),{userRole:y,roleOverride:I,featureFlags:S}=ge(),x=I??y,M=!!d&&d.startsWith("uic_anon_"),z=x==="admin"||!!S.enableAiReview;Wm(()=>{(async()=>{if(!(!d||p&&Date.now()-p<Mz&&c)){u(!0);try{let R=K(),v=await Z(`${R}/api/addon/account`,{headers:{Authorization:`Bearer ${d}`}});if(v.ok){let A=await v.json();g(A)}}catch(R){console.error("Failed to fetch balance:",R)}finally{u(!1)}}})()},[d,p,c,g]),Wm(()=>{let h=()=>{document.visibilityState==="visible"&&t&&n(!1)},b=()=>{t&&n(!1)};return document.addEventListener("visibilitychange",h),window.addEventListener("focus",b),()=>{document.removeEventListener("visibilitychange",h),window.removeEventListener("focus",b)}},[t]),Wm(()=>{if(!i)return;let h=R=>{l.current&&!l.current.contains(R.target)&&a(!1)},b=R=>{R.key==="Escape"&&a(!1)};return document.addEventListener("mousedown",h),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",h),document.removeEventListener("keydown",b)}},[i]);let O=Vm(()=>{n(!0)},[]),L=Vm(()=>{n(!1)},[]),_=Vm(async()=>{if(a(!1),d)try{await fetch(`${K()}/api/addon/auth/sign-out`,{method:"POST",headers:{Authorization:`Bearer ${d}`}})}catch{}f()},[d,f]),m=c?.creditBalance??0,k=m<2&&!s,C=c?.email,E=(()=>{if(!C)return"?";let h=C.split("@")[0],b=h.split(/[^a-zA-Z0-9]+/).filter(Boolean);return b.length>=2?(b[0][0]+b[1][0]).toUpperCase():h.slice(0,2).toUpperCase()})();return xt.createElement(mz,null,xt.createElement(hz,null,xt.createElement(xz,{"aria-hidden":!0},"\u21CB"),xt.createElement(yz,null,jt.NAME),xt.createElement(bz,null,"v","0.12.1")),xt.createElement(wz,null,M&&xt.createElement(vz,{title:"Guest session \u2014 sign up to save your work"},xt.createElement("span",{"aria-hidden":!0},xt.createElement(gs,null)),"Guest"),d&&y==="admin"&&x==="admin"&&xt.createElement(dS,null),d&&S.showCosts&&z&&xt.createElement(mS,{onClick:O,isLow:k,title:s?"Loading...":c?k?"Low balance - click to top up":"Credit balance - click for details":"Click to load balance"},s?xt.createElement(Az,null):c?xt.createElement(xt.Fragment,null,xt.createElement(hS,{isLow:k}),"$",m.toFixed(2)):"..."),d&&!S.showCosts&&c&&z&&xt.createElement(mS,{onClick:O,isLow:Math.floor(m)<=3,title:`${Math.floor(m)} review credits \u2014 click for details`},xt.createElement(hS,{isLow:Math.floor(m)<=3}),Math.floor(m)),e&&d&&xt.createElement(Fz,{onClick:e,title:"Settings","aria-label":"Settings"},xt.createElement(fp,null)),!M&&xt.createElement(Sz,{ref:l},xt.createElement(kz,{title:"Account","aria-label":"Account",onClick:()=>a(h=>!h)},E),i&&xt.createElement(Cz,{role:"menu"},xt.createElement(Iz,null,xt.createElement(Tz,null,C||"Account"),c?.plan&&xt.createElement(Ez,null,c.plan," plan")),xt.createElement(Gm,{role:"menuitem",onClick:()=>{a(!1),O()}},xt.createElement("span",{"aria-hidden":!0},xt.createElement(gs,null))," ","Account & usage"),e&&xt.createElement(Gm,{role:"menuitem",onClick:()=>{a(!1),e()}},xt.createElement("span",{"aria-hidden":!0},xt.createElement(fp,null))," ","Settings"),xt.createElement(Rz,null),xt.createElement(Gm,{role:"menuitem",onClick:_},"Sign out")),t&&xt.createElement(cS,{onClose:L}))),d&&xt.createElement(Pz,{onClick:()=>o(!0),title:"Send feedback","aria-label":"Send feedback"},"\u{1F4AC}"),xt.createElement(fS,{isOpen:r,onClose:()=>o(!1)}))};import _e,{useEffect as OU,useRef as cd,useState as $U}from"react";import Xn from"react";ke();He();De();ct();on();import{useState as bS,useCallback as to,useRef as wS,useEffect as Ym}from"react";De();ct();var Lz=K(),Ra=null;function xS(e){Ra=e}async function yS(e){if(!Ra||!e||e===Ra||e.startsWith("uic_anon_"))return null;let t=Ra;Ra=null;try{let n=await Z(`${Lz}/api/anonymous/claim`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify({anonymousToken:t})});if(!n.ok)throw new Error(`claim failed: ${n.status}`);let r=await n.json().catch(()=>({}));return typeof r?.claimedProjects=="number"?r.claimedProjects:0}catch(n){throw Ra=t,n}}var _r=K();w.debug("[useAuth] Module loaded, APP_URL:",_r);var au=null,su=null,Ys=null;function Ks(){au&&(clearInterval(au),au=null),su&&(clearTimeout(su),su=null)}var no=()=>{let e=wS(null),t=wS(null),n=to(()=>{t.current&&(clearTimeout(t.current),t.current=null)},[]),{sessionToken:r,apiKey:o,authMethod:i,deviceCode:a,userCode:s,verificationUri:u,isConnected:l,authError:c,setSessionToken:p,setApiKey:g,setAuthMethod:d,setDeviceCode:f,setUserCode:y,setVerificationUri:I,setPollingInterval:S,setAuthError:x,resetAuth:M}=ye(),[z,O]=bS(!1),[L,_]=bS(!1),m=to(()=>{Ks(),Ys=null},[]),k=to(P=>{Ys=P,Ks();let N=async()=>{let T=Ys;if(!T){Ks();return}try{let H=await(await fetch(`${_r}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:T})})).json();H.status==="authorized"&&H.session_token?(w.debug("[useAuth] \u2705 OAuth poll successful! Got token."),Ks(),n(),Ys=null,localStorage.setItem("uicopilot_session_token",H.session_token),p(H.session_token),O(!1)):H.status==="expired"&&(w.debug("[useAuth] OAuth poll_code expired"),Ks(),n(),Ys=null,O(!1))}catch(D){w.error("[useAuth] OAuth poll error:",D)}};au=setInterval(N,2e3),su=setTimeout(N,1e3)},[p,n]);Ym(()=>{function P(N){if(!N.origin.startsWith(_r))return;let T=N.data;if(!T||typeof T!="object")return;let D=T;if(D.type==="UICOPILOT_AUTH_ERROR"){w.debug("[useAuth] Popup reported auth error:",D.step,D.detail),m(),O(!1);let H=typeof D.step=="string"?D.step:"auth",F=typeof D.detail=="string"?D.detail:"Unknown error";x(`${jt.NAME} auth failed (${H}): ${F}`)}else D.type==="UICOPILOT_AUTH_POLL_CODE"&&typeof D.pollCode=="string"&&D.pollCode&&(w.debug("[useAuth] Popup handed us a fresh poll_code, switching"),x(null),k(D.pollCode))}return window.addEventListener("message",P),()=>window.removeEventListener("message",P)},[k,m,x]);let C=to(async()=>{let T=Math.max(0,Math.round((window.screen.width-480)/2)),D=Math.max(0,Math.round((window.screen.height-640)/2)),H=`width=480,height=640,left=${T},top=${D},resizable=yes,scrollbars=yes`,F=null;try{F=window.open("about:blank","uiparity-signin",H)}catch{}try{w.debug("[useAuth] Starting OAuth flow, requesting poll_code...");let re;try{re=await Z(`${_r}/api/addon/auth/oauth-poll`,{method:"POST"})}catch(ne){let be=ne instanceof Error&&ne.message.includes("timed out")?`Cannot reach ${jt.NAME} server at ${_r}. Is the dashboard running?`:`Connection failed: ${_r} is not responding.`;x(be),w.error("[useAuth]",be),F?.close();return}if(!re.ok){let ne=`Cannot reach ${jt.NAME} server. Is the dashboard running?`;x(ne),w.error("[useAuth]",ne),F?.close();return}let{poll_code:j}=await re.json();w.debug("[useAuth] Got poll_code:",j.substring(0,15)+"...");let Y=localStorage.getItem("uicopilot_force_sign_in")==="true";Y&&localStorage.removeItem("uicopilot_force_sign_in");let J=`${_r}/addon/auth?poll_code=${j}${Y?"&force_sign_in=true":""}`;O(!0),F&&!F.closed?F.location.href=J:window.open(J,"uiparity-signin",H),n(),t.current=setTimeout(()=>{O(!1),m()},9e4),w.debug("[useAuth] Starting OAuth poll for token..."),k(j)}catch(re){w.error("[useAuth] OAuth flow error:",re),x(`Connection failed. Is the dashboard running at ${_r}?`),O(!1),F?.close()}},[x,k,n,m]),E=to(async()=>{try{let P=await fetch(`${_r}/api/addon/auth/device`,{method:"POST"});if(!P.ok)throw new Error("Failed to start device code flow");let N=await P.json();f(N.device_code),y(N.user_code),I(N.verification_uri),window.open(N.verification_uri,"_blank"),h(N.device_code,N.interval*1e3)}catch(P){throw w.error("[useAuth] Device code flow error:",P),P}},[f,y,I]),h=to((P,N)=>{w.debug("[useAuth] Starting polling. Device code:",P,"Interval:",N),e.current&&clearInterval(e.current);let T=async()=>{try{let H=await(await fetch(`${_r}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:P})})).json();H.status==="authorized"?(w.debug("[useAuth] Device code authorization successful!"),e.current&&(clearInterval(e.current),e.current=null),f(null),y(null),I(null),localStorage.setItem("uicopilot_session_token",H.session_token),p(H.session_token),O(!1)):(H.status==="expired"||H.status==="denied")&&(w.debug("[useAuth] Device code expired or denied"),e.current&&(clearInterval(e.current),e.current=null),f(null),y(null),I(null))}catch(D){w.error("[useAuth] Polling error:",D)}};e.current=setInterval(T,N),S(N)},[f,y,I,p,S]),b=to(()=>{e.current&&(clearInterval(e.current),e.current=null),f(null),y(null),I(null),S(null)},[f,y,I,S]),R=to(P=>{g(P),p(P),localStorage.setItem("uicopilot_api_key",P)},[g,p]),v=to(async()=>{if(r)try{await Z(`${_r}/api/addon/auth/sign-out`,{method:"POST",headers:{Authorization:`Bearer ${r}`}})}catch{}M(),O(!1),e.current&&(clearInterval(e.current),e.current=null),m()},[r,M,m]),A=to(async()=>{_(!0),x(null);try{let P=await Z(`${_r}/api/anonymous/session`,{method:"POST"});if(!P.ok)throw new Error(`anonymous session ${P.status}`);let N=await P.json();if(!N?.token)throw new Error("anonymous session: no token");p(N.token)}catch{x("Couldn't start a guest session. Please try again.")}finally{_(!1)}},[p,x]),B=to(()=>{r&&r.startsWith("uic_anon_")&&(xS(r),typeof localStorage<"u"&&localStorage.removeItem("uicopilot_force_sign_in")),C()},[r,C]);return Ym(()=>{!r||r.startsWith("uic_anon_")||yS(r).then(P=>{P!==null&&w.info(`[useAuth] Guest work claimed (${P} project${P===1?"":"s"}).`)}).catch(P=>{w.error("[useAuth] Guest claim failed:",P)})},[r]),Ym(()=>()=>{e.current&&clearInterval(e.current),n()},[n]),{sessionToken:r,apiKey:o,authMethod:i,deviceCode:a,userCode:s,verificationUri:u,isConnected:l,authError:c,oauthPending:z,anonPending:L,isAnonymous:!!r&&r.startsWith("uic_anon_"),setAuthMethod:d,startOAuth:C,startAnonymous:A,signUpToSave:B,startDeviceCode:E,cancelDeviceCode:b,saveApiKey:R,logout:v}};ke();He();De();ct();import{useCallback as lu}from"react";var Xs=K(),Ir=()=>{let{projects:e,selectedProjectId:t,loadingProjects:n,setProjects:r,setSelectedProjectId:o,setLoadingProjects:i,getSelectedProject:a}=Ke(),{sessionToken:s}=ye(),u=lu(async()=>{if(!s){w.debug("[useProjects] No session token, skipping fetch");return}try{i(!0),w.debug("[useProjects] Fetching from:",`${Xs}/api/projects`);let g=await Z(`${Xs}/api/projects`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`}});if(g.ok){let d=await g.json();w.debug("[useProjects] Projects:",d.projects),r(d.projects||[])}else w.error("[useProjects] Failed to fetch projects:",g.status,g.statusText)}catch(g){w.error("[useProjects] Error fetching projects:",g)}finally{i(!1)}},[s,r,i]),l=lu(async g=>{if(!s)throw new Error("Not authenticated");let d=await Z(`${Xs}/api/projects`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},body:JSON.stringify(g)});if(!d.ok)throw new Error("Failed to create project");let f=await d.json();return await u(),f.project},[s,u]),c=lu(async(g,d)=>{if(!s)throw new Error("Not authenticated");let f={};if(d.name!==void 0&&(f.name=d.name),d.description!==void 0&&(f.description=d.description),d.figmaFileUrl!==void 0&&(f.figmaFileId=d.figmaFileUrl===""?null:d.figmaFileUrl),!(await Z(`${Xs}/api/projects/${g}`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},body:JSON.stringify(f)})).ok)throw new Error("Failed to update project");await u()},[s,u]),p=lu(async g=>{if(!s)throw new Error("Not authenticated");if(!(await Z(`${Xs}/api/projects/${g}`,{method:"DELETE",headers:{Authorization:`Bearer ${s}`}})).ok)throw new Error("Failed to delete project");await u(),t===g&&o(null)},[s,t,u,o]);return{projects:e,selectedProjectId:t,selectedProject:a(),loadingProjects:n,setSelectedProjectId:o,fetchProjects:u,createProject:l,updateProject:c,deleteProject:p}};ke();var Js=()=>{let{showComponentBrowser:e,figmaFileUrl:t,currentMapping:n,mappingSource:r,loadingMapping:o,showFigmaQuality:i,setShowComponentBrowser:a,setFigmaFileUrl:s,setCurrentMapping:u,setMappingSource:l,setLoadingMapping:c,setShowFigmaQuality:p}=pt();return{showComponentBrowser:e,figmaFileUrl:t,currentMapping:n,mappingSource:r,loadingMapping:o,showFigmaQuality:i,setShowComponentBrowser:a,setFigmaFileUrl:s,setCurrentMapping:u,setMappingSource:l,setLoadingMapping:c,setShowFigmaQuality:p,openComponentBrowser:()=>a(!0),closeComponentBrowser:()=>a(!1)}};ke();Zm();fu();import{useCallback as cl,useRef as ku}from"react";He();function mu(){return new Promise(e=>{let t=document.getElementById("storybook-preview-iframe");if(!t||!t.contentWindow){w.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();w.debug("[iframeReload] Triggering cache-busted reload:",o);let i=setTimeout(()=>{w.warn("[iframeReload] Iframe reload timed out after 5s"),t.removeEventListener("load",a),e()},5e3),a=()=>{clearTimeout(i),t.removeEventListener("load",a),w.debug("[iframeReload] Iframe loaded, waiting for HMR and styles to settle..."),setTimeout(()=>{w.debug("[iframeReload] Iframe reloaded and styles should be fresh"),e()},2e3)};t.addEventListener("load",a),t.contentWindow.location.href=o})}function hu(e){return e&&e!=="admin"?{"X-UIC-Role-Preview":e}:{}}var xu=BigInt(4294967295),_S=BigInt(32);function tD(e,t=!1){return t?{h:Number(e&xu),l:Number(e>>_S&xu)}:{h:Number(e>>_S&xu)|0,l:Number(e&xu)|0}}function NS(e,t=!1){let n=e.length,r=new Uint32Array(n),o=new Uint32Array(n);for(let i=0;i<n;i++){let{h:a,l:s}=tD(e[i],t);[r[i],o[i]]=[a,s]}return[r,o]}var OS=(e,t,n)=>e<<n|t>>>32-n,$S=(e,t,n)=>t<<n|e>>>32-n,HS=(e,t,n)=>t<<n-32|e>>>64-n,US=(e,t,n)=>e<<n-32|t>>>64-n;function nD(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function ih(e,t=""){if(!Number.isSafeInteger(e)||e<0){let n=t&&`"${t}" `;throw new Error(`${n}expected integer >= 0, got ${e}`)}}function yu(e,t,n=""){let r=nD(e),o=e?.length,i=t!==void 0;if(!r||i&&o!==t){let a=n&&`"${n}" `,s=i?` of length ${t}`:"",u=r?`length=${o}`:`type=${typeof e}`;throw new Error(a+"expected Uint8Array"+s+", got "+u)}return e}function ah(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 jS(e,t){yu(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 VS(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function sh(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}var rD=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function oD(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function iD(e){for(let t=0;t<e.length;t++)e[t]=oD(e[t]);return e}var lh=rD?e=>e:iD;function WS(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 GS=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var aD=BigInt(0),nl=BigInt(1),sD=BigInt(2),lD=BigInt(7),cD=BigInt(256),uD=BigInt(113),KS=[],XS=[],JS=[];for(let e=0,t=nl,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],KS.push(2*(5*r+n)),XS.push((e+1)*(e+2)/2%64);let o=aD;for(let i=0;i<7;i++)t=(t<<nl^(t>>lD)*uD)%cD,t&sD&&(o^=nl<<(nl<<BigInt(i))-nl);JS.push(o)}var QS=NS(JS,!0),dD=QS[0],pD=QS[1],qS=(e,t,n)=>n>32?HS(e,t,n):OS(e,t,n),YS=(e,t,n)=>n>32?US(e,t,n):$S(e,t,n);function gD(e,t=24){let n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let a=0;a<10;a++)n[a]=e[a]^e[a+10]^e[a+20]^e[a+30]^e[a+40];for(let a=0;a<10;a+=2){let s=(a+8)%10,u=(a+2)%10,l=n[u],c=n[u+1],p=qS(l,c,1)^n[s],g=YS(l,c,1)^n[s+1];for(let d=0;d<50;d+=10)e[a+d]^=p,e[a+d+1]^=g}let o=e[2],i=e[3];for(let a=0;a<24;a++){let s=XS[a],u=qS(o,i,s),l=YS(o,i,s),c=KS[a];o=e[c],i=e[c+1],e[c]=u,e[c+1]=l}for(let a=0;a<50;a+=10){for(let s=0;s<10;s++)n[s]=e[a+s];for(let s=0;s<10;s++)e[a+s]^=~n[(s+2)%10]&n[(s+4)%10]}e[0]^=dD[r],e[1]^=pD[r]}sh(n)}var ch=class e{constructor(t,n,r,o=!1,i=24){Pr(this,"state");Pr(this,"pos",0);Pr(this,"posOut",0);Pr(this,"finished",!1);Pr(this,"state32");Pr(this,"destroyed",!1);Pr(this,"blockLen");Pr(this,"suffix");Pr(this,"outputLen");Pr(this,"enableXOF",!1);Pr(this,"rounds");if(this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=i,ih(r,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=VS(this.state)}clone(){return this._cloneInto()}keccak(){lh(this.state32),gD(this.state32,this.rounds),lh(this.state32),this.posOut=0,this.pos=0}update(t){ah(this),yu(t);let{blockLen:n,state:r}=this,o=t.length;for(let i=0;i<o;){let a=Math.min(n-this.pos,o-i);for(let s=0;s<a;s++)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){ah(this,!1),yu(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 a=Math.min(r-this.posOut,i-o);t.set(n.subarray(this.posOut,this.posOut+a),o),this.posOut+=a,o+=a}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return ih(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(jS(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,sh(this.state)}_cloneInto(t){let{blockLen:n,suffix:r,outputLen:o,rounds:i,enableXOF:a}=this;return t||(t=new e(n,r,o,a,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=a,t.destroyed=this.destroyed,t}},fD=(e,t,n,r={})=>WS(()=>new ch(t,e,n),r);var ZS=fD(6,72,64,GS(10));var mD=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,uh=Math.ceil,Or=Math.floor,pr="[BigNumber Error] ",e4=pr+"Number primitive has more than 15 significant digits: ",ro=1e14,nt=14,dh=9007199254740991,ph=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],ci=1e7,Ln=1e9;function t4(e){var t,n,r,o=x.prototype={constructor:x,toString:null,valueOf:null},i=new x(1),a=20,s=4,u=-7,l=21,c=-1e7,p=1e7,g=!1,d=1,f=0,y={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},I="0123456789abcdefghijklmnopqrstuvwxyz",S=!0;function x(m,k){var C,E,h,b,R,v,A,B,P=this;if(!(P instanceof x))return new x(m,k);if(k==null){if(m&&m._isBigNumber===!0){P.s=m.s,!m.c||m.e>p?P.c=P.e=null:m.e<c?P.c=[P.e=0]:(P.e=m.e,P.c=m.c.slice());return}if((v=typeof m=="number")&&m*0==0){if(P.s=1/m<0?(m=-m,-1):1,m===~~m){for(b=0,R=m;R>=10;R/=10,b++);b>p?P.c=P.e=null:(P.e=b,P.c=[m]);return}B=String(m)}else{if(!mD.test(B=String(m)))return r(P,B,v);P.s=B.charCodeAt(0)==45?(B=B.slice(1),-1):1}(b=B.indexOf("."))>-1&&(B=B.replace(".","")),(R=B.search(/e/i))>0?(b<0&&(b=R),b+=+B.slice(R+1),B=B.substring(0,R)):b<0&&(b=B.length)}else{if(an(k,2,I.length,"Base"),k==10&&S)return P=new x(m),L(P,a+P.e+1,s);if(B=String(m),v=typeof m=="number"){if(m*0!=0)return r(P,B,v,k);if(P.s=1/m<0?(B=B.slice(1),-1):1,x.DEBUG&&B.replace(/^0\.0*|\./,"").length>15)throw Error(e4+m)}else P.s=B.charCodeAt(0)===45?(B=B.slice(1),-1):1;for(C=I.slice(0,k),b=R=0,A=B.length;R<A;R++)if(C.indexOf(E=B.charAt(R))<0){if(E=="."){if(R>b){b=A;continue}}else if(!h&&(B==B.toUpperCase()&&(B=B.toLowerCase())||B==B.toLowerCase()&&(B=B.toUpperCase()))){h=!0,R=-1,b=0;continue}return r(P,String(m),v,k)}v=!1,B=n(B,k,10,P.s),(b=B.indexOf("."))>-1?B=B.replace(".",""):b=B.length}for(R=0;B.charCodeAt(R)===48;R++);for(A=B.length;B.charCodeAt(--A)===48;);if(B=B.slice(R,++A)){if(A-=R,v&&x.DEBUG&&A>15&&(m>dh||m!==Or(m)))throw Error(e4+P.s*m);if((b=b-R-1)>p)P.c=P.e=null;else if(b<c)P.c=[P.e=0];else{if(P.e=b,P.c=[],R=(b+1)%nt,b<0&&(R+=nt),R<A){for(R&&P.c.push(+B.slice(0,R)),A-=nt;R<A;)P.c.push(+B.slice(R,R+=nt));R=nt-(B=B.slice(R)).length}else R-=A;for(;R--;B+="0");P.c.push(+B)}}else P.c=[P.e=0]}x.clone=t4,x.ROUND_UP=0,x.ROUND_DOWN=1,x.ROUND_CEIL=2,x.ROUND_FLOOR=3,x.ROUND_HALF_UP=4,x.ROUND_HALF_DOWN=5,x.ROUND_HALF_EVEN=6,x.ROUND_HALF_CEIL=7,x.ROUND_HALF_FLOOR=8,x.EUCLID=9,x.config=x.set=function(m){var k,C;if(m!=null)if(typeof m=="object"){if(m.hasOwnProperty(k="DECIMAL_PLACES")&&(C=m[k],an(C,0,Ln,k),a=C),m.hasOwnProperty(k="ROUNDING_MODE")&&(C=m[k],an(C,0,8,k),s=C),m.hasOwnProperty(k="EXPONENTIAL_AT")&&(C=m[k],C&&C.pop?(an(C[0],-Ln,0,k),an(C[1],0,Ln,k),u=C[0],l=C[1]):(an(C,-Ln,Ln,k),u=-(l=C<0?-C:C))),m.hasOwnProperty(k="RANGE"))if(C=m[k],C&&C.pop)an(C[0],-Ln,-1,k),an(C[1],1,Ln,k),c=C[0],p=C[1];else if(an(C,-Ln,Ln,k),C)c=-(p=C<0?-C:C);else throw Error(pr+k+" cannot be zero: "+C);if(m.hasOwnProperty(k="CRYPTO"))if(C=m[k],C===!!C)if(C)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))g=C;else throw g=!C,Error(pr+"crypto unavailable");else g=C;else throw Error(pr+k+" not true or false: "+C);if(m.hasOwnProperty(k="MODULO_MODE")&&(C=m[k],an(C,0,9,k),d=C),m.hasOwnProperty(k="POW_PRECISION")&&(C=m[k],an(C,0,Ln,k),f=C),m.hasOwnProperty(k="FORMAT"))if(C=m[k],typeof C=="object")y=C;else throw Error(pr+k+" not an object: "+C);if(m.hasOwnProperty(k="ALPHABET"))if(C=m[k],typeof C=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(C))S=C.slice(0,10)=="0123456789",I=C;else throw Error(pr+k+" invalid: "+C)}else throw Error(pr+"Object expected: "+m);return{DECIMAL_PLACES:a,ROUNDING_MODE:s,EXPONENTIAL_AT:[u,l],RANGE:[c,p],CRYPTO:g,MODULO_MODE:d,POW_PRECISION:f,FORMAT:y,ALPHABET:I}},x.isBigNumber=function(m){if(!m||m._isBigNumber!==!0)return!1;if(!x.DEBUG)return!0;var k,C,E=m.c,h=m.e,b=m.s;e:if({}.toString.call(E)=="[object Array]"){if((b===1||b===-1)&&h>=-Ln&&h<=Ln&&h===Or(h)){if(E[0]===0){if(h===0&&E.length===1)return!0;break e}if(k=(h+1)%nt,k<1&&(k+=nt),String(E[0]).length==k){for(k=0;k<E.length;k++)if(C=E[k],C<0||C>=ro||C!==Or(C))break e;if(C!==0)return!0}}}else if(E===null&&h===null&&(b===null||b===1||b===-1))return!0;throw Error(pr+"Invalid BigNumber: "+m)},x.maximum=x.max=function(){return z(arguments,-1)},x.minimum=x.min=function(){return z(arguments,1)},x.random=(function(){var m=9007199254740992,k=Math.random()*m&2097151?function(){return Or(Math.random()*m)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(C){var E,h,b,R,v,A=0,B=[],P=new x(i);if(C==null?C=a:an(C,0,Ln),R=uh(C/nt),g)if(crypto.getRandomValues){for(E=crypto.getRandomValues(new Uint32Array(R*=2));A<R;)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]):(B.push(v%1e14),A+=2);A=R/2}else if(crypto.randomBytes){for(E=crypto.randomBytes(R*=7);A<R;)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):(B.push(v%1e14),A+=7);A=R/7}else throw g=!1,Error(pr+"crypto unavailable");if(!g)for(;A<R;)v=k(),v<9e15&&(B[A++]=v%1e14);for(R=B[--A],C%=nt,R&&C&&(v=ph[nt-C],B[A]=Or(R/v)*v);B[A]===0;B.pop(),A--);if(A<0)B=[b=0];else{for(b=-1;B[0]===0;B.splice(0,1),b-=nt);for(A=1,v=B[0];v>=10;v/=10,A++);A<nt&&(b-=nt-A)}return P.e=b,P.c=B,P}})(),x.sum=function(){for(var m=1,k=arguments,C=new x(k[0]);m<k.length;)C=C.plus(k[m++]);return C},n=(function(){var m="0123456789";function k(C,E,h,b){for(var R,v=[0],A,B=0,P=C.length;B<P;){for(A=v.length;A--;v[A]*=E);for(v[0]+=b.indexOf(C.charAt(B++)),R=0;R<v.length;R++)v[R]>h-1&&(v[R+1]==null&&(v[R+1]=0),v[R+1]+=v[R]/h|0,v[R]%=h)}return v.reverse()}return function(C,E,h,b,R){var v,A,B,P,N,T,D,H,F=C.indexOf("."),re=a,j=s;for(F>=0&&(P=f,f=0,C=C.replace(".",""),H=new x(E),T=H.pow(C.length-F),f=P,H.c=k(Uo(Nr(T.c),T.e,"0"),10,h,m),H.e=H.c.length),D=k(C,E,h,R?(v=I,m):(v=m,I)),B=P=D.length;D[--P]==0;D.pop());if(!D[0])return v.charAt(0);if(F<0?--B:(T.c=D,T.e=B,T.s=b,T=t(T,H,re,j,h),D=T.c,N=T.r,B=T.e),A=B+re+1,F=D[A],P=h/2,N=N||A<0||D[A+1]!=null,N=j<4?(F!=null||N)&&(j==0||j==(T.s<0?3:2)):F>P||F==P&&(j==4||N||j==6&&D[A-1]&1||j==(T.s<0?8:7)),A<1||!D[0])C=N?Uo(v.charAt(1),-re,v.charAt(0)):v.charAt(0);else{if(D.length=A,N)for(--h;++D[--A]>h;)D[A]=0,A||(++B,D=[1].concat(D));for(P=D.length;!D[--P];);for(F=0,C="";F<=P;C+=v.charAt(D[F++]));C=Uo(C,B,v.charAt(0))}return C}})(),t=(function(){function m(E,h,b){var R,v,A,B,P=0,N=E.length,T=h%ci,D=h/ci|0;for(E=E.slice();N--;)A=E[N]%ci,B=E[N]/ci|0,R=D*A+B*T,v=T*A+R%ci*ci+P,P=(v/b|0)+(R/ci|0)+D*B,E[N]=v%b;return P&&(E=[P].concat(E)),E}function k(E,h,b,R){var v,A;if(b!=R)A=b>R?1:-1;else for(v=A=0;v<b;v++)if(E[v]!=h[v]){A=E[v]>h[v]?1:-1;break}return A}function C(E,h,b,R){for(var v=0;b--;)E[b]-=v,v=E[b]<h[b]?1:0,E[b]=v*R+E[b]-h[b];for(;!E[0]&&E.length>1;E.splice(0,1));}return function(E,h,b,R,v){var A,B,P,N,T,D,H,F,re,j,Y,J,ne,Re,be,fe,Me,me=E.s==h.s?1:-1,ze=E.c,he=h.c;if(!ze||!ze[0]||!he||!he[0])return new x(!E.s||!h.s||(ze?he&&ze[0]==he[0]:!he)?NaN:ze&&ze[0]==0||!he?me*0:me/0);for(F=new x(me),re=F.c=[],B=E.e-h.e,me=b+B+1,v||(v=ro,B=$r(E.e/nt)-$r(h.e/nt),me=me/nt|0),P=0;he[P]==(ze[P]||0);P++);if(he[P]>(ze[P]||0)&&B--,me<0)re.push(1),N=!0;else{for(Re=ze.length,fe=he.length,P=0,me+=2,T=Or(v/(he[0]+1)),T>1&&(he=m(he,T,v),ze=m(ze,T,v),fe=he.length,Re=ze.length),ne=fe,j=ze.slice(0,fe),Y=j.length;Y<fe;j[Y++]=0);Me=he.slice(),Me=[0].concat(Me),be=he[0],he[1]>=v/2&&be++;do{if(T=0,A=k(he,j,fe,Y),A<0){if(J=j[0],fe!=Y&&(J=J*v+(j[1]||0)),T=Or(J/be),T>1)for(T>=v&&(T=v-1),D=m(he,T,v),H=D.length,Y=j.length;k(D,j,H,Y)==1;)T--,C(D,fe<H?Me:he,H,v),H=D.length,A=1;else T==0&&(A=T=1),D=he.slice(),H=D.length;if(H<Y&&(D=[0].concat(D)),C(j,D,Y,v),Y=j.length,A==-1)for(;k(he,j,fe,Y)<1;)T++,C(j,fe<Y?Me:he,Y,v),Y=j.length}else A===0&&(T++,j=[0]);re[P++]=T,j[0]?j[Y++]=ze[ne]||0:(j=[ze[ne]],Y=1)}while((ne++<Re||j[0]!=null)&&me--);N=j[0]!=null,re[0]||re.splice(0,1)}if(v==ro){for(P=1,me=re[0];me>=10;me/=10,P++);L(F,b+(F.e=P+B*nt-1)+1,R,N)}else F.e=B,F.r=+N;return F}})();function M(m,k,C,E){var h,b,R,v,A;if(C==null?C=s:an(C,0,8),!m.c)return m.toString();if(h=m.c[0],R=m.e,k==null)A=Nr(m.c),A=E==1||E==2&&(R<=u||R>=l)?wu(A,R):Uo(A,R,"0");else if(m=L(new x(m),k,C),b=m.e,A=Nr(m.c),v=A.length,E==1||E==2&&(k<=b||b<=u)){for(;v<k;A+="0",v++);A=wu(A,b)}else if(k-=R+(E===2&&b>R),A=Uo(A,b,"0"),b+1>v){if(--k>0)for(A+=".";k--;A+="0");}else if(k+=b-v,k>0)for(b+1==v&&(A+=".");k--;A+="0");return m.s<0&&h?"-"+A:A}function z(m,k){for(var C,E,h=1,b=new x(m[0]);h<m.length;h++)E=new x(m[h]),(!E.s||(C=Hi(b,E))===k||C===0&&b.s===k)&&(b=E);return b}function O(m,k,C){for(var E=1,h=k.length;!k[--h];k.pop());for(h=k[0];h>=10;h/=10,E++);return(C=E+C*nt-1)>p?m.c=m.e=null:C<c?m.c=[m.e=0]:(m.e=C,m.c=k),m}r=(function(){var m=/^(-?)0([xbo])(?=\w[\w.]*$)/i,k=/^([^.]+)\.$/,C=/^\.([^.]+)$/,E=/^-?(Infinity|NaN)$/,h=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(b,R,v,A){var B,P=v?R:R.replace(h,"");if(E.test(P))b.s=isNaN(P)?null:P<0?-1:1;else{if(!v&&(P=P.replace(m,function(N,T,D){return B=(D=D.toLowerCase())=="x"?16:D=="b"?2:8,!A||A==B?T:N}),A&&(B=A,P=P.replace(k,"$1").replace(C,"0.$1")),R!=P))return new x(P,B);if(x.DEBUG)throw Error(pr+"Not a"+(A?" base "+A:"")+" number: "+R);b.s=null}b.c=b.e=null}})();function L(m,k,C,E){var h,b,R,v,A,B,P,N=m.c,T=ph;if(N){e:{for(h=1,v=N[0];v>=10;v/=10,h++);if(b=k-h,b<0)b+=nt,R=k,A=N[B=0],P=Or(A/T[h-R-1]%10);else if(B=uh((b+1)/nt),B>=N.length)if(E){for(;N.length<=B;N.push(0));A=P=0,h=1,b%=nt,R=b-nt+1}else break e;else{for(A=v=N[B],h=1;v>=10;v/=10,h++);b%=nt,R=b-nt+h,P=R<0?0:Or(A/T[h-R-1]%10)}if(E=E||k<0||N[B+1]!=null||(R<0?A:A%T[h-R-1]),E=C<4?(P||E)&&(C==0||C==(m.s<0?3:2)):P>5||P==5&&(C==4||E||C==6&&(b>0?R>0?A/T[h-R]:0:N[B-1])%10&1||C==(m.s<0?8:7)),k<1||!N[0])return N.length=0,E?(k-=m.e+1,N[0]=T[(nt-k%nt)%nt],m.e=-k||0):N[0]=m.e=0,m;if(b==0?(N.length=B,v=1,B--):(N.length=B+1,v=T[nt-b],N[B]=R>0?Or(A/T[h-R]%T[R])*v:0),E)for(;;)if(B==0){for(b=1,R=N[0];R>=10;R/=10,b++);for(R=N[0]+=v,v=1;R>=10;R/=10,v++);b!=v&&(m.e++,N[0]==ro&&(N[0]=1));break}else{if(N[B]+=v,N[B]!=ro)break;N[B--]=0,v=1}for(b=N.length;N[--b]===0;N.pop());}m.e>p?m.c=m.e=null:m.e<c&&(m.c=[m.e=0])}return m}function _(m){var k,C=m.e;return C===null?m.toString():(k=Nr(m.c),k=C<=u||C>=l?wu(k,C):Uo(k,C,"0"),m.s<0?"-"+k:k)}return o.absoluteValue=o.abs=function(){var m=new x(this);return m.s<0&&(m.s=1),m},o.comparedTo=function(m,k){return Hi(this,new x(m,k))},o.decimalPlaces=o.dp=function(m,k){var C,E,h,b=this;if(m!=null)return an(m,0,Ln),k==null?k=s:an(k,0,8),L(new x(b),m+b.e+1,k);if(!(C=b.c))return null;if(E=((h=C.length-1)-$r(this.e/nt))*nt,h=C[h])for(;h%10==0;h/=10,E--);return E<0&&(E=0),E},o.dividedBy=o.div=function(m,k){return t(this,new x(m,k),a,s)},o.dividedToIntegerBy=o.idiv=function(m,k){return t(this,new x(m,k),0,1)},o.exponentiatedBy=o.pow=function(m,k){var C,E,h,b,R,v,A,B,P,N=this;if(m=new x(m),m.c&&!m.isInteger())throw Error(pr+"Exponent not an integer: "+_(m));if(k!=null&&(k=new x(k)),v=m.e>14,!N.c||!N.c[0]||N.c[0]==1&&!N.e&&N.c.length==1||!m.c||!m.c[0])return P=new x(Math.pow(+_(N),v?m.s*(2-bu(m)):+_(m))),k?P.mod(k):P;if(A=m.s<0,k){if(k.c?!k.c[0]:!k.s)return new x(NaN);E=!A&&N.isInteger()&&k.isInteger(),E&&(N=N.mod(k))}else{if(m.e>9&&(N.e>0||N.e<-1||(N.e==0?N.c[0]>1||v&&N.c[1]>=24e7:N.c[0]<8e13||v&&N.c[0]<=9999975e7)))return b=N.s<0&&bu(m)?-0:0,N.e>-1&&(b=1/b),new x(A?1/b:b);f&&(b=uh(f/nt+2))}for(v?(C=new x(.5),A&&(m.s=1),B=bu(m)):(h=Math.abs(+_(m)),B=h%2),P=new x(i);;){if(B){if(P=P.times(N),!P.c)break;b?P.c.length>b&&(P.c.length=b):E&&(P=P.mod(k))}if(h){if(h=Or(h/2),h===0)break;B=h%2}else if(m=m.times(C),L(m,m.e+1,1),m.e>14)B=bu(m);else{if(h=+_(m),h===0)break;B=h%2}N=N.times(N),b?N.c&&N.c.length>b&&(N.c.length=b):E&&(N=N.mod(k))}return E?P:(A&&(P=i.div(P)),k?P.mod(k):b?L(P,f,s,R):P)},o.integerValue=function(m){var k=new x(this);return m==null?m=s:an(m,0,8),L(k,k.e+1,m)},o.isEqualTo=o.eq=function(m,k){return Hi(this,new x(m,k))===0},o.isFinite=function(){return!!this.c},o.isGreaterThan=o.gt=function(m,k){return Hi(this,new x(m,k))>0},o.isGreaterThanOrEqualTo=o.gte=function(m,k){return(k=Hi(this,new x(m,k)))===1||k===0},o.isInteger=function(){return!!this.c&&$r(this.e/nt)>this.c.length-2},o.isLessThan=o.lt=function(m,k){return Hi(this,new x(m,k))<0},o.isLessThanOrEqualTo=o.lte=function(m,k){return(k=Hi(this,new x(m,k)))===-1||k===0},o.isNaN=function(){return!this.s},o.isNegative=function(){return this.s<0},o.isPositive=function(){return this.s>0},o.isZero=function(){return!!this.c&&this.c[0]==0},o.minus=function(m,k){var C,E,h,b,R=this,v=R.s;if(m=new x(m,k),k=m.s,!v||!k)return new x(NaN);if(v!=k)return m.s=-k,R.plus(m);var A=R.e/nt,B=m.e/nt,P=R.c,N=m.c;if(!A||!B){if(!P||!N)return P?(m.s=-k,m):new x(N?R:NaN);if(!P[0]||!N[0])return N[0]?(m.s=-k,m):new x(P[0]?R:s==3?-0:0)}if(A=$r(A),B=$r(B),P=P.slice(),v=A-B){for((b=v<0)?(v=-v,h=P):(B=A,h=N),h.reverse(),k=v;k--;h.push(0));h.reverse()}else for(E=(b=(v=P.length)<(k=N.length))?v:k,v=k=0;k<E;k++)if(P[k]!=N[k]){b=P[k]<N[k];break}if(b&&(h=P,P=N,N=h,m.s=-m.s),k=(E=N.length)-(C=P.length),k>0)for(;k--;P[C++]=0);for(k=ro-1;E>v;){if(P[--E]<N[E]){for(C=E;C&&!P[--C];P[C]=k);--P[C],P[E]+=ro}P[E]-=N[E]}for(;P[0]==0;P.splice(0,1),--B);return P[0]?O(m,P,B):(m.s=s==3?-1:1,m.c=[m.e=0],m)},o.modulo=o.mod=function(m,k){var C,E,h=this;return m=new x(m,k),!h.c||!m.s||m.c&&!m.c[0]?new x(NaN):!m.c||h.c&&!h.c[0]?new x(h):(d==9?(E=m.s,m.s=1,C=t(h,m,0,3),m.s=E,C.s*=E):C=t(h,m,0,d),m=h.minus(C.times(m)),!m.c[0]&&d==1&&(m.s=h.s),m)},o.multipliedBy=o.times=function(m,k){var C,E,h,b,R,v,A,B,P,N,T,D,H,F,re,j=this,Y=j.c,J=(m=new x(m,k)).c;if(!Y||!J||!Y[0]||!J[0])return!j.s||!m.s||Y&&!Y[0]&&!J||J&&!J[0]&&!Y?m.c=m.e=m.s=null:(m.s*=j.s,!Y||!J?m.c=m.e=null:(m.c=[0],m.e=0)),m;for(E=$r(j.e/nt)+$r(m.e/nt),m.s*=j.s,A=Y.length,N=J.length,A<N&&(H=Y,Y=J,J=H,h=A,A=N,N=h),h=A+N,H=[];h--;H.push(0));for(F=ro,re=ci,h=N;--h>=0;){for(C=0,T=J[h]%re,D=J[h]/re|0,R=A,b=h+R;b>h;)B=Y[--R]%re,P=Y[R]/re|0,v=D*B+P*T,B=T*B+v%re*re+H[b]+C,C=(B/F|0)+(v/re|0)+D*P,H[b--]=B%F;H[b]=C}return C?++E:H.splice(0,1),O(m,H,E)},o.negated=function(){var m=new x(this);return m.s=-m.s||null,m},o.plus=function(m,k){var C,E=this,h=E.s;if(m=new x(m,k),k=m.s,!h||!k)return new x(NaN);if(h!=k)return m.s=-k,E.minus(m);var b=E.e/nt,R=m.e/nt,v=E.c,A=m.c;if(!b||!R){if(!v||!A)return new x(h/0);if(!v[0]||!A[0])return A[0]?m:new x(v[0]?E:h*0)}if(b=$r(b),R=$r(R),v=v.slice(),h=b-R){for(h>0?(R=b,C=A):(h=-h,C=v),C.reverse();h--;C.push(0));C.reverse()}for(h=v.length,k=A.length,h-k<0&&(C=A,A=v,v=C,k=h),h=0;k;)h=(v[--k]=v[k]+A[k]+h)/ro|0,v[k]=ro===v[k]?0:v[k]%ro;return h&&(v=[h].concat(v),++R),O(m,v,R)},o.precision=o.sd=function(m,k){var C,E,h,b=this;if(m!=null&&m!==!!m)return an(m,1,Ln),k==null?k=s:an(k,0,8),L(new x(b),m,k);if(!(C=b.c))return null;if(h=C.length-1,E=h*nt+1,h=C[h]){for(;h%10==0;h/=10,E--);for(h=C[0];h>=10;h/=10,E++);}return m&&b.e+1>E&&(E=b.e+1),E},o.shiftedBy=function(m){return an(m,-dh,dh),this.times("1e"+m)},o.squareRoot=o.sqrt=function(){var m,k,C,E,h,b=this,R=b.c,v=b.s,A=b.e,B=a+4,P=new x("0.5");if(v!==1||!R||!R[0])return new x(!v||v<0&&(!R||R[0])?NaN:R?b:1/0);if(v=Math.sqrt(+_(b)),v==0||v==1/0?(k=Nr(R),(k.length+A)%2==0&&(k+="0"),v=Math.sqrt(+k),A=$r((A+1)/2)-(A<0||A%2),v==1/0?k="5e"+A:(k=v.toExponential(),k=k.slice(0,k.indexOf("e")+1)+A),C=new x(k)):C=new x(v+""),C.c[0]){for(A=C.e,v=A+B,v<3&&(v=0);;)if(h=C,C=P.times(h.plus(t(b,h,B,1))),Nr(h.c).slice(0,v)===(k=Nr(C.c)).slice(0,v))if(C.e<A&&--v,k=k.slice(v-3,v+1),k=="9999"||!E&&k=="4999"){if(!E&&(L(h,h.e+a+2,0),h.times(h).eq(b))){C=h;break}B+=4,v+=4,E=1}else{(!+k||!+k.slice(1)&&k.charAt(0)=="5")&&(L(C,C.e+a+2,1),m=!C.times(C).eq(b));break}}return L(C,C.e+a+1,s,m)},o.toExponential=function(m,k){return m!=null&&(an(m,0,Ln),m++),M(this,m,k,1)},o.toFixed=function(m,k){return m!=null&&(an(m,0,Ln),m=m+this.e+1),M(this,m,k)},o.toFormat=function(m,k,C){var E,h=this;if(C==null)m!=null&&k&&typeof k=="object"?(C=k,k=null):m&&typeof m=="object"?(C=m,m=k=null):C=y;else if(typeof C!="object")throw Error(pr+"Argument not an object: "+C);if(E=h.toFixed(m,k),h.c){var b,R=E.split("."),v=+C.groupSize,A=+C.secondaryGroupSize,B=C.groupSeparator||"",P=R[0],N=R[1],T=h.s<0,D=T?P.slice(1):P,H=D.length;if(A&&(b=v,v=A,A=b,H-=b),v>0&&H>0){for(b=H%v||v,P=D.substr(0,b);b<H;b+=v)P+=B+D.substr(b,v);A>0&&(P+=B+D.slice(b)),T&&(P="-"+P)}E=N?P+(C.decimalSeparator||"")+((A=+C.fractionGroupSize)?N.replace(new RegExp("\\d{"+A+"}\\B","g"),"$&"+(C.fractionGroupSeparator||"")):N):P}return(C.prefix||"")+E+(C.suffix||"")},o.toFraction=function(m){var k,C,E,h,b,R,v,A,B,P,N,T,D=this,H=D.c;if(m!=null&&(v=new x(m),!v.isInteger()&&(v.c||v.s!==1)||v.lt(i)))throw Error(pr+"Argument "+(v.isInteger()?"out of range: ":"not an integer: ")+_(v));if(!H)return new x(D);for(k=new x(i),B=C=new x(i),E=A=new x(i),T=Nr(H),b=k.e=T.length-D.e-1,k.c[0]=ph[(R=b%nt)<0?nt+R:R],m=!m||v.comparedTo(k)>0?b>0?k:B:v,R=p,p=1/0,v=new x(T),A.c[0]=0;P=t(v,k,0,1),h=C.plus(P.times(E)),h.comparedTo(m)!=1;)C=E,E=h,B=A.plus(P.times(h=B)),A=h,k=v.minus(P.times(h=k)),v=h;return h=t(m.minus(C),E,0,1),A=A.plus(h.times(B)),C=C.plus(h.times(E)),A.s=B.s=D.s,b=b*2,N=t(B,E,b,s).minus(D).abs().comparedTo(t(A,C,b,s).minus(D).abs())<1?[B,E]:[A,C],p=R,N},o.toNumber=function(){return+_(this)},o.toPrecision=function(m,k){return m!=null&&an(m,1,Ln),M(this,m,k,2)},o.toString=function(m){var k,C=this,E=C.s,h=C.e;return h===null?E?(k="Infinity",E<0&&(k="-"+k)):k="NaN":(m==null?k=h<=u||h>=l?wu(Nr(C.c),h):Uo(Nr(C.c),h,"0"):m===10&&S?(C=L(new x(C),a+h+1,s),k=Uo(Nr(C.c),C.e,"0")):(an(m,2,I.length,"Base"),k=n(Uo(Nr(C.c),h,"0"),10,m,E,!0)),E<0&&C.c[0]&&(k="-"+k)),k},o.valueOf=o.toJSON=function(){return _(this)},o._isBigNumber=!0,o[Symbol.toStringTag]="BigNumber",o[Symbol.for("nodejs.util.inspect.custom")]=o.valueOf,e!=null&&x.set(e),x}function $r(e){var t=e|0;return e>0||e===t?t:t-1}function Nr(e){for(var t,n,r=1,o=e.length,i=e[0]+"";r<o;){for(t=e[r++]+"",n=nt-t.length;n--;t="0"+t);i+=t}for(o=i.length;i.charCodeAt(--o)===48;);return i.slice(0,o+1||1)}function Hi(e,t){var n,r,o=e.c,i=t.c,a=e.s,s=t.s,u=e.e,l=t.e;if(!a||!s)return null;if(n=o&&!o[0],r=i&&!i[0],n||r)return n?r?0:-s:a;if(a!=s)return a;if(n=a<0,r=u==l,!o||!i)return r?0:!o^n?1:-1;if(!r)return u>l^n?1:-1;for(s=(u=o.length)<(l=i.length)?u:l,a=0;a<s;a++)if(o[a]!=i[a])return o[a]>i[a]^n?1:-1;return u==l?0:u>l^n?1:-1}function an(e,t,n,r){if(e<t||e>n||e!==Or(e))throw Error(pr+(r||"Argument")+(typeof e=="number"?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function bu(e){var t=e.c.length-1;return $r(e.e/nt)==t&&e.c[t]%2!=0}function wu(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function Uo(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 hD=t4(),n4=hD;var xD=24,rl=32,yD=()=>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,fh=yD(),gh=(e=4,t=fh)=>{let n="";for(;n.length<e;)n=n+Math.floor(t()*36).toString(36);return n};function bD(e){let t=new n4(0);for(let n of e.values())t=t.multipliedBy(256).plus(n);return t}var o4=(e="")=>{let t=new TextEncoder;return bD(ZS(t.encode(e))).toString(36).slice(1)},r4=Array.from({length:26},(e,t)=>String.fromCharCode(t+97)),wD=e=>r4[Math.floor(e()*r4.length)],vD=({globalObj:e=typeof global<"u"?global:typeof window<"u"?window:{},random:t=fh}={})=>{let n=Object.keys(e).toString(),r=n.length?n+gh(rl,t):gh(rl,t);return o4(r).substring(0,rl)},SD=e=>()=>e++,kD=476782367,i4=({random:e=fh,counter:t=SD(Math.floor(e()*kD)),length:n=xD,fingerprint:r=vD({random:e})}={})=>{if(n>rl)throw new Error(`Length must be between 2 and ${rl}. Received: ${n}`);return function(){let i=wD(e),a=Date.now().toString(36),s=t().toString(36),u=gh(n,e),l=`${a+u+s+r}`;return`${i+o4(l).substring(1,n)}`}},ui=CD(i4);function CD(e){let t;return()=>(t||(t=e()),t())}var ED=tc(l4());on();He();var vu=/\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*-\s*(.+)/g;function RD(e){return e.replace(/\*\*/g,"").replace(/\*/g,"").replace(/__/g,"").replace(/_/g," ").trim()}function mh(e,t){let n=[],r=e.split(`
|
|
14
|
+
`,B7="/",z7="*",Zi="",WV="comment",GV="declaration";function qV(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function o(f){var y=f.match(_V);y&&(n+=y.length);var I=f.lastIndexOf(VV);r=~I?f.length-I:r+f.length}function i(){var f={line:n,column:r};return function(y){return y.position=new a(f),l(),y}}function a(f){this.start=f,this.end={line:n,column:r},this.source=t.source}a.prototype.content=e;function s(f){var y=new Error(t.source+":"+n+":"+r+": "+f);if(y.reason=f,y.filename=t.source,y.line=n,y.column=r,y.source=e,!t.silent)throw y}function u(f){var y=f.exec(e);if(y){var I=y[0];return o(I),e=e.slice(I.length),y}}function l(){u(NV)}function c(f){var y;for(f=f||[];y=p();)y!==!1&&f.push(y);return f}function p(){var f=i();if(!(B7!=e.charAt(0)||z7!=e.charAt(1))){for(var y=2;Zi!=e.charAt(y)&&(z7!=e.charAt(y)||B7!=e.charAt(y+1));)++y;if(y+=2,Zi===e.charAt(y-1))return s("End of comment missing");var I=e.slice(2,y-2);return r+=2,o(I),e=e.slice(y),r+=2,f({type:WV,comment:I})}}function g(){var f=i(),y=u(OV);if(y){if(p(),!u($V))return s("property missing ':'");var I=u(HV),S=f({type:GV,property:D7(y[0].replace(L7,Zi)),value:I?D7(I[0].replace(L7,Zi)):Zi});return u(UV),S}}function d(){var f=[];c(f);for(var y;y=g();)y!==!1&&(f.push(y),c(f));return f}return l(),d()}function D7(e){return e?e.replace(jV,Zi):Zi}_7.exports=qV});var O7=Fr(Rl=>{"use strict";var YV=Rl&&Rl.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Rl,"__esModule",{value:!0});Rl.default=XV;var KV=YV(N7());function XV(e,t){let n=null;if(!e||typeof e!="string")return n;let r=(0,KV.default)(e),o=typeof t=="function";return r.forEach(i=>{if(i.type!=="declaration")return;let{property:a,value:s}=i;o?t(a,s,i):s&&(n=n||{},n[a]=s)}),n}});var H7=Fr(vd=>{"use strict";Object.defineProperty(vd,"__esModule",{value:!0});vd.camelCase=void 0;var JV=/^--[a-zA-Z0-9_-]+$/,QV=/-([a-z])/g,ZV=/^[^-]+$/,eW=/^-(webkit|moz|ms|o|khtml)-/,tW=/^-(ms)-/,nW=function(e){return!e||ZV.test(e)||JV.test(e)},rW=function(e,t){return t.toUpperCase()},$7=function(e,t){return"".concat(t,"-")},oW=function(e,t){return t===void 0&&(t={}),nW(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(tW,$7):e=e.replace(eW,$7),e.replace(QV,rW))};vd.camelCase=oW});var j7=Fr((C5,U7)=>{"use strict";var iW=C5&&C5.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},aW=iW(O7()),sW=H7();function k5(e,t){var n={};return!e||typeof e!="string"||(0,aW.default)(e,function(r,o){r&&o&&(n[(0,sW.camelCase)(r,t)]=o)}),n}k5.default=k5;U7.exports=k5});var h8=Fr((ySe,m8)=>{"use strict";var Vd=Object.prototype.hasOwnProperty,f8=Object.prototype.toString,l8=Object.defineProperty,c8=Object.getOwnPropertyDescriptor,u8=function(t){return typeof Array.isArray=="function"?Array.isArray(t):f8.call(t)==="[object Array]"},d8=function(t){if(!t||f8.call(t)!=="[object Object]")return!1;var n=Vd.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&Vd.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var o;for(o in t);return typeof o>"u"||Vd.call(t,o)},p8=function(t,n){l8&&n.name==="__proto__"?l8(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},g8=function(t,n){if(n==="__proto__")if(Vd.call(t,n)){if(c8)return c8(t,n).value}else return;return t[n]};m8.exports=function e(){var t,n,r,o,i,a,s=arguments[0],u=1,l=arguments.length,c=!1;for(typeof s=="boolean"&&(c=s,s=arguments[1]||{},u=2),(s==null||typeof s!="object"&&typeof s!="function")&&(s={});u<l;++u)if(t=arguments[u],t!=null)for(n in t)r=g8(s,n),o=g8(t,n),s!==o&&(c&&o&&(d8(o)||(i=u8(o)))?(i?(i=!1,a=r&&u8(r)?r:[]):a=r&&d8(r)?r:{},p8(s,{name:n,newValue:e(c,a,o)})):typeof o<"u"&&p8(s,{name:n,newValue:o}));return s}});import Fi from"react";import{addons as ap,types as Yx,experimental_getStatusStore as Kx}from"storybook/manager-api";import{AddonPanel as hZ}from"storybook/internal/components";import{styled as xZ}from"storybook/theming";import{styled as tn}from"storybook/theming";var W="#ea580c",ei="#c2410c",lp="#ff6b35",Xx="#A259FF",Jx="#8a3de8",Qx=W,Zx="#d1d5db",nc="#7c3aed",Ye={red:"#ef4444",amber:"#f59e0b",green:"#16a34a",redText:"#b91c1c",amberText:"#b45309",greenText:"#16a34a",criticalRail:"#dc2626",criticalLabel:"#dc2626",majorLabel:"#f59e0b",minorLabel:"#f59e0b",minorRail:"#fbbf24"},ey={color:{text:"#1d4ed8",bg:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.25)"},spacing:{text:"#c2410c",bg:"rgba(249, 115, 22, 0.1)",border:"rgba(249, 115, 22, 0.25)"},typography:{text:"#be185d",bg:"rgba(236, 72, 153, 0.1)",border:"rgba(236, 72, 153, 0.25)"},border:{text:"#047857",bg:"rgba(16, 185, 129, 0.1)",border:"rgba(16, 185, 129, 0.25)"},layout:{text:"#0f766e",bg:"rgba(20, 184, 166, 0.1)",border:"rgba(20, 184, 166, 0.25)"},sizing:{text:"#6d28d9",bg:"rgba(139, 92, 246, 0.1)",border:"rgba(139, 92, 246, 0.25)"}},cp={spec:"#c2410c",ai:"#6d28d9"},te={card:"#ffffff",green:"#10b981",border:"#e5e7eb",track:"#f1f5f9",muted:"#6b7280",locked:"#9ca3af",text:"#111827",subText:"#374151",formBg:"#fafafa",lockedBtnBg:"#f3f4f6",calloutBg:"#fffbeb",calloutText:"#b45309",accentTint:"#fff7ed"},Mi={pillBg:"#fff7ed",pillBorder:"#f5d0b5",iconFrom:"#d97706",iconTo:ei,badgeBg:"#fef3c7",badgeText:"#92400e"};var ty=tn.div(({theme:e})=>({fontFamily:e.typography.fonts.base,height:"100%",display:"flex",flexDirection:"column",backgroundColor:e.background.content,color:e.color.defaultText})),ny=tn.div(({theme:e})=>({flex:1,overflow:"auto",padding:"6px 12px 12px",backgroundColor:e.background.app})),rc=tn.div({marginBottom:"20px"}),oc=tn.label(({theme:e})=>({display:"block",marginBottom:`${e.layoutMargin*.6}px`,fontSize:e.typography.size.s2,fontFamily:e.typography.fonts.base,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),ps=tn.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*2,backgroundColor:e.input.background,color:e.color.defaultText,"&:focus":{outline:"none",borderColor:e.color.secondary,boxShadow:`0 0 0 2px ${e.color.secondary}20`}})),ir=tn.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*2,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"}})),ry=tn(ir)(({theme:e})=>({width:"auto",padding:`${e.layoutMargin*.6}px 28px ${e.layoutMargin*.6}px ${e.layoutMargin}px`,fontSize:e.typography.size.s1})),ic=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*2,cursor:"pointer",transition:"all 0.15s","&:disabled":{opacity:.5,cursor:"not-allowed"}}),Po=tn.button(({theme:e})=>({...ic(e),backgroundColor:e.color.secondary,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),Qt=tn.button(({theme:e})=>({...ic(e),backgroundColor:W,color:e.color.inverseText,boxShadow:`0 2px 4px ${W}4d`,"&:hover:not(:disabled)":{backgroundColor:ei,transform:"translateY(-1px)",boxShadow:`0 4px 8px ${W}66`}})),mo=tn.button(({theme:e})=>({...ic(e),backgroundColor:"transparent",border:`1px solid ${e.appBorderColor}`,color:e.color.defaultText,"&:hover:not(:disabled)":{backgroundColor:e.background.hoverable}})),oy=tn.button(({theme:e})=>({...ic(e),backgroundColor:e.color.negative,color:e.color.inverseText,"&:hover:not(:disabled)":{opacity:.9}})),br=tn.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"}})),up=tn.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"}})),ti=tn.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}})),ni=tn(ps)(({theme:e})=>({paddingLeft:`${e.layoutMargin*3}px`,backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:`${e.layoutMargin}px center`,backgroundSize:"14px"})),TZ=tn.div(({theme:e})=>({padding:`${e.layoutMargin*1.6}px`,borderRadius:e.appBorderRadius*2.5,border:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.content})),iy=tn.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})),EZ=tn.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})),dp=tn.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})),RZ=tn.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%)"}}})),ay=tn.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}}),AZ=tn.div(({theme:e})=>({padding:"40px 20px",textAlign:"center",color:e.color.mediumdark})),FZ=tn.div(({theme:e})=>({fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,marginBottom:`${e.layoutMargin*.8}px`,color:e.color.defaultText})),PZ=tn.div(({theme:e})=>({fontSize:e.typography.size.s2,color:e.color.mediumdark}));import st,{useState as NQ,useEffect as JT}from"react";import{styled as nr}from"storybook/theming";import sy from"react";var pp=({header:e,children:t,footer:n})=>sy.createElement(ty,null,e,sy.createElement(ny,null,t),n);import RE from"react";import{styled as AE}from"storybook/theming";var FE=AE.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})),gp=({toolbar:e})=>RE.createElement(FE,null,e);import HZ from"react";import{styled as ac}from"storybook/theming";var VZ=ac.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})),WZ=ac.div({display:"flex",flex:1}),GZ=ac(ti)(({theme:e,disabled:t})=>({padding:"6px 12px",...t?{color:e.color.mediumlight,cursor:"not-allowed",opacity:.5,"&:hover":{}}:{}})),qZ=ac.div({display:"flex",gap:"8px",alignItems:"center"});import xt,{useState as iu,useCallback as Vm,useEffect as Wm,useRef as fz}from"react";import{styled as Sn}from"storybook/theming";import Ce from"react";var ly=()=>Ce.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"},Ce.createElement("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),Ce.createElement("circle",{cx:"12",cy:"12",r:"3"})),gs=()=>Ce.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"},Ce.createElement("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),Ce.createElement("circle",{cx:"12",cy:"7",r:"4"})),Mr={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"},fs=()=>Ce.createElement("svg",{...Mr},Ce.createElement("circle",{cx:"11",cy:"11",r:"8"}),Ce.createElement("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})),cy=()=>Ce.createElement("svg",{...Mr},Ce.createElement("path",{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07l-1.71 1.71"}),Ce.createElement("path",{d:"M5.17 11.75l-1.71 1.71a5 5 0 0 0 7.07 7.07l1.71-1.71"}),Ce.createElement("line",{x1:"8",y1:"2",x2:"8",y2:"5"}),Ce.createElement("line",{x1:"2",y1:"8",x2:"5",y2:"8"}),Ce.createElement("line",{x1:"16",y1:"22",x2:"16",y2:"19"}),Ce.createElement("line",{x1:"22",y1:"16",x2:"19",y2:"16"})),uy=()=>Ce.createElement("svg",{...Mr},Ce.createElement("polyline",{points:"23 4 23 10 17 10"}),Ce.createElement("polyline",{points:"1 20 1 14 7 14"}),Ce.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 fp=()=>Ce.createElement("svg",{...Mr},Ce.createElement("circle",{cx:"12",cy:"12",r:"3"}),Ce.createElement("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})),sc=()=>Ce.createElement("svg",{...Mr},Ce.createElement("path",{d:"M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3z"}),Ce.createElement("path",{d:"M19 14l.7 1.9L21.6 17l-1.9.7L19 19.6l-.7-1.9L16.4 17l1.9-.7L19 14z"})),dy=()=>Ce.createElement("svg",{...Mr},Ce.createElement("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),Ce.createElement("polyline",{points:"12 5 19 12 12 19"})),py=()=>Ce.createElement("svg",{...Mr},Ce.createElement("path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72Z"}),Ce.createElement("path",{d:"m14 7 3 3"}),Ce.createElement("path",{d:"M5 6v4"}),Ce.createElement("path",{d:"M19 14v4"}),Ce.createElement("path",{d:"M10 2v2"}),Ce.createElement("path",{d:"M7 8H3"}),Ce.createElement("path",{d:"M21 16h-4"}),Ce.createElement("path",{d:"M11 3H9"})),gy=()=>Ce.createElement("svg",{...Mr},Ce.createElement("polyline",{points:"6 9 12 15 18 9"})),fy=()=>Ce.createElement("svg",{...Mr},Ce.createElement("polyline",{points:"20 6 9 17 4 12"})),my=()=>Ce.createElement("svg",{...Mr},Ce.createElement("path",{d:"M7 10v12"}),Ce.createElement("path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z"})),hy=()=>Ce.createElement("svg",{...Mr},Ce.createElement("path",{d:"M3 3v5h5"}),Ce.createElement("path",{d:"M3.05 13A9 9 0 1 0 6 5.3L3 8"}),Ce.createElement("path",{d:"M12 7v5l4 2"})),mp=()=>Ce.createElement("svg",{...Mr},Ce.createElement("path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5a2 2 0 0 0 2 2h1"}),Ce.createElement("path",{d:"M16 3h1a2 2 0 0 1 2 2v5a2 2 0 0 0 2 2 2 2 0 0 0-2 2v5a2 2 0 0 1-2 2h-1"})),Mo=()=>Ce.createElement("svg",{width:"10",height:"15",viewBox:"0 0 38 57","aria-label":"Figma",role:"img"},Ce.createElement("path",{fill:"#1abcfe",d:"M19 28.5a9.5 9.5 0 1 1 19 0 9.5 9.5 0 0 1-19 0z"}),Ce.createElement("path",{fill:"#0acf83",d:"M0 47.5A9.5 9.5 0 0 1 9.5 38H19v9.5a9.5 9.5 0 1 1-19 0z"}),Ce.createElement("path",{fill:"#ff7262",d:"M19 0v19h9.5a9.5 9.5 0 1 0 0-19H19z"}),Ce.createElement("path",{fill:"#f24e1e",d:"M0 9.5A9.5 9.5 0 0 0 9.5 19H19V0H9.5A9.5 9.5 0 0 0 0 9.5z"}),Ce.createElement("path",{fill:"#a259ff",d:"M0 28.5A9.5 9.5 0 0 0 9.5 38H19V19H9.5A9.5 9.5 0 0 0 0 28.5z"})),hp=()=>Ce.createElement("svg",{width:"13",height:"13",viewBox:"0 0 64 64","aria-label":"Storybook",role:"img"},Ce.createElement("path",{fill:"#ff4785",d:"M8 4l1.5 56L56 62l2-58z"}),Ce.createElement("path",{fill:"#fff",d:"M40.5 18.2c-.2 1.5-3.6 2.4-7.6 2.1-4-.3-7-1.6-6.9-3.1.1-1.4 2.4-2 5.3-2 .8 0 1.2-.4 1.2-1.1 0-1.6-3.6-2.6-7-2.6-7 0-10.6 3.8-10.6 7.6 0 6.6 8.9 7 11.4 7.2 5.5.4 6.9 1.5 6.9 3 0 1.6-2.1 2.6-5 2.6-3.8 0-5.6-1.4-5.7-3.1 0-.6-.4-1-1-1l-3.5.1c-.6 0-1 .4-1 1 .2 4.7 4.3 7.6 11.3 7.6 6.7 0 11.2-3.1 11.2-7.6 0-5.7-5-7-11.1-7.5-4.2-.3-6.5-.6-6.5-2 0-1 1.8-1.8 4.4-1.8 2.5 0 4.2.6 4.4 1.7.1.6.5 1 1.1 1l3.5-.1c.6-.1 1-.5 1-1.1z"}));import Le,{useEffect as oS}from"react";import{styled as kt}from"storybook/theming";ke();De();He();ct();var iS=kt.div({position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:1e4}),aS=kt.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})),CB=kt.div({display:"flex",alignItems:"center",gap:"12px",padding:"16px 16px 12px"}),IB=kt.div({width:"36px",height:"36px",borderRadius:"50%",backgroundColor:W,display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:"14px",fontWeight:700,flexShrink:0}),TB=kt.div({display:"flex",flexDirection:"column",gap:"4px"}),EB=kt.div(({theme:e})=>({fontSize:"15px",fontWeight:600,color:e.color.defaultText,lineHeight:1.2})),RB=kt.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"}),AB=kt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px 8px",fontSize:"14px",color:e.color.defaultText})),FB=kt.span(({theme:e})=>({color:e.textMutedColor,fontSize:"13px"})),PB=kt.span(({theme:e})=>({color:e.color.defaultText,fontSize:"15px",fontWeight:600})),MB=kt.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"})),LB=kt.div(({percent:e})=>({height:"100%",width:`${Math.min(100,Math.max(0,e))}%`,background:`linear-gradient(90deg, #f59e0b 0%, ${W} 100%)`,transition:"width 0.3s ease"})),BB=kt.div(({theme:e})=>({padding:"0 16px 14px",fontSize:"12px",color:e.textMutedColor})),zB=kt.div(({theme:e})=>({height:"1px",backgroundColor:e.appBorderColor})),DB=kt.button({width:"100%",padding:"14px 16px",background:"transparent",border:"none",color:W,fontSize:"14px",fontWeight:500,textAlign:"left",cursor:"pointer",display:"flex",alignItems:"center",gap:"6px","&:hover":{backgroundColor:"rgba(0, 0, 0, 0.03)"}}),sS=kt.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}})),_B=kt.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px",borderBottom:`1px solid ${e.appBorderColor}`})),NB=kt.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"10px",color:e.color.defaultText,fontSize:"14px",fontWeight:500})),OB=kt.div(({theme:e})=>({width:"32px",height:"32px",borderRadius:"50%",backgroundColor:W,display:"flex",alignItems:"center",justifyContent:"center",color:e.color.inverseText,fontSize:"14px",fontWeight:600})),$B=kt.div({display:"flex",gap:"8px"}),lS=kt(br)({fontSize:"18px"}),HB=kt.div({padding:"20px 16px"}),UB=kt.div(({theme:e})=>({padding:"16px",borderRadius:"8px",background:"linear-gradient(135deg, #10B981 0%, #3B82F6 100%)",marginBottom:"16px",color:"#fff"})),jB=kt.div({fontSize:"12px",fontWeight:500,opacity:.9,marginBottom:"4px"}),VB=kt.div({fontSize:"28px",fontWeight:700}),WB=kt.div({fontSize:"11px",opacity:.8,marginTop:"4px"}),GB=kt.div(({theme:e})=>({padding:"16px",borderRadius:"8px",border:`1px solid ${e.appBorderColor}`,marginBottom:"16px"})),qB=kt.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),YB=kt.div({display:"flex",alignItems:"center",gap:"8px"}),KB=kt.span(({theme:e})=>({fontSize:"14px",fontWeight:600,color:e.color.defaultText})),XB=kt.span(({theme:e})=>({fontSize:"10px",fontWeight:600,padding:"2px 6px",borderRadius:"4px",backgroundColor:W,color:e.color.inverseText})),JB=kt.button(({theme:e})=>({background:"none",border:"none",color:W,fontSize:"12px",cursor:"pointer","&:hover":{textDecoration:"underline"}})),QB=kt.div(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),ZB=kt.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"?W:e.background.hoverable,color:t==="primary"?e.color.inverseText:e.color.defaultText,"&:hover":{opacity:.9}})),ez=30*1e3,cS=({onClose:e})=>{let{sessionToken:t,resetAuth:n,usageData:r,usageLastFetched:o,setUsageData:i}=ye(),{featureFlags:a}=ge(),s=a.showCosts,u=r,l=!r&&t,c=async(f=!1)=>{if(!t)return;let y=o&&Date.now()-o<ez;if(!(!f&&y&&r))try{let I=K(),S=await Z(`${I}/api/addon/account`,{headers:{Authorization:`Bearer ${t}`}});if(S.ok){let x=await S.json();i(x)}}catch(I){w.error("Failed to fetch usage:",I)}};oS(()=>{c()},[t]),oS(()=>{let f=()=>{document.visibilityState==="visible"&&(w.debug("[TokenUsageModal] Tab visible, refreshing balance..."),c(!0))};return document.addEventListener("visibilitychange",f),()=>document.removeEventListener("visibilitychange",f)},[t]);let p=async()=>{if(t){let f=K();try{await fetch(`${f}/api/addon/auth/sign-out`,{method:"POST",headers:{Authorization:`Bearer ${t}`}})}catch{}}n(),e()},g=()=>{let f=K();window.open(`${f}/pricing`,"_blank")},d=()=>{let f=K();window.open(`${f}/pricing#add-credits`,"_blank")};if(t&&!s&&!l){let f=Math.floor(u?.creditBalance??0),I=Math.max(f,10),S=Math.max(0,I-f),x=I>0?f/I*100:0;return Le.createElement(Le.Fragment,null,Le.createElement(iS,{onClick:e}),Le.createElement(aS,{onClick:M=>M.stopPropagation(),style:{width:"320px"}},Le.createElement(CB,null,Le.createElement(IB,null,(u?.name||u?.email||"U")[0].toUpperCase()),Le.createElement(TB,null,Le.createElement(EB,null,u?.name||u?.email||"Your account"),Le.createElement(RB,null,(u?.plan||"FREE").toUpperCase())),Le.createElement("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"2px"}},Le.createElement(sS,{onClick:p,title:"Sign out",style:{position:"static"}},Le.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},Le.createElement("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),Le.createElement("polyline",{points:"16 17 21 12 16 7"}),Le.createElement("line",{x1:"21",y1:"12",x2:"9",y2:"12"}))),Le.createElement(sS,{onClick:e,title:"Close",style:{position:"static"}},"\xD7"))),Le.createElement(AB,null,Le.createElement(FB,null,"Credits"),Le.createElement(PB,null,f," left")),Le.createElement(MB,null,Le.createElement(LB,{percent:x})),Le.createElement(BB,null,S," used \xB7 ",f," remaining"),Le.createElement(zB,null),Le.createElement(DB,{onClick:()=>window.open("mailto:hello@uiparity.com?subject=Credits request","_blank")},"Contact us for credits \u2192")))}return Le.createElement(Le.Fragment,null,Le.createElement(iS,{onClick:e}),Le.createElement(aS,{onClick:f=>f.stopPropagation()},Le.createElement(_B,null,Le.createElement(NB,null,Le.createElement(OB,null,u?.email?u.email[0].toUpperCase():"U"),Le.createElement("span",null,u?.email||"Loading...")),Le.createElement($B,null,Le.createElement(lS,{onClick:p,title:"Sign out"},Le.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},Le.createElement("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),Le.createElement("polyline",{points:"16 17 21 12 16 7"}),Le.createElement("line",{x1:"21",y1:"12",x2:"9",y2:"12"}))),Le.createElement(lS,{onClick:e,title:"Close"},"\xD7"))),Le.createElement(HB,null,l?Le.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Loading..."):t?Le.createElement(Le.Fragment,null,Le.createElement(UB,null,Le.createElement(jB,null,"Credit Balance"),Le.createElement(VB,null,"$",(u?.creditBalance??0).toFixed(2)),Le.createElement(WB,null,(u?.creditBalance??0)<2?"Low balance - consider topping up":"Pay only for what you use")),Le.createElement(GB,null,Le.createElement(qB,null,Le.createElement(YB,null,Le.createElement(KB,null,"Current Plan"),Le.createElement(XB,null,u?.plan||"Free")),Le.createElement(JB,{onClick:g},"View detail >")),Le.createElement(QB,null,"~$0.02-0.05 per review depending on complexity"),Le.createElement(ZB,{onClick:d,style:{marginTop:"16px"}},"Add Credits"))):Le.createElement("div",{style:{textAlign:"center",padding:"20px"}},"Please sign in to view usage"))))};on();ke();import Ea from"react";import{styled as uS}from"storybook/theming";De();ke();ct();He();var tz=uS.div({display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"}),nz=uS.span(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark})),dS=()=>{let{userRole:e,roleOverride:t,setRoleOverride:n,setFeatureFlags:r}=ge(),{sessionToken:o}=ye();return e!=="admin"?null:Ea.createElement(tz,null,Ea.createElement(nz,null,"View as:"),Ea.createElement(ry,{value:t??e,onChange:s=>{let u=s.target.value;if(u===e)n(null),o&&Z(`${K()}/api/addon/flags`,{headers:{Authorization:`Bearer ${o}`}}).then(l=>l.json()).then(l=>{let c={enableFixGeneration:!!l.enableFixGeneration,enableFixApply:!!l.enableFixApply,enableAutoMap:!!l.enableAutoMap,enableAutoFigmaLinking:!!l.enableAutoFigmaLinking,enableReviewBadges:!!l.enableReviewBadges,showCosts:!!l.showCosts,enableParallelReview:!!l.enableParallelReview,enableModelSelection:!!l.enableModelSelection};r(c);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(c))}catch{}}).catch(l=>w.warn("[RoleSwitcher] Failed to re-fetch flags:",l.message));else{n(u);let l=Ws[u];r(l);try{localStorage.setItem("uicopilot_feature_flags",JSON.stringify(l))}catch{}}},style:{width:"auto",minWidth:"100px"}},Ea.createElement("option",{value:"admin"},"Admin"),Ea.createElement("option",{value:"beta"},"Regular user")),t&&Ea.createElement(ay,{variant:"warning"},"Previewing as"," ",t==="beta"?"regular user":t))};De();ke();ct();import Bt,{useState as qs,useCallback as jm}from"react";import{styled as eo}from"storybook/theming";var rz="0.5.7",oz=[{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"}],iz=eo.div({position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center"}),az=eo.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)"})),sz=eo.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px 12px",borderBottom:`1px solid ${e.appBorderColor}`})),lz=eo.h3(({theme:e})=>({margin:0,fontSize:"15px",fontWeight:600,color:e.color.defaultText,display:"flex",alignItems:"center",gap:"8px"})),cz=eo.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}})),uz=eo.div({padding:"16px 20px",display:"flex",flexDirection:"column",gap:"14px"}),dz=eo.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:W}})),pS=eo.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 20px 16px",borderTop:`1px solid ${e.appBorderColor}`,gap:"8px"})),gS=eo.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s1,color:e.color.mediumdark,lineHeight:1.4})),pz=eo.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s1,color:e.color.negative})),gz=eo.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 fS({isOpen:e,onClose:t}){let{sessionToken:n,isConnected:r}=ye(),{selectedProjectId:o}=Ke(),{currentStoryId:i}=pt(),[a,s]=qs("other"),[u,l]=qs(""),[c,p]=qs(!1),[g,d]=qs(!1),[f,y]=qs(null),I=jm(()=>{l(""),s("other"),d(!1),y(null),p(!1)},[]),S=jm(()=>{I(),t()},[I,t]),x=jm(async M=>{if(M.preventDefault(),!u.trim()){y("Please write a message.");return}if(!r||!n){y("Sign in to send feedback.");return}p(!0),y(null);try{let z=await Z(`${K()}/api/feedback`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({message:u.trim(),severity:a,projectId:o||void 0,storyId:i||void 0,addonVersion:rz})});if(!z.ok){let O=await z.json().catch(()=>({}));throw new Error(O.error||`Request failed (${z.status})`)}d(!0)}catch(z){y(z instanceof Error?z.message:"Something went wrong")}finally{p(!1)}},[u,a,n,r,o,i]);return e?Bt.createElement(iz,{onClick:S},Bt.createElement(az,{onClick:M=>M.stopPropagation()},Bt.createElement(sz,null,Bt.createElement(lz,null,Bt.createElement("span",null,"\u{1F4AC}"),"Send feedback"),Bt.createElement(cz,{onClick:S,"aria-label":"Close"},"\xD7")),g?Bt.createElement(Bt.Fragment,null,Bt.createElement(gz,null,Bt.createElement("h4",null,"Thanks \u2014 got it."),Bt.createElement("p",null,"We read every message. If it's a bug, we'll likely follow up by email.")),Bt.createElement(pS,null,Bt.createElement("span",null),Bt.createElement(Po,{onClick:S},"Close"))):Bt.createElement("form",{onSubmit:x},Bt.createElement(uz,null,Bt.createElement(rc,null,Bt.createElement(oc,{htmlFor:"feedback-severity"},"Type"),Bt.createElement(ir,{id:"feedback-severity",value:a,onChange:M=>s(M.target.value),disabled:c},oz.map(M=>Bt.createElement("option",{key:M.value,value:M.value},M.label)))),Bt.createElement(rc,null,Bt.createElement(oc,{htmlFor:"feedback-message"},"What happened?"),Bt.createElement(dz,{id:"feedback-message",value:u,onChange:M=>l(M.target.value),placeholder:"Tell us what you were doing, what you expected, and what happened.",disabled:c,autoFocus:!0,maxLength:5e3})),Bt.createElement(gS,null,"We auto-attach your current story and project so we can reproduce it. No screenshots sent."),f&&Bt.createElement(pz,null,f)),Bt.createElement(pS,null,Bt.createElement(gS,null,i?`Context: ${i}`:"No story selected"),Bt.createElement("div",{style:{display:"flex",gap:"8px"}},Bt.createElement(Po,{type:"button",onClick:S,disabled:c},"Cancel"),Bt.createElement(Qt,{type:"submit",disabled:c||!u.trim()},c?"Sending\u2026":"Send")))))):null}ke();De();ct();on();var mz=Sn.div({display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",gap:"8px"}),hz=Sn.div({display:"inline-flex",alignItems:"center",gap:"6px",flexShrink:0,userSelect:"none"}),xz=Sn.span(({theme:e})=>({width:"20px",height:"20px",display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:"5px",background:`linear-gradient(135deg, ${lp} 0%, ${W} 100%)`,color:e.color.lightest,fontSize:"11px",fontWeight:900,letterSpacing:"-0.5px",boxShadow:"0 1px 2px rgba(0,0,0,0.15)"})),yz=Sn.span(({theme:e})=>({fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,letterSpacing:"-0.2px",color:e.color.defaultText})),bz=Sn.span(({theme:e})=>({fontSize:"10px",fontFamily:e.typography.fonts.mono,color:e.color.mediumdark,opacity:.8,marginLeft:"2px"})),wz=Sn.div({display:"flex",alignItems:"center",gap:"6px",flexShrink:0}),vz=Sn.span(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"999px",fontSize:"10px",fontWeight:e.typography.weight.bold,lineHeight:1.6,color:e.color.mediumdark,backgroundColor:e.background.hoverable,border:`1px solid ${e.appBorderColor}`,userSelect:"none",cursor:"default","& svg":{width:"11px",height:"11px"}})),Sz=Sn.div({position:"relative"}),kz=Sn.button(({theme:e})=>({width:"22px",height:"22px",padding:0,background:e.background.app,border:`1px solid ${e.appBorderColor}`,borderRadius:"50%",color:e.color.defaultText,cursor:"pointer",fontSize:"10px",fontWeight:600,display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s","&:hover":{backgroundColor:e.background.hoverable}})),Cz=Sn.div(({theme:e})=>({position:"absolute",top:"calc(100% + 6px)",right:0,minWidth:"220px",backgroundColor:e.background.content,border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius,boxShadow:"0 8px 24px rgba(0,0,0,0.14)",zIndex:1e3,overflow:"hidden",padding:"4px"})),Iz=Sn.div(({theme:e})=>({padding:"8px 10px 10px",borderBottom:`1px solid ${e.appBorderColor}`,marginBottom:"4px"})),Tz=Sn.div(({theme:e})=>({fontSize:e.typography.size.s2,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),Ez=Sn.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:"2px"})),Gm=Sn.button(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",width:"100%",padding:"7px 10px",border:"none",borderRadius:e.appBorderRadius,background:"transparent",color:e.color.defaultText,fontSize:e.typography.size.s2,textAlign:"left",cursor:"pointer",transition:"background 0.12s","&:hover":{backgroundColor:e.background.hoverable}})),Rz=Sn.div(({theme:e})=>({height:"1px",margin:"4px 0",backgroundColor:e.appBorderColor})),mS=Sn.button(({theme:e,isLow:t})=>({display:"flex",alignItems:"center",gap:"6px",padding:"4px 8px",background:"transparent",border:"none",borderRadius:e.appBorderRadius,color:t?e.color.warning:Ye.green,cursor:"pointer",fontFamily:e.typography.fonts.mono,fontSize:"11px",fontWeight:e.typography.weight.bold,transition:"background 0.15s","&:hover":{backgroundColor:e.background.hoverable}})),hS=Sn.span(({theme:e,isLow:t})=>({width:"6px",height:"6px",borderRadius:"50%",flexShrink:0,backgroundColor:t?e.color.warning:Ye.green})),Az=Sn.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)"}}}),Fz=Sn.button(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",width:"28px",height:"28px",border:"none",borderRadius:e.appBorderRadius,backgroundColor:"transparent",color:e.color.mediumdark,cursor:"pointer",transition:"all 0.15s","& svg":{width:"14px",height:"14px"},"&:hover":{backgroundColor:e.background.hoverable,color:e.color.defaultText}})),Pz=Sn.button({position:"fixed",bottom:"20px",right:"20px",width:"48px",height:"48px",borderRadius:"50%",backgroundColor:W,color:"white",border:"none",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"22px",cursor:"pointer",boxShadow:`0 4px 14px ${W}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 ${W}88, 0 3px 6px rgba(0,0,0,0.15)`},"&:active":{transform:"scale(0.96)"}}),Mz=30*1e3,qm=({onOpenSettings:e})=>{let[t,n]=iu(!1),[r,o]=iu(!1),[i,a]=iu(!1),[s,u]=iu(!1),l=fz(null),{usageData:c,usageLastFetched:p,setUsageData:g,sessionToken:d,resetAuth:f}=ye(),{userRole:y,roleOverride:I,featureFlags:S}=ge(),x=I??y,M=!!d&&d.startsWith("uic_anon_"),z=x==="admin"||!!S.enableAiReview;Wm(()=>{(async()=>{if(!(!d||p&&Date.now()-p<Mz&&c)){u(!0);try{let R=K(),v=await Z(`${R}/api/addon/account`,{headers:{Authorization:`Bearer ${d}`}});if(v.ok){let A=await v.json();g(A)}}catch(R){console.error("Failed to fetch balance:",R)}finally{u(!1)}}})()},[d,p,c,g]),Wm(()=>{let h=()=>{document.visibilityState==="visible"&&t&&n(!1)},b=()=>{t&&n(!1)};return document.addEventListener("visibilitychange",h),window.addEventListener("focus",b),()=>{document.removeEventListener("visibilitychange",h),window.removeEventListener("focus",b)}},[t]),Wm(()=>{if(!i)return;let h=R=>{l.current&&!l.current.contains(R.target)&&a(!1)},b=R=>{R.key==="Escape"&&a(!1)};return document.addEventListener("mousedown",h),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",h),document.removeEventListener("keydown",b)}},[i]);let O=Vm(()=>{n(!0)},[]),L=Vm(()=>{n(!1)},[]),_=Vm(async()=>{if(a(!1),d)try{await fetch(`${K()}/api/addon/auth/sign-out`,{method:"POST",headers:{Authorization:`Bearer ${d}`}})}catch{}f()},[d,f]),m=c?.creditBalance??0,k=m<2&&!s,C=c?.email,E=(()=>{if(!C)return"?";let h=C.split("@")[0],b=h.split(/[^a-zA-Z0-9]+/).filter(Boolean);return b.length>=2?(b[0][0]+b[1][0]).toUpperCase():h.slice(0,2).toUpperCase()})();return xt.createElement(mz,null,xt.createElement(hz,null,xt.createElement(xz,{"aria-hidden":!0},"\u21CB"),xt.createElement(yz,null,jt.NAME),xt.createElement(bz,null,"v","0.12.2")),xt.createElement(wz,null,M&&xt.createElement(vz,{title:"Guest session \u2014 sign up to save your work"},xt.createElement("span",{"aria-hidden":!0},xt.createElement(gs,null)),"Guest"),d&&y==="admin"&&x==="admin"&&xt.createElement(dS,null),d&&S.showCosts&&z&&xt.createElement(mS,{onClick:O,isLow:k,title:s?"Loading...":c?k?"Low balance - click to top up":"Credit balance - click for details":"Click to load balance"},s?xt.createElement(Az,null):c?xt.createElement(xt.Fragment,null,xt.createElement(hS,{isLow:k}),"$",m.toFixed(2)):"..."),d&&!S.showCosts&&c&&z&&xt.createElement(mS,{onClick:O,isLow:Math.floor(m)<=3,title:`${Math.floor(m)} review credits \u2014 click for details`},xt.createElement(hS,{isLow:Math.floor(m)<=3}),Math.floor(m)),e&&d&&xt.createElement(Fz,{onClick:e,title:"Settings","aria-label":"Settings"},xt.createElement(fp,null)),!M&&xt.createElement(Sz,{ref:l},xt.createElement(kz,{title:"Account","aria-label":"Account",onClick:()=>a(h=>!h)},E),i&&xt.createElement(Cz,{role:"menu"},xt.createElement(Iz,null,xt.createElement(Tz,null,C||"Account"),c?.plan&&xt.createElement(Ez,null,c.plan," plan")),xt.createElement(Gm,{role:"menuitem",onClick:()=>{a(!1),O()}},xt.createElement("span",{"aria-hidden":!0},xt.createElement(gs,null))," ","Account & usage"),e&&xt.createElement(Gm,{role:"menuitem",onClick:()=>{a(!1),e()}},xt.createElement("span",{"aria-hidden":!0},xt.createElement(fp,null))," ","Settings"),xt.createElement(Rz,null),xt.createElement(Gm,{role:"menuitem",onClick:_},"Sign out")),t&&xt.createElement(cS,{onClose:L}))),d&&xt.createElement(Pz,{onClick:()=>o(!0),title:"Send feedback","aria-label":"Send feedback"},"\u{1F4AC}"),xt.createElement(fS,{isOpen:r,onClose:()=>o(!1)}))};import _e,{useEffect as OU,useRef as cd,useState as $U}from"react";import Xn from"react";ke();He();De();ct();on();import{useState as bS,useCallback as to,useRef as wS,useEffect as Ym}from"react";De();ct();var Lz=K(),Ra=null;function xS(e){Ra=e}async function yS(e){if(!Ra||!e||e===Ra||e.startsWith("uic_anon_"))return null;let t=Ra;Ra=null;try{let n=await Z(`${Lz}/api/anonymous/claim`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify({anonymousToken:t})});if(!n.ok)throw new Error(`claim failed: ${n.status}`);let r=await n.json().catch(()=>({}));return typeof r?.claimedProjects=="number"?r.claimedProjects:0}catch(n){throw Ra=t,n}}var _r=K();w.debug("[useAuth] Module loaded, APP_URL:",_r);var au=null,su=null,Ys=null;function Ks(){au&&(clearInterval(au),au=null),su&&(clearTimeout(su),su=null)}var no=()=>{let e=wS(null),t=wS(null),n=to(()=>{t.current&&(clearTimeout(t.current),t.current=null)},[]),{sessionToken:r,apiKey:o,authMethod:i,deviceCode:a,userCode:s,verificationUri:u,isConnected:l,authError:c,setSessionToken:p,setApiKey:g,setAuthMethod:d,setDeviceCode:f,setUserCode:y,setVerificationUri:I,setPollingInterval:S,setAuthError:x,resetAuth:M}=ye(),[z,O]=bS(!1),[L,_]=bS(!1),m=to(()=>{Ks(),Ys=null},[]),k=to(P=>{Ys=P,Ks();let N=async()=>{let T=Ys;if(!T){Ks();return}try{let H=await(await fetch(`${_r}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:T})})).json();H.status==="authorized"&&H.session_token?(w.debug("[useAuth] \u2705 OAuth poll successful! Got token."),Ks(),n(),Ys=null,localStorage.setItem("uicopilot_session_token",H.session_token),p(H.session_token),O(!1)):H.status==="expired"&&(w.debug("[useAuth] OAuth poll_code expired"),Ks(),n(),Ys=null,O(!1))}catch(D){w.error("[useAuth] OAuth poll error:",D)}};au=setInterval(N,2e3),su=setTimeout(N,1e3)},[p,n]);Ym(()=>{function P(N){if(!N.origin.startsWith(_r))return;let T=N.data;if(!T||typeof T!="object")return;let D=T;if(D.type==="UICOPILOT_AUTH_ERROR"){w.debug("[useAuth] Popup reported auth error:",D.step,D.detail),m(),O(!1);let H=typeof D.step=="string"?D.step:"auth",F=typeof D.detail=="string"?D.detail:"Unknown error";x(`${jt.NAME} auth failed (${H}): ${F}`)}else D.type==="UICOPILOT_AUTH_POLL_CODE"&&typeof D.pollCode=="string"&&D.pollCode&&(w.debug("[useAuth] Popup handed us a fresh poll_code, switching"),x(null),k(D.pollCode))}return window.addEventListener("message",P),()=>window.removeEventListener("message",P)},[k,m,x]);let C=to(async()=>{let T=Math.max(0,Math.round((window.screen.width-480)/2)),D=Math.max(0,Math.round((window.screen.height-640)/2)),H=`width=480,height=640,left=${T},top=${D},resizable=yes,scrollbars=yes`,F=null;try{F=window.open("about:blank","uiparity-signin",H)}catch{}try{w.debug("[useAuth] Starting OAuth flow, requesting poll_code...");let re;try{re=await Z(`${_r}/api/addon/auth/oauth-poll`,{method:"POST"})}catch(ne){let be=ne instanceof Error&&ne.message.includes("timed out")?`Cannot reach ${jt.NAME} server at ${_r}. Is the dashboard running?`:`Connection failed: ${_r} is not responding.`;x(be),w.error("[useAuth]",be),F?.close();return}if(!re.ok){let ne=`Cannot reach ${jt.NAME} server. Is the dashboard running?`;x(ne),w.error("[useAuth]",ne),F?.close();return}let{poll_code:j}=await re.json();w.debug("[useAuth] Got poll_code:",j.substring(0,15)+"...");let Y=localStorage.getItem("uicopilot_force_sign_in")==="true";Y&&localStorage.removeItem("uicopilot_force_sign_in");let J=`${_r}/addon/auth?poll_code=${j}${Y?"&force_sign_in=true":""}`;O(!0),F&&!F.closed?F.location.href=J:window.open(J,"uiparity-signin",H),n(),t.current=setTimeout(()=>{O(!1),m()},9e4),w.debug("[useAuth] Starting OAuth poll for token..."),k(j)}catch(re){w.error("[useAuth] OAuth flow error:",re),x(`Connection failed. Is the dashboard running at ${_r}?`),O(!1),F?.close()}},[x,k,n,m]),E=to(async()=>{try{let P=await fetch(`${_r}/api/addon/auth/device`,{method:"POST"});if(!P.ok)throw new Error("Failed to start device code flow");let N=await P.json();f(N.device_code),y(N.user_code),I(N.verification_uri),window.open(N.verification_uri,"_blank"),h(N.device_code,N.interval*1e3)}catch(P){throw w.error("[useAuth] Device code flow error:",P),P}},[f,y,I]),h=to((P,N)=>{w.debug("[useAuth] Starting polling. Device code:",P,"Interval:",N),e.current&&clearInterval(e.current);let T=async()=>{try{let H=await(await fetch(`${_r}/api/addon/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:P})})).json();H.status==="authorized"?(w.debug("[useAuth] Device code authorization successful!"),e.current&&(clearInterval(e.current),e.current=null),f(null),y(null),I(null),localStorage.setItem("uicopilot_session_token",H.session_token),p(H.session_token),O(!1)):(H.status==="expired"||H.status==="denied")&&(w.debug("[useAuth] Device code expired or denied"),e.current&&(clearInterval(e.current),e.current=null),f(null),y(null),I(null))}catch(D){w.error("[useAuth] Polling error:",D)}};e.current=setInterval(T,N),S(N)},[f,y,I,p,S]),b=to(()=>{e.current&&(clearInterval(e.current),e.current=null),f(null),y(null),I(null),S(null)},[f,y,I,S]),R=to(P=>{g(P),p(P),localStorage.setItem("uicopilot_api_key",P)},[g,p]),v=to(async()=>{if(r)try{await Z(`${_r}/api/addon/auth/sign-out`,{method:"POST",headers:{Authorization:`Bearer ${r}`}})}catch{}M(),O(!1),e.current&&(clearInterval(e.current),e.current=null),m()},[r,M,m]),A=to(async()=>{_(!0),x(null);try{let P=await Z(`${_r}/api/anonymous/session`,{method:"POST"});if(!P.ok)throw new Error(`anonymous session ${P.status}`);let N=await P.json();if(!N?.token)throw new Error("anonymous session: no token");p(N.token)}catch{x("Couldn't start a guest session. Please try again.")}finally{_(!1)}},[p,x]),B=to(()=>{r&&r.startsWith("uic_anon_")&&(xS(r),typeof localStorage<"u"&&localStorage.removeItem("uicopilot_force_sign_in")),C()},[r,C]);return Ym(()=>{!r||r.startsWith("uic_anon_")||yS(r).then(P=>{P!==null&&w.info(`[useAuth] Guest work claimed (${P} project${P===1?"":"s"}).`)}).catch(P=>{w.error("[useAuth] Guest claim failed:",P)})},[r]),Ym(()=>()=>{e.current&&clearInterval(e.current),n()},[n]),{sessionToken:r,apiKey:o,authMethod:i,deviceCode:a,userCode:s,verificationUri:u,isConnected:l,authError:c,oauthPending:z,anonPending:L,isAnonymous:!!r&&r.startsWith("uic_anon_"),setAuthMethod:d,startOAuth:C,startAnonymous:A,signUpToSave:B,startDeviceCode:E,cancelDeviceCode:b,saveApiKey:R,logout:v}};ke();He();De();ct();import{useCallback as lu}from"react";var Xs=K(),Ir=()=>{let{projects:e,selectedProjectId:t,loadingProjects:n,setProjects:r,setSelectedProjectId:o,setLoadingProjects:i,getSelectedProject:a}=Ke(),{sessionToken:s}=ye(),u=lu(async()=>{if(!s){w.debug("[useProjects] No session token, skipping fetch");return}try{i(!0),w.debug("[useProjects] Fetching from:",`${Xs}/api/projects`);let g=await Z(`${Xs}/api/projects`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`}});if(g.ok){let d=await g.json();w.debug("[useProjects] Projects:",d.projects),r(d.projects||[])}else w.error("[useProjects] Failed to fetch projects:",g.status,g.statusText)}catch(g){w.error("[useProjects] Error fetching projects:",g)}finally{i(!1)}},[s,r,i]),l=lu(async g=>{if(!s)throw new Error("Not authenticated");let d=await Z(`${Xs}/api/projects`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},body:JSON.stringify(g)});if(!d.ok)throw new Error("Failed to create project");let f=await d.json();return await u(),f.project},[s,u]),c=lu(async(g,d)=>{if(!s)throw new Error("Not authenticated");let f={};if(d.name!==void 0&&(f.name=d.name),d.description!==void 0&&(f.description=d.description),d.figmaFileUrl!==void 0&&(f.figmaFileId=d.figmaFileUrl===""?null:d.figmaFileUrl),!(await Z(`${Xs}/api/projects/${g}`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},body:JSON.stringify(f)})).ok)throw new Error("Failed to update project");await u()},[s,u]),p=lu(async g=>{if(!s)throw new Error("Not authenticated");if(!(await Z(`${Xs}/api/projects/${g}`,{method:"DELETE",headers:{Authorization:`Bearer ${s}`}})).ok)throw new Error("Failed to delete project");await u(),t===g&&o(null)},[s,t,u,o]);return{projects:e,selectedProjectId:t,selectedProject:a(),loadingProjects:n,setSelectedProjectId:o,fetchProjects:u,createProject:l,updateProject:c,deleteProject:p}};ke();var Js=()=>{let{showComponentBrowser:e,figmaFileUrl:t,currentMapping:n,mappingSource:r,loadingMapping:o,showFigmaQuality:i,setShowComponentBrowser:a,setFigmaFileUrl:s,setCurrentMapping:u,setMappingSource:l,setLoadingMapping:c,setShowFigmaQuality:p}=pt();return{showComponentBrowser:e,figmaFileUrl:t,currentMapping:n,mappingSource:r,loadingMapping:o,showFigmaQuality:i,setShowComponentBrowser:a,setFigmaFileUrl:s,setCurrentMapping:u,setMappingSource:l,setLoadingMapping:c,setShowFigmaQuality:p,openComponentBrowser:()=>a(!0),closeComponentBrowser:()=>a(!1)}};ke();Zm();fu();import{useCallback as cl,useRef as ku}from"react";He();function mu(){return new Promise(e=>{let t=document.getElementById("storybook-preview-iframe");if(!t||!t.contentWindow){w.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();w.debug("[iframeReload] Triggering cache-busted reload:",o);let i=setTimeout(()=>{w.warn("[iframeReload] Iframe reload timed out after 5s"),t.removeEventListener("load",a),e()},5e3),a=()=>{clearTimeout(i),t.removeEventListener("load",a),w.debug("[iframeReload] Iframe loaded, waiting for HMR and styles to settle..."),setTimeout(()=>{w.debug("[iframeReload] Iframe reloaded and styles should be fresh"),e()},2e3)};t.addEventListener("load",a),t.contentWindow.location.href=o})}function hu(e){return e&&e!=="admin"?{"X-UIC-Role-Preview":e}:{}}var xu=BigInt(4294967295),_S=BigInt(32);function tD(e,t=!1){return t?{h:Number(e&xu),l:Number(e>>_S&xu)}:{h:Number(e>>_S&xu)|0,l:Number(e&xu)|0}}function NS(e,t=!1){let n=e.length,r=new Uint32Array(n),o=new Uint32Array(n);for(let i=0;i<n;i++){let{h:a,l:s}=tD(e[i],t);[r[i],o[i]]=[a,s]}return[r,o]}var OS=(e,t,n)=>e<<n|t>>>32-n,$S=(e,t,n)=>t<<n|e>>>32-n,HS=(e,t,n)=>t<<n-32|e>>>64-n,US=(e,t,n)=>e<<n-32|t>>>64-n;function nD(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function ih(e,t=""){if(!Number.isSafeInteger(e)||e<0){let n=t&&`"${t}" `;throw new Error(`${n}expected integer >= 0, got ${e}`)}}function yu(e,t,n=""){let r=nD(e),o=e?.length,i=t!==void 0;if(!r||i&&o!==t){let a=n&&`"${n}" `,s=i?` of length ${t}`:"",u=r?`length=${o}`:`type=${typeof e}`;throw new Error(a+"expected Uint8Array"+s+", got "+u)}return e}function ah(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 jS(e,t){yu(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 VS(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function sh(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}var rD=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function oD(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function iD(e){for(let t=0;t<e.length;t++)e[t]=oD(e[t]);return e}var lh=rD?e=>e:iD;function WS(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 GS=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var aD=BigInt(0),nl=BigInt(1),sD=BigInt(2),lD=BigInt(7),cD=BigInt(256),uD=BigInt(113),KS=[],XS=[],JS=[];for(let e=0,t=nl,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],KS.push(2*(5*r+n)),XS.push((e+1)*(e+2)/2%64);let o=aD;for(let i=0;i<7;i++)t=(t<<nl^(t>>lD)*uD)%cD,t&sD&&(o^=nl<<(nl<<BigInt(i))-nl);JS.push(o)}var QS=NS(JS,!0),dD=QS[0],pD=QS[1],qS=(e,t,n)=>n>32?HS(e,t,n):OS(e,t,n),YS=(e,t,n)=>n>32?US(e,t,n):$S(e,t,n);function gD(e,t=24){let n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let a=0;a<10;a++)n[a]=e[a]^e[a+10]^e[a+20]^e[a+30]^e[a+40];for(let a=0;a<10;a+=2){let s=(a+8)%10,u=(a+2)%10,l=n[u],c=n[u+1],p=qS(l,c,1)^n[s],g=YS(l,c,1)^n[s+1];for(let d=0;d<50;d+=10)e[a+d]^=p,e[a+d+1]^=g}let o=e[2],i=e[3];for(let a=0;a<24;a++){let s=XS[a],u=qS(o,i,s),l=YS(o,i,s),c=KS[a];o=e[c],i=e[c+1],e[c]=u,e[c+1]=l}for(let a=0;a<50;a+=10){for(let s=0;s<10;s++)n[s]=e[a+s];for(let s=0;s<10;s++)e[a+s]^=~n[(s+2)%10]&n[(s+4)%10]}e[0]^=dD[r],e[1]^=pD[r]}sh(n)}var ch=class e{constructor(t,n,r,o=!1,i=24){Pr(this,"state");Pr(this,"pos",0);Pr(this,"posOut",0);Pr(this,"finished",!1);Pr(this,"state32");Pr(this,"destroyed",!1);Pr(this,"blockLen");Pr(this,"suffix");Pr(this,"outputLen");Pr(this,"enableXOF",!1);Pr(this,"rounds");if(this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=i,ih(r,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=VS(this.state)}clone(){return this._cloneInto()}keccak(){lh(this.state32),gD(this.state32,this.rounds),lh(this.state32),this.posOut=0,this.pos=0}update(t){ah(this),yu(t);let{blockLen:n,state:r}=this,o=t.length;for(let i=0;i<o;){let a=Math.min(n-this.pos,o-i);for(let s=0;s<a;s++)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){ah(this,!1),yu(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 a=Math.min(r-this.posOut,i-o);t.set(n.subarray(this.posOut,this.posOut+a),o),this.posOut+=a,o+=a}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return ih(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(jS(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,sh(this.state)}_cloneInto(t){let{blockLen:n,suffix:r,outputLen:o,rounds:i,enableXOF:a}=this;return t||(t=new e(n,r,o,a,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=a,t.destroyed=this.destroyed,t}},fD=(e,t,n,r={})=>WS(()=>new ch(t,e,n),r);var ZS=fD(6,72,64,GS(10));var mD=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,uh=Math.ceil,Or=Math.floor,pr="[BigNumber Error] ",e4=pr+"Number primitive has more than 15 significant digits: ",ro=1e14,nt=14,dh=9007199254740991,ph=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],ci=1e7,Ln=1e9;function t4(e){var t,n,r,o=x.prototype={constructor:x,toString:null,valueOf:null},i=new x(1),a=20,s=4,u=-7,l=21,c=-1e7,p=1e7,g=!1,d=1,f=0,y={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},I="0123456789abcdefghijklmnopqrstuvwxyz",S=!0;function x(m,k){var C,E,h,b,R,v,A,B,P=this;if(!(P instanceof x))return new x(m,k);if(k==null){if(m&&m._isBigNumber===!0){P.s=m.s,!m.c||m.e>p?P.c=P.e=null:m.e<c?P.c=[P.e=0]:(P.e=m.e,P.c=m.c.slice());return}if((v=typeof m=="number")&&m*0==0){if(P.s=1/m<0?(m=-m,-1):1,m===~~m){for(b=0,R=m;R>=10;R/=10,b++);b>p?P.c=P.e=null:(P.e=b,P.c=[m]);return}B=String(m)}else{if(!mD.test(B=String(m)))return r(P,B,v);P.s=B.charCodeAt(0)==45?(B=B.slice(1),-1):1}(b=B.indexOf("."))>-1&&(B=B.replace(".","")),(R=B.search(/e/i))>0?(b<0&&(b=R),b+=+B.slice(R+1),B=B.substring(0,R)):b<0&&(b=B.length)}else{if(an(k,2,I.length,"Base"),k==10&&S)return P=new x(m),L(P,a+P.e+1,s);if(B=String(m),v=typeof m=="number"){if(m*0!=0)return r(P,B,v,k);if(P.s=1/m<0?(B=B.slice(1),-1):1,x.DEBUG&&B.replace(/^0\.0*|\./,"").length>15)throw Error(e4+m)}else P.s=B.charCodeAt(0)===45?(B=B.slice(1),-1):1;for(C=I.slice(0,k),b=R=0,A=B.length;R<A;R++)if(C.indexOf(E=B.charAt(R))<0){if(E=="."){if(R>b){b=A;continue}}else if(!h&&(B==B.toUpperCase()&&(B=B.toLowerCase())||B==B.toLowerCase()&&(B=B.toUpperCase()))){h=!0,R=-1,b=0;continue}return r(P,String(m),v,k)}v=!1,B=n(B,k,10,P.s),(b=B.indexOf("."))>-1?B=B.replace(".",""):b=B.length}for(R=0;B.charCodeAt(R)===48;R++);for(A=B.length;B.charCodeAt(--A)===48;);if(B=B.slice(R,++A)){if(A-=R,v&&x.DEBUG&&A>15&&(m>dh||m!==Or(m)))throw Error(e4+P.s*m);if((b=b-R-1)>p)P.c=P.e=null;else if(b<c)P.c=[P.e=0];else{if(P.e=b,P.c=[],R=(b+1)%nt,b<0&&(R+=nt),R<A){for(R&&P.c.push(+B.slice(0,R)),A-=nt;R<A;)P.c.push(+B.slice(R,R+=nt));R=nt-(B=B.slice(R)).length}else R-=A;for(;R--;B+="0");P.c.push(+B)}}else P.c=[P.e=0]}x.clone=t4,x.ROUND_UP=0,x.ROUND_DOWN=1,x.ROUND_CEIL=2,x.ROUND_FLOOR=3,x.ROUND_HALF_UP=4,x.ROUND_HALF_DOWN=5,x.ROUND_HALF_EVEN=6,x.ROUND_HALF_CEIL=7,x.ROUND_HALF_FLOOR=8,x.EUCLID=9,x.config=x.set=function(m){var k,C;if(m!=null)if(typeof m=="object"){if(m.hasOwnProperty(k="DECIMAL_PLACES")&&(C=m[k],an(C,0,Ln,k),a=C),m.hasOwnProperty(k="ROUNDING_MODE")&&(C=m[k],an(C,0,8,k),s=C),m.hasOwnProperty(k="EXPONENTIAL_AT")&&(C=m[k],C&&C.pop?(an(C[0],-Ln,0,k),an(C[1],0,Ln,k),u=C[0],l=C[1]):(an(C,-Ln,Ln,k),u=-(l=C<0?-C:C))),m.hasOwnProperty(k="RANGE"))if(C=m[k],C&&C.pop)an(C[0],-Ln,-1,k),an(C[1],1,Ln,k),c=C[0],p=C[1];else if(an(C,-Ln,Ln,k),C)c=-(p=C<0?-C:C);else throw Error(pr+k+" cannot be zero: "+C);if(m.hasOwnProperty(k="CRYPTO"))if(C=m[k],C===!!C)if(C)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))g=C;else throw g=!C,Error(pr+"crypto unavailable");else g=C;else throw Error(pr+k+" not true or false: "+C);if(m.hasOwnProperty(k="MODULO_MODE")&&(C=m[k],an(C,0,9,k),d=C),m.hasOwnProperty(k="POW_PRECISION")&&(C=m[k],an(C,0,Ln,k),f=C),m.hasOwnProperty(k="FORMAT"))if(C=m[k],typeof C=="object")y=C;else throw Error(pr+k+" not an object: "+C);if(m.hasOwnProperty(k="ALPHABET"))if(C=m[k],typeof C=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(C))S=C.slice(0,10)=="0123456789",I=C;else throw Error(pr+k+" invalid: "+C)}else throw Error(pr+"Object expected: "+m);return{DECIMAL_PLACES:a,ROUNDING_MODE:s,EXPONENTIAL_AT:[u,l],RANGE:[c,p],CRYPTO:g,MODULO_MODE:d,POW_PRECISION:f,FORMAT:y,ALPHABET:I}},x.isBigNumber=function(m){if(!m||m._isBigNumber!==!0)return!1;if(!x.DEBUG)return!0;var k,C,E=m.c,h=m.e,b=m.s;e:if({}.toString.call(E)=="[object Array]"){if((b===1||b===-1)&&h>=-Ln&&h<=Ln&&h===Or(h)){if(E[0]===0){if(h===0&&E.length===1)return!0;break e}if(k=(h+1)%nt,k<1&&(k+=nt),String(E[0]).length==k){for(k=0;k<E.length;k++)if(C=E[k],C<0||C>=ro||C!==Or(C))break e;if(C!==0)return!0}}}else if(E===null&&h===null&&(b===null||b===1||b===-1))return!0;throw Error(pr+"Invalid BigNumber: "+m)},x.maximum=x.max=function(){return z(arguments,-1)},x.minimum=x.min=function(){return z(arguments,1)},x.random=(function(){var m=9007199254740992,k=Math.random()*m&2097151?function(){return Or(Math.random()*m)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(C){var E,h,b,R,v,A=0,B=[],P=new x(i);if(C==null?C=a:an(C,0,Ln),R=uh(C/nt),g)if(crypto.getRandomValues){for(E=crypto.getRandomValues(new Uint32Array(R*=2));A<R;)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]):(B.push(v%1e14),A+=2);A=R/2}else if(crypto.randomBytes){for(E=crypto.randomBytes(R*=7);A<R;)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):(B.push(v%1e14),A+=7);A=R/7}else throw g=!1,Error(pr+"crypto unavailable");if(!g)for(;A<R;)v=k(),v<9e15&&(B[A++]=v%1e14);for(R=B[--A],C%=nt,R&&C&&(v=ph[nt-C],B[A]=Or(R/v)*v);B[A]===0;B.pop(),A--);if(A<0)B=[b=0];else{for(b=-1;B[0]===0;B.splice(0,1),b-=nt);for(A=1,v=B[0];v>=10;v/=10,A++);A<nt&&(b-=nt-A)}return P.e=b,P.c=B,P}})(),x.sum=function(){for(var m=1,k=arguments,C=new x(k[0]);m<k.length;)C=C.plus(k[m++]);return C},n=(function(){var m="0123456789";function k(C,E,h,b){for(var R,v=[0],A,B=0,P=C.length;B<P;){for(A=v.length;A--;v[A]*=E);for(v[0]+=b.indexOf(C.charAt(B++)),R=0;R<v.length;R++)v[R]>h-1&&(v[R+1]==null&&(v[R+1]=0),v[R+1]+=v[R]/h|0,v[R]%=h)}return v.reverse()}return function(C,E,h,b,R){var v,A,B,P,N,T,D,H,F=C.indexOf("."),re=a,j=s;for(F>=0&&(P=f,f=0,C=C.replace(".",""),H=new x(E),T=H.pow(C.length-F),f=P,H.c=k(Uo(Nr(T.c),T.e,"0"),10,h,m),H.e=H.c.length),D=k(C,E,h,R?(v=I,m):(v=m,I)),B=P=D.length;D[--P]==0;D.pop());if(!D[0])return v.charAt(0);if(F<0?--B:(T.c=D,T.e=B,T.s=b,T=t(T,H,re,j,h),D=T.c,N=T.r,B=T.e),A=B+re+1,F=D[A],P=h/2,N=N||A<0||D[A+1]!=null,N=j<4?(F!=null||N)&&(j==0||j==(T.s<0?3:2)):F>P||F==P&&(j==4||N||j==6&&D[A-1]&1||j==(T.s<0?8:7)),A<1||!D[0])C=N?Uo(v.charAt(1),-re,v.charAt(0)):v.charAt(0);else{if(D.length=A,N)for(--h;++D[--A]>h;)D[A]=0,A||(++B,D=[1].concat(D));for(P=D.length;!D[--P];);for(F=0,C="";F<=P;C+=v.charAt(D[F++]));C=Uo(C,B,v.charAt(0))}return C}})(),t=(function(){function m(E,h,b){var R,v,A,B,P=0,N=E.length,T=h%ci,D=h/ci|0;for(E=E.slice();N--;)A=E[N]%ci,B=E[N]/ci|0,R=D*A+B*T,v=T*A+R%ci*ci+P,P=(v/b|0)+(R/ci|0)+D*B,E[N]=v%b;return P&&(E=[P].concat(E)),E}function k(E,h,b,R){var v,A;if(b!=R)A=b>R?1:-1;else for(v=A=0;v<b;v++)if(E[v]!=h[v]){A=E[v]>h[v]?1:-1;break}return A}function C(E,h,b,R){for(var v=0;b--;)E[b]-=v,v=E[b]<h[b]?1:0,E[b]=v*R+E[b]-h[b];for(;!E[0]&&E.length>1;E.splice(0,1));}return function(E,h,b,R,v){var A,B,P,N,T,D,H,F,re,j,Y,J,ne,Re,be,fe,Me,me=E.s==h.s?1:-1,ze=E.c,he=h.c;if(!ze||!ze[0]||!he||!he[0])return new x(!E.s||!h.s||(ze?he&&ze[0]==he[0]:!he)?NaN:ze&&ze[0]==0||!he?me*0:me/0);for(F=new x(me),re=F.c=[],B=E.e-h.e,me=b+B+1,v||(v=ro,B=$r(E.e/nt)-$r(h.e/nt),me=me/nt|0),P=0;he[P]==(ze[P]||0);P++);if(he[P]>(ze[P]||0)&&B--,me<0)re.push(1),N=!0;else{for(Re=ze.length,fe=he.length,P=0,me+=2,T=Or(v/(he[0]+1)),T>1&&(he=m(he,T,v),ze=m(ze,T,v),fe=he.length,Re=ze.length),ne=fe,j=ze.slice(0,fe),Y=j.length;Y<fe;j[Y++]=0);Me=he.slice(),Me=[0].concat(Me),be=he[0],he[1]>=v/2&&be++;do{if(T=0,A=k(he,j,fe,Y),A<0){if(J=j[0],fe!=Y&&(J=J*v+(j[1]||0)),T=Or(J/be),T>1)for(T>=v&&(T=v-1),D=m(he,T,v),H=D.length,Y=j.length;k(D,j,H,Y)==1;)T--,C(D,fe<H?Me:he,H,v),H=D.length,A=1;else T==0&&(A=T=1),D=he.slice(),H=D.length;if(H<Y&&(D=[0].concat(D)),C(j,D,Y,v),Y=j.length,A==-1)for(;k(he,j,fe,Y)<1;)T++,C(j,fe<Y?Me:he,Y,v),Y=j.length}else A===0&&(T++,j=[0]);re[P++]=T,j[0]?j[Y++]=ze[ne]||0:(j=[ze[ne]],Y=1)}while((ne++<Re||j[0]!=null)&&me--);N=j[0]!=null,re[0]||re.splice(0,1)}if(v==ro){for(P=1,me=re[0];me>=10;me/=10,P++);L(F,b+(F.e=P+B*nt-1)+1,R,N)}else F.e=B,F.r=+N;return F}})();function M(m,k,C,E){var h,b,R,v,A;if(C==null?C=s:an(C,0,8),!m.c)return m.toString();if(h=m.c[0],R=m.e,k==null)A=Nr(m.c),A=E==1||E==2&&(R<=u||R>=l)?wu(A,R):Uo(A,R,"0");else if(m=L(new x(m),k,C),b=m.e,A=Nr(m.c),v=A.length,E==1||E==2&&(k<=b||b<=u)){for(;v<k;A+="0",v++);A=wu(A,b)}else if(k-=R+(E===2&&b>R),A=Uo(A,b,"0"),b+1>v){if(--k>0)for(A+=".";k--;A+="0");}else if(k+=b-v,k>0)for(b+1==v&&(A+=".");k--;A+="0");return m.s<0&&h?"-"+A:A}function z(m,k){for(var C,E,h=1,b=new x(m[0]);h<m.length;h++)E=new x(m[h]),(!E.s||(C=Hi(b,E))===k||C===0&&b.s===k)&&(b=E);return b}function O(m,k,C){for(var E=1,h=k.length;!k[--h];k.pop());for(h=k[0];h>=10;h/=10,E++);return(C=E+C*nt-1)>p?m.c=m.e=null:C<c?m.c=[m.e=0]:(m.e=C,m.c=k),m}r=(function(){var m=/^(-?)0([xbo])(?=\w[\w.]*$)/i,k=/^([^.]+)\.$/,C=/^\.([^.]+)$/,E=/^-?(Infinity|NaN)$/,h=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(b,R,v,A){var B,P=v?R:R.replace(h,"");if(E.test(P))b.s=isNaN(P)?null:P<0?-1:1;else{if(!v&&(P=P.replace(m,function(N,T,D){return B=(D=D.toLowerCase())=="x"?16:D=="b"?2:8,!A||A==B?T:N}),A&&(B=A,P=P.replace(k,"$1").replace(C,"0.$1")),R!=P))return new x(P,B);if(x.DEBUG)throw Error(pr+"Not a"+(A?" base "+A:"")+" number: "+R);b.s=null}b.c=b.e=null}})();function L(m,k,C,E){var h,b,R,v,A,B,P,N=m.c,T=ph;if(N){e:{for(h=1,v=N[0];v>=10;v/=10,h++);if(b=k-h,b<0)b+=nt,R=k,A=N[B=0],P=Or(A/T[h-R-1]%10);else if(B=uh((b+1)/nt),B>=N.length)if(E){for(;N.length<=B;N.push(0));A=P=0,h=1,b%=nt,R=b-nt+1}else break e;else{for(A=v=N[B],h=1;v>=10;v/=10,h++);b%=nt,R=b-nt+h,P=R<0?0:Or(A/T[h-R-1]%10)}if(E=E||k<0||N[B+1]!=null||(R<0?A:A%T[h-R-1]),E=C<4?(P||E)&&(C==0||C==(m.s<0?3:2)):P>5||P==5&&(C==4||E||C==6&&(b>0?R>0?A/T[h-R]:0:N[B-1])%10&1||C==(m.s<0?8:7)),k<1||!N[0])return N.length=0,E?(k-=m.e+1,N[0]=T[(nt-k%nt)%nt],m.e=-k||0):N[0]=m.e=0,m;if(b==0?(N.length=B,v=1,B--):(N.length=B+1,v=T[nt-b],N[B]=R>0?Or(A/T[h-R]%T[R])*v:0),E)for(;;)if(B==0){for(b=1,R=N[0];R>=10;R/=10,b++);for(R=N[0]+=v,v=1;R>=10;R/=10,v++);b!=v&&(m.e++,N[0]==ro&&(N[0]=1));break}else{if(N[B]+=v,N[B]!=ro)break;N[B--]=0,v=1}for(b=N.length;N[--b]===0;N.pop());}m.e>p?m.c=m.e=null:m.e<c&&(m.c=[m.e=0])}return m}function _(m){var k,C=m.e;return C===null?m.toString():(k=Nr(m.c),k=C<=u||C>=l?wu(k,C):Uo(k,C,"0"),m.s<0?"-"+k:k)}return o.absoluteValue=o.abs=function(){var m=new x(this);return m.s<0&&(m.s=1),m},o.comparedTo=function(m,k){return Hi(this,new x(m,k))},o.decimalPlaces=o.dp=function(m,k){var C,E,h,b=this;if(m!=null)return an(m,0,Ln),k==null?k=s:an(k,0,8),L(new x(b),m+b.e+1,k);if(!(C=b.c))return null;if(E=((h=C.length-1)-$r(this.e/nt))*nt,h=C[h])for(;h%10==0;h/=10,E--);return E<0&&(E=0),E},o.dividedBy=o.div=function(m,k){return t(this,new x(m,k),a,s)},o.dividedToIntegerBy=o.idiv=function(m,k){return t(this,new x(m,k),0,1)},o.exponentiatedBy=o.pow=function(m,k){var C,E,h,b,R,v,A,B,P,N=this;if(m=new x(m),m.c&&!m.isInteger())throw Error(pr+"Exponent not an integer: "+_(m));if(k!=null&&(k=new x(k)),v=m.e>14,!N.c||!N.c[0]||N.c[0]==1&&!N.e&&N.c.length==1||!m.c||!m.c[0])return P=new x(Math.pow(+_(N),v?m.s*(2-bu(m)):+_(m))),k?P.mod(k):P;if(A=m.s<0,k){if(k.c?!k.c[0]:!k.s)return new x(NaN);E=!A&&N.isInteger()&&k.isInteger(),E&&(N=N.mod(k))}else{if(m.e>9&&(N.e>0||N.e<-1||(N.e==0?N.c[0]>1||v&&N.c[1]>=24e7:N.c[0]<8e13||v&&N.c[0]<=9999975e7)))return b=N.s<0&&bu(m)?-0:0,N.e>-1&&(b=1/b),new x(A?1/b:b);f&&(b=uh(f/nt+2))}for(v?(C=new x(.5),A&&(m.s=1),B=bu(m)):(h=Math.abs(+_(m)),B=h%2),P=new x(i);;){if(B){if(P=P.times(N),!P.c)break;b?P.c.length>b&&(P.c.length=b):E&&(P=P.mod(k))}if(h){if(h=Or(h/2),h===0)break;B=h%2}else if(m=m.times(C),L(m,m.e+1,1),m.e>14)B=bu(m);else{if(h=+_(m),h===0)break;B=h%2}N=N.times(N),b?N.c&&N.c.length>b&&(N.c.length=b):E&&(N=N.mod(k))}return E?P:(A&&(P=i.div(P)),k?P.mod(k):b?L(P,f,s,R):P)},o.integerValue=function(m){var k=new x(this);return m==null?m=s:an(m,0,8),L(k,k.e+1,m)},o.isEqualTo=o.eq=function(m,k){return Hi(this,new x(m,k))===0},o.isFinite=function(){return!!this.c},o.isGreaterThan=o.gt=function(m,k){return Hi(this,new x(m,k))>0},o.isGreaterThanOrEqualTo=o.gte=function(m,k){return(k=Hi(this,new x(m,k)))===1||k===0},o.isInteger=function(){return!!this.c&&$r(this.e/nt)>this.c.length-2},o.isLessThan=o.lt=function(m,k){return Hi(this,new x(m,k))<0},o.isLessThanOrEqualTo=o.lte=function(m,k){return(k=Hi(this,new x(m,k)))===-1||k===0},o.isNaN=function(){return!this.s},o.isNegative=function(){return this.s<0},o.isPositive=function(){return this.s>0},o.isZero=function(){return!!this.c&&this.c[0]==0},o.minus=function(m,k){var C,E,h,b,R=this,v=R.s;if(m=new x(m,k),k=m.s,!v||!k)return new x(NaN);if(v!=k)return m.s=-k,R.plus(m);var A=R.e/nt,B=m.e/nt,P=R.c,N=m.c;if(!A||!B){if(!P||!N)return P?(m.s=-k,m):new x(N?R:NaN);if(!P[0]||!N[0])return N[0]?(m.s=-k,m):new x(P[0]?R:s==3?-0:0)}if(A=$r(A),B=$r(B),P=P.slice(),v=A-B){for((b=v<0)?(v=-v,h=P):(B=A,h=N),h.reverse(),k=v;k--;h.push(0));h.reverse()}else for(E=(b=(v=P.length)<(k=N.length))?v:k,v=k=0;k<E;k++)if(P[k]!=N[k]){b=P[k]<N[k];break}if(b&&(h=P,P=N,N=h,m.s=-m.s),k=(E=N.length)-(C=P.length),k>0)for(;k--;P[C++]=0);for(k=ro-1;E>v;){if(P[--E]<N[E]){for(C=E;C&&!P[--C];P[C]=k);--P[C],P[E]+=ro}P[E]-=N[E]}for(;P[0]==0;P.splice(0,1),--B);return P[0]?O(m,P,B):(m.s=s==3?-1:1,m.c=[m.e=0],m)},o.modulo=o.mod=function(m,k){var C,E,h=this;return m=new x(m,k),!h.c||!m.s||m.c&&!m.c[0]?new x(NaN):!m.c||h.c&&!h.c[0]?new x(h):(d==9?(E=m.s,m.s=1,C=t(h,m,0,3),m.s=E,C.s*=E):C=t(h,m,0,d),m=h.minus(C.times(m)),!m.c[0]&&d==1&&(m.s=h.s),m)},o.multipliedBy=o.times=function(m,k){var C,E,h,b,R,v,A,B,P,N,T,D,H,F,re,j=this,Y=j.c,J=(m=new x(m,k)).c;if(!Y||!J||!Y[0]||!J[0])return!j.s||!m.s||Y&&!Y[0]&&!J||J&&!J[0]&&!Y?m.c=m.e=m.s=null:(m.s*=j.s,!Y||!J?m.c=m.e=null:(m.c=[0],m.e=0)),m;for(E=$r(j.e/nt)+$r(m.e/nt),m.s*=j.s,A=Y.length,N=J.length,A<N&&(H=Y,Y=J,J=H,h=A,A=N,N=h),h=A+N,H=[];h--;H.push(0));for(F=ro,re=ci,h=N;--h>=0;){for(C=0,T=J[h]%re,D=J[h]/re|0,R=A,b=h+R;b>h;)B=Y[--R]%re,P=Y[R]/re|0,v=D*B+P*T,B=T*B+v%re*re+H[b]+C,C=(B/F|0)+(v/re|0)+D*P,H[b--]=B%F;H[b]=C}return C?++E:H.splice(0,1),O(m,H,E)},o.negated=function(){var m=new x(this);return m.s=-m.s||null,m},o.plus=function(m,k){var C,E=this,h=E.s;if(m=new x(m,k),k=m.s,!h||!k)return new x(NaN);if(h!=k)return m.s=-k,E.minus(m);var b=E.e/nt,R=m.e/nt,v=E.c,A=m.c;if(!b||!R){if(!v||!A)return new x(h/0);if(!v[0]||!A[0])return A[0]?m:new x(v[0]?E:h*0)}if(b=$r(b),R=$r(R),v=v.slice(),h=b-R){for(h>0?(R=b,C=A):(h=-h,C=v),C.reverse();h--;C.push(0));C.reverse()}for(h=v.length,k=A.length,h-k<0&&(C=A,A=v,v=C,k=h),h=0;k;)h=(v[--k]=v[k]+A[k]+h)/ro|0,v[k]=ro===v[k]?0:v[k]%ro;return h&&(v=[h].concat(v),++R),O(m,v,R)},o.precision=o.sd=function(m,k){var C,E,h,b=this;if(m!=null&&m!==!!m)return an(m,1,Ln),k==null?k=s:an(k,0,8),L(new x(b),m,k);if(!(C=b.c))return null;if(h=C.length-1,E=h*nt+1,h=C[h]){for(;h%10==0;h/=10,E--);for(h=C[0];h>=10;h/=10,E++);}return m&&b.e+1>E&&(E=b.e+1),E},o.shiftedBy=function(m){return an(m,-dh,dh),this.times("1e"+m)},o.squareRoot=o.sqrt=function(){var m,k,C,E,h,b=this,R=b.c,v=b.s,A=b.e,B=a+4,P=new x("0.5");if(v!==1||!R||!R[0])return new x(!v||v<0&&(!R||R[0])?NaN:R?b:1/0);if(v=Math.sqrt(+_(b)),v==0||v==1/0?(k=Nr(R),(k.length+A)%2==0&&(k+="0"),v=Math.sqrt(+k),A=$r((A+1)/2)-(A<0||A%2),v==1/0?k="5e"+A:(k=v.toExponential(),k=k.slice(0,k.indexOf("e")+1)+A),C=new x(k)):C=new x(v+""),C.c[0]){for(A=C.e,v=A+B,v<3&&(v=0);;)if(h=C,C=P.times(h.plus(t(b,h,B,1))),Nr(h.c).slice(0,v)===(k=Nr(C.c)).slice(0,v))if(C.e<A&&--v,k=k.slice(v-3,v+1),k=="9999"||!E&&k=="4999"){if(!E&&(L(h,h.e+a+2,0),h.times(h).eq(b))){C=h;break}B+=4,v+=4,E=1}else{(!+k||!+k.slice(1)&&k.charAt(0)=="5")&&(L(C,C.e+a+2,1),m=!C.times(C).eq(b));break}}return L(C,C.e+a+1,s,m)},o.toExponential=function(m,k){return m!=null&&(an(m,0,Ln),m++),M(this,m,k,1)},o.toFixed=function(m,k){return m!=null&&(an(m,0,Ln),m=m+this.e+1),M(this,m,k)},o.toFormat=function(m,k,C){var E,h=this;if(C==null)m!=null&&k&&typeof k=="object"?(C=k,k=null):m&&typeof m=="object"?(C=m,m=k=null):C=y;else if(typeof C!="object")throw Error(pr+"Argument not an object: "+C);if(E=h.toFixed(m,k),h.c){var b,R=E.split("."),v=+C.groupSize,A=+C.secondaryGroupSize,B=C.groupSeparator||"",P=R[0],N=R[1],T=h.s<0,D=T?P.slice(1):P,H=D.length;if(A&&(b=v,v=A,A=b,H-=b),v>0&&H>0){for(b=H%v||v,P=D.substr(0,b);b<H;b+=v)P+=B+D.substr(b,v);A>0&&(P+=B+D.slice(b)),T&&(P="-"+P)}E=N?P+(C.decimalSeparator||"")+((A=+C.fractionGroupSize)?N.replace(new RegExp("\\d{"+A+"}\\B","g"),"$&"+(C.fractionGroupSeparator||"")):N):P}return(C.prefix||"")+E+(C.suffix||"")},o.toFraction=function(m){var k,C,E,h,b,R,v,A,B,P,N,T,D=this,H=D.c;if(m!=null&&(v=new x(m),!v.isInteger()&&(v.c||v.s!==1)||v.lt(i)))throw Error(pr+"Argument "+(v.isInteger()?"out of range: ":"not an integer: ")+_(v));if(!H)return new x(D);for(k=new x(i),B=C=new x(i),E=A=new x(i),T=Nr(H),b=k.e=T.length-D.e-1,k.c[0]=ph[(R=b%nt)<0?nt+R:R],m=!m||v.comparedTo(k)>0?b>0?k:B:v,R=p,p=1/0,v=new x(T),A.c[0]=0;P=t(v,k,0,1),h=C.plus(P.times(E)),h.comparedTo(m)!=1;)C=E,E=h,B=A.plus(P.times(h=B)),A=h,k=v.minus(P.times(h=k)),v=h;return h=t(m.minus(C),E,0,1),A=A.plus(h.times(B)),C=C.plus(h.times(E)),A.s=B.s=D.s,b=b*2,N=t(B,E,b,s).minus(D).abs().comparedTo(t(A,C,b,s).minus(D).abs())<1?[B,E]:[A,C],p=R,N},o.toNumber=function(){return+_(this)},o.toPrecision=function(m,k){return m!=null&&an(m,1,Ln),M(this,m,k,2)},o.toString=function(m){var k,C=this,E=C.s,h=C.e;return h===null?E?(k="Infinity",E<0&&(k="-"+k)):k="NaN":(m==null?k=h<=u||h>=l?wu(Nr(C.c),h):Uo(Nr(C.c),h,"0"):m===10&&S?(C=L(new x(C),a+h+1,s),k=Uo(Nr(C.c),C.e,"0")):(an(m,2,I.length,"Base"),k=n(Uo(Nr(C.c),h,"0"),10,m,E,!0)),E<0&&C.c[0]&&(k="-"+k)),k},o.valueOf=o.toJSON=function(){return _(this)},o._isBigNumber=!0,o[Symbol.toStringTag]="BigNumber",o[Symbol.for("nodejs.util.inspect.custom")]=o.valueOf,e!=null&&x.set(e),x}function $r(e){var t=e|0;return e>0||e===t?t:t-1}function Nr(e){for(var t,n,r=1,o=e.length,i=e[0]+"";r<o;){for(t=e[r++]+"",n=nt-t.length;n--;t="0"+t);i+=t}for(o=i.length;i.charCodeAt(--o)===48;);return i.slice(0,o+1||1)}function Hi(e,t){var n,r,o=e.c,i=t.c,a=e.s,s=t.s,u=e.e,l=t.e;if(!a||!s)return null;if(n=o&&!o[0],r=i&&!i[0],n||r)return n?r?0:-s:a;if(a!=s)return a;if(n=a<0,r=u==l,!o||!i)return r?0:!o^n?1:-1;if(!r)return u>l^n?1:-1;for(s=(u=o.length)<(l=i.length)?u:l,a=0;a<s;a++)if(o[a]!=i[a])return o[a]>i[a]^n?1:-1;return u==l?0:u>l^n?1:-1}function an(e,t,n,r){if(e<t||e>n||e!==Or(e))throw Error(pr+(r||"Argument")+(typeof e=="number"?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function bu(e){var t=e.c.length-1;return $r(e.e/nt)==t&&e.c[t]%2!=0}function wu(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function Uo(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 hD=t4(),n4=hD;var xD=24,rl=32,yD=()=>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,fh=yD(),gh=(e=4,t=fh)=>{let n="";for(;n.length<e;)n=n+Math.floor(t()*36).toString(36);return n};function bD(e){let t=new n4(0);for(let n of e.values())t=t.multipliedBy(256).plus(n);return t}var o4=(e="")=>{let t=new TextEncoder;return bD(ZS(t.encode(e))).toString(36).slice(1)},r4=Array.from({length:26},(e,t)=>String.fromCharCode(t+97)),wD=e=>r4[Math.floor(e()*r4.length)],vD=({globalObj:e=typeof global<"u"?global:typeof window<"u"?window:{},random:t=fh}={})=>{let n=Object.keys(e).toString(),r=n.length?n+gh(rl,t):gh(rl,t);return o4(r).substring(0,rl)},SD=e=>()=>e++,kD=476782367,i4=({random:e=fh,counter:t=SD(Math.floor(e()*kD)),length:n=xD,fingerprint:r=vD({random:e})}={})=>{if(n>rl)throw new Error(`Length must be between 2 and ${rl}. Received: ${n}`);return function(){let i=wD(e),a=Date.now().toString(36),s=t().toString(36),u=gh(n,e),l=`${a+u+s+r}`;return`${i+o4(l).substring(1,n)}`}},ui=CD(i4);function CD(e){let t;return()=>(t||(t=e()),t())}var ED=tc(l4());on();He();var vu=/\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*-\s*(.+)/g;function RD(e){return e.replace(/\*\*/g,"").replace(/\*/g,"").replace(/__/g,"").replace(/_/g," ").trim()}function mh(e,t){let n=[],r=e.split(`
|
|
15
15
|
`);for(let a=0;a<r.length;a++){let s=RD(r[a]),u=vu.exec(s);if(u){let[,l,c,,p]=u,g=AD(c),d=FD(r,a+1),f={id:ui(),reviewId:t,type:l.trim(),severity:g,title:p.trim(),description:d.description,file:d.file,lineNumber:d.lineNumber,property:d.property,currentValue:d.currentValue,suggestedValue:d.suggestedValue,suggestedCode:d.suggestedCode,suggestedFix:d.suggestedFix,fixTarget:d.fixTarget,fixRequired:d.fixRequired,status:"pending",selectedForFix:!1,createdAt:new Date};n.push(f)}vu.lastIndex=0}return n.map(a=>{let s=Vs(a);return s.dismissed?(w.debug(`[parseIssues] Auto-dismissed: ${a.title} - ${s.dismissReason}`),{...a,dismissed:!0,dismissReason:s.dismissReason,dismissedBy:s.dismissedBy,dismissedAt:new Date}):a})}function AD(e){let t=e.toLowerCase().trim();return t.includes("critical")||t.includes("high")?"critical":t.includes("major")||t.includes("medium")?"major":"minor"}function FD(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||vu.test(i)){vu.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 a=i.replace("File:","").trim(),s=a.match(/^(.+?):(\d+)$/);s?(n.file=s[1],n.lineNumber=parseInt(s[2],10)):n.file=a}else if(i.startsWith("Property:"))n.property=i.replace("Property:","").trim();else if(i.startsWith("FixTarget:")){let a=i.replace("FixTarget:","").trim().toLowerCase();(a==="css"||a==="component")&&(n.fixTarget=a)}else if(i.startsWith("FixRequired:")){let a=i.replace("FixRequired:","").trim().toLowerCase();n.fixRequired=a==="true"}else if(i.startsWith("Fix:"))n.suggestedFix=i.replace("Fix:","").trim();else if(i.startsWith("```")){let a=[];for(o++;o<e.length&&!e[o].trim().startsWith("```");)a.push(e[o]),o++;n.suggestedCode=a.join(`
|
|
16
16
|
`)}else r.push(i)}return n.description=r.join(" ").trim(),n}He();var ol=null,c4=0,PD=3e4;async function MD(){let e=Date.now();if(ol&&e-c4<PD)return ol;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 ol=n.entries||n.stories||{},c4=e,w.debug("[storyFilePaths] Fetched index.json, entries:",Object.keys(ol).length),ol}catch(t){throw w.error("[storyFilePaths] Error fetching index.json:",t),t}}async function Ui(e){try{let n=(await MD())[e];if(!n?.importPath)return w.warn("[storyFilePaths] No importPath found for story:",e),null;let r=n.importPath;w.debug("[storyFilePaths] Found importPath:",r);let o=r.replace(/^\.\//,""),i;n.componentPath?(i=n.componentPath.replace(/^\.\//,""),w.debug("[storyFilePaths] Using Storybook componentPath:",i)):(i=`${o.replace(/\.stories\.tsx$/,"").replace(/\.stories\.ts$/,"").replace(/\.stories\.jsx$/,"").replace(/\.stories\.js$/,"")}.tsx`,w.debug("[storyFilePaths] Derived componentFile:",i));let a=i.replace(/\.tsx$/,".css").replace(/\.ts$/,".css").replace(/\.jsx$/,".css").replace(/\.js$/,".css"),s=i.substring(0,i.lastIndexOf("/")),u={storyFile:o,componentFile:i,cssFile:a,baseDir:s};return w.debug("[storyFilePaths] Final paths:",u),u}catch(t){return w.error("[storyFilePaths] Error getting file paths:",t),null}}function hh(e,t){if(e==="css")return t.cssFile;if(e==="component")return t.componentFile;if(e==="story")return t.storyFile}function LD(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 xh(e,t){let n=e.property?.toLowerCase()||"",r=e.domElement?.toLowerCase()||"",o=r.startsWith("svg"),i=r.startsWith("img"),a=n==="width"||n==="height",s=/\[(?:width|height)=/.test(r);return(o||i)&&a||s?(w.debug(`[storyFilePaths] \u{1F50D} INLINE ATTRIBUTE: domElement="${e.domElement}", property="${e.property}" \u2192 component file`),t.componentFile):LD(e.type,t)}on();He();function BD(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 zD(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 DD(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 _D(e,t,n){let r={critical:3,major:2,minor:1},i=[...e].sort((l,c)=>(r[c.severity]||0)-(r[l.severity]||0))[0],a=e.length,s,u;if(t.includes("icon")&&n==="dimensions"){let l=e.map(p=>p.currentValue).filter(Boolean),c=e.map(p=>p.suggestedValue).filter(Boolean);s=`Icon sizing is incorrect (${a} related issues)`,u=`Icons are rendered at wrong dimensions. Current: ${l[0]||"10px"}, Expected: ${c[0]||"20px"}. This single CSS fix will resolve all ${a} icon dimension issues.`}else s=`${t} ${n} issues (${a} related)`,u=`${a} related ${n} issues for ${t}. ${i.description}`;return{...i,id:`merged-${t}-${n}-${i.id}`,title:s,description:u,currentValue:i.currentValue,suggestedValue:i.suggestedValue,mergedCount:a,mergedIssueIds:e.map(l=>l.id)}}function yh(e){if(!e||e.length===0)return[];let t=e.filter(i=>!DD(i)),n=[],r=[];for(let i of t){let a=BD(i),s=zD(i);a.includes("icon")&&s==="dimensions"?n.push(i):r.push(i)}let o=[];return n.length>0&&(n.length===1?o.push(n[0]):o.push(_D(n,"icon","dimensions"))),o.push(...r),w.debug("[deduplicateIssues] Input:",e.length,"issues, Output:",o.length,"issues"),w.debug("[deduplicateIssues] Removed",e.length-t.length,"summary issues"),w.debug("[deduplicateIssues] Merged",n.length,"icon issues into",n.length>0?1:0),o}He();on();var ND=[/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],OD=[/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 il(e){let t=e instanceof Error?e.message:typeof e=="string"?e:"Review failed";return OD.some(n=>n.test(t))?t:ND.some(n=>n.test(t))?`Can't reach ${jt.NAME}. Check your internet connection and try again. If the dashboard URL is wrong, fix it in Settings.`:/Unauthorized|401/i.test(t)?"Your session expired. Sign out and back in from Settings to continue.":/Internal Server Error|5\d\d|server error/i.test(t)?`${jt.NAME}'s servers had a hiccup. Try the review again in a moment. If it keeps failing, send feedback.`:/parsing|SSE|stream|structured result|failed to receive/i.test(t)?"Review completed but the result was malformed. Try again, or send feedback if it keeps happening.":`Review failed: ${t.replace(/\.+\s*$/,"")}. Try again, or send feedback if this keeps happening.`}De();import{addons as Da}from"storybook/manager-api";var u4="uicopilot-sidebar-traffic-light",Ma="data-uic-issues",Hn="data-uic-status",Kn='[aria-label*="Test status" i]',La=new Map,al=new Set,bh=null,wh=!1;function Su(e,t){let n=t>0?t:0,r=La.get(e)??0;n!==r&&(n>0?La.set(e,n):La.delete(e),sl())}function ll(e){al.has(e)||(al.add(e),sl())}function p4(){La.size===0&&al.size===0||(La.clear(),al.clear(),sl())}function $D(e){let t=e.closest("[data-item-id]")??e.closest('[data-nodetype="story"], [data-nodetype="docs"]')??e.closest("a[id], a[href]");if(!t)return null;let n=t.getAttribute("data-item-id")??t.getAttribute("id");if(n)return n;let o=(t.getAttribute("href")??"").match(/[?&]id=([^&]+)/);return o?decodeURIComponent(o[1]):null}function d4(){typeof document>"u"||document.querySelectorAll(Kn).forEach(e=>{let t=$D(e);t&&al.has(t)?e.setAttribute(Hn,""):e.removeAttribute(Hn);let n=t?La.get(t):void 0;n&&n>0?e.setAttribute(Ma,n>99?"99+":String(n)):e.removeAttribute(Ma)})}function sl(){if(typeof requestAnimationFrame>"u"){d4();return}wh||(wh=!0,requestAnimationFrame(()=>{wh=!1,d4()}))}function g4(){typeof document>"u"||bh||(bh=new MutationObserver(()=>sl()),bh.observe(document.body,{childList:!0,subtree:!0}),sl())}function f4(){if(typeof document>"u"||document.getElementById(u4))return;let e=document.createElement("style");e.id=u4,e.textContent=`
|
|
17
17
|
${Kn}[${Hn}][aria-label*="error" i] svg,
|
|
@@ -88,7 +88,7 @@ ${vt}`).join(`
|
|
|
88
88
|
`,c$=tC.span(({theme:e})=>({display:"inline-block",width:"12px",height:"12px",border:`2px solid ${e.appBorderColor}`,borderTopColor:"currentColor",borderRadius:"50%",animation:`${l$} 0.6s linear infinite`,marginRight:"6px",verticalAlign:"middle"})),u$=tC.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}}})),So=({loading:e=!1,disabled:t=!1,onClick:n,variant:r="default",children:o,loadingText:i})=>eC.createElement(u$,{variant:r,disabled:t||e,onClick:n},e&&eC.createElement(c$,null),e&&i?i:o);De();import Bn from"react";import{styled as yl}from"storybook/theming";var nC=yl.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"})),d$=yl.div({display:"flex",alignItems:"center",gap:"12px"}),Nu=yl.span({whiteSpace:"nowrap"}),rC=yl.div({display:"flex",alignItems:"center",gap:"8px"}),Ou=yl.span(({theme:e})=>({fontWeight:600,color:e.color.defaultText})),$u=({inputTokens:e,outputTokens:t,costUsd:n,compact:r=!1})=>{let o=e+t,i=n*rS;return r?Bn.createElement(nC,null,Bn.createElement(Nu,null,o.toLocaleString()," tokens"),Bn.createElement(rC,null,Bn.createElement(Ou,null,"$",n.toFixed(4)),Bn.createElement("span",null,"\xB7"),Bn.createElement(Ou,null,"\u20AA",i.toFixed(2)))):Bn.createElement(nC,null,Bn.createElement(d$,null,Bn.createElement(Nu,null,e.toLocaleString()," input"),Bn.createElement("span",null,"+"),Bn.createElement(Nu,null,t.toLocaleString()," output"),Bn.createElement("span",null,"="),Bn.createElement(Nu,null,Bn.createElement("strong",null,o.toLocaleString())," tokens")),Bn.createElement(rC,null,Bn.createElement(Ou,null,"$",n.toFixed(4)),Bn.createElement("span",null,"\xB7"),Bn.createElement(Ou,null,"\u20AA",i.toFixed(2))))};import mr from"react";import{styled as fi}from"storybook/theming";function m1(e){if(typeof e!="string")return e;try{let t=JSON.parse(e);if(t.summary)return t}catch{}return{summary:e}}var p$=fi.div(({theme:e})=>({display:"flex",flexDirection:"column",gap:`${e.layoutMargin*.5}px`})),oC=fi.div(({theme:e,color:t})=>({fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,color:t||e.color.defaultText,lineHeight:"1.4"})),g$=fi.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.25}px`,flexWrap:"wrap",fontSize:e.typography.size.s1,color:e.color.mediumdark})),f$=fi.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$=fi.span(({theme:e})=>({color:e.color.mediumlight,fontSize:e.typography.size.s1})),h$=fi.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,fontStyle:"italic"})),x$=fi.div(({theme:e})=>({fontSize:e.typography.size.s1,color:e.color.mediumdark,display:"flex",gap:`${e.layoutMargin*.25}px`})),y$=fi.span(({theme:e})=>({fontWeight:e.typography.weight.bold,color:e.color.defaultText})),iC=({data:e,color:t,compact:n})=>n?mr.createElement(oC,{color:t},e.summary):mr.createElement(p$,null,mr.createElement(oC,{color:t},e.summary),e.mappings&&e.mappings.length>0&&mr.createElement(g$,null,e.mappings.map((r,o)=>mr.createElement(mr.Fragment,{key:o},mr.createElement(f$,null,r.from," ",mr.createElement(m$,null,"\u2192")," ",r.to)))),e.candidates!=null&&e.candidates>1&&mr.createElement(h$,null,e.candidates," candidate variants matched"),e.defaults&&e.defaults.length>0&&mr.createElement(mr.Fragment,null,e.defaults.map((r,o)=>mr.createElement(x$,{key:o},mr.createElement(y$,null,r.choice),mr.createElement("span",null,"\u2014 ",r.why)))));var b$=It.div({display:"flex",flexDirection:"column",flex:1,overflow:"hidden"}),w$=It.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px",borderBottom:`1px solid ${e.appBorderColor}`})),v$=It.div({display:"flex",flexDirection:"column",gap:"4px"}),S$=It.div({display:"flex",alignItems:"center",gap:"10px"}),k$=It.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"})),sC=It.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})),C$=It.span(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark})),I$=It.div({display:"flex",gap:"8px"}),T$=It.div(({theme:e})=>({display:"flex",alignItems:"center",padding:"12px 24px",gap:"12px",borderBottom:`1px solid ${e.appBorderColor}`})),E$=It(ni)(({theme:e})=>({flex:1,fontSize:e.typography.size.s2})),R$=It.div({display:"flex",gap:"4px"}),Hu=It.button(({theme:e,active:t})=>({padding:"6px 12px",borderRadius:"6px",fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,fontWeight:500,border:t?"none":`1px solid ${e.appBorderColor}`,backgroundColor:t?e.color.defaultText:e.background.content,color:t?e.color.inverseText:e.color.mediumdark,cursor:"pointer",transition:"all 0.15s","&:hover":{backgroundColor:t?e.color.defaultText:e.background.hoverable}})),A$=It.div({display:"flex",flexDirection:"column",flex:1,padding:"16px 24px",gap:"8px",overflowY:"auto"}),lC=It.div({display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",flex:"none"}),cC=It.span(({theme:e})=>({fontSize:"9px",fontWeight:e.typography.weight.bold,letterSpacing:"0.06em",textTransform:"uppercase",color:e.color.mediumdark,whiteSpace:"nowrap"})),F$=It.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}})),P$=It.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}`}})),M$=It.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"})),Uu=It.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$=It.img({width:"100%",height:"100%",objectFit:"contain"}),fC=It.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=It.div({flex:1,display:"flex",flexDirection:"column",gap:"2px",minWidth:0}),dC=It.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"})),h1=It.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"})),uge=It.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"})),B$=It.div(({theme:e})=>({flexShrink:0,color:e.color.mediumlight,fontSize:"14px"})),z$=It.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})),D$=It.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}})),_$=It.div(({theme:e})=>({padding:"16px 0",marginTop:"8px",borderTop:`1px solid ${e.appBorderColor}`,display:"flex",flexDirection:"column",gap:"8px"})),N$=It.div({display:"flex",flexWrap:"wrap",gap:"6px"}),O$=It.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})),$$=It.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$=It.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"}})),dge=It.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})),pC=({src:e,alt:t})=>{let[n,r]=ju(!1);return Ee.createElement(Ee.Fragment,null,!n&&Ee.createElement(fC,null),Ee.createElement(L$,{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 U$(e){return e==="high"?"#16a34a":e==="medium"?"#d97706":"#ef4444"}var x1=({results:e,stories:t,onApply:n,onCancel:r,onRerun:o,isApplying:i,isRerunning:a,source:s,resolveThumbnail:u,resolveStoryScreenshot:l,isCapturingScreenshots:c,onBrowse:p})=>{let[g,d]=ju(()=>{let C=new Set;for(let E of e.mappings)E.confidence>=90&&C.add(E.storyId);return C}),[f,y]=ju(""),[I,S]=ju("all"),x=aC(()=>{let C=new Map;for(let E of t)C.set(E.id,{name:E.name,title:E.title});return C},[t]),M=aC(()=>{let C=e.mappings;if(I!=="all"&&(C=C.filter(E=>gC(E.confidence)===I)),f.trim()){let E=f.toLowerCase();C=C.filter(h=>{let b=x.get(h.storyId);return b?.name.toLowerCase().includes(E)||b?.title.toLowerCase().includes(E)||h.componentSetName.toLowerCase().includes(E)||h.figmaFrameName.toLowerCase().includes(E)})}return C},[e.mappings,I,f,x]),z=C=>{d(E=>{let h=new Set(E);return h.has(C)?h.delete(C):h.add(C),h})},O=()=>{let C=e.mappings.filter(E=>g.has(E.storyId));n(C)},L=e.mappings.filter(C=>C.confidence>=90).length,_=e.mappings.filter(C=>C.confidence>=70&&C.confidence<90).length,m=e.mappings.filter(C=>C.confidence<70).length,k=e.usage;return Ee.createElement(b$,null,Ee.createElement(w$,null,Ee.createElement(v$,null,Ee.createElement(S$,null,Ee.createElement(k$,null,s==="deterministic"?"Auto-Link Results":"Auto-Map Results"),Ee.createElement(sC,{variant:"success"},e.stats.matched," matched"),e.unmatched.length>0&&Ee.createElement(sC,{variant:"danger"},e.unmatched.length," unmatched"),s&&Ee.createElement($$,{variant:s},s==="cache"?"Loaded from cache":s==="deterministic"?"Deterministic (no AI)":"Fresh analysis")),Ee.createElement(C$,null,"Review matches below. Uncheck any incorrect mappings before applying.")),Ee.createElement(I$,null,s==="cache"&&o&&Ee.createElement(H$,{onClick:o,disabled:a},a?"Re-running...":"Re-run LLM"),Ee.createElement(So,{onClick:r,variant:"ghost"},"Cancel"),Ee.createElement(So,{loading:i,onClick:O,loadingText:"Applying..."},"Apply ",g.size," Selected"))),Ee.createElement(T$,null,Ee.createElement(E$,{type:"text",placeholder:"Filter stories...",value:f,onChange:C=>y(C.target.value)}),Ee.createElement(R$,null,Ee.createElement(Hu,{active:I==="all",onClick:()=>S("all")},"All ",e.mappings.length),L>0&&Ee.createElement(Hu,{active:I==="high",onClick:()=>S("high")},"\u226590% (",L,")"),_>0&&Ee.createElement(Hu,{active:I==="medium",onClick:()=>S("medium")},"70-89% (",_,")"),m>0&&Ee.createElement(Hu,{active:I==="low",onClick:()=>S("low")},"<70% (",m,")"))),Ee.createElement(A$,null,M.map(C=>{let E=x.get(C.storyId),h=gC(C.confidence),b=g.has(C.storyId),R=h==="low";return Ee.createElement(F$,{key:C.storyId,dimmed:R&&!b},Ee.createElement(P$,{checked:b,onClick:()=>z(C.storyId)},b?"\u2713":""),(()=>{let v=l?.(C.storyId),A=v?Ee.createElement(Uu,null,Ee.createElement(pC,{src:v,alt:E?.name||C.storyId})):c?Ee.createElement(Uu,null,Ee.createElement(fC,null)):Ee.createElement(M$,{bgColor:R?"#f1f5f9":"#eff6ff"},Ee.createElement("span",{style:{fontFamily:"Inter",fontSize:"8px",fontWeight:500,color:R?"#94a3b8":"#3b82f6"}},(E?.name||"?").substring(0,4)));return Ee.createElement(lC,null,A,Ee.createElement(cC,null,"Storybook"))})(),Ee.createElement(uC,null,Ee.createElement(dC,null,E?.name||C.storyId),Ee.createElement(h1,null,E?.title||"")),Ee.createElement(B$,null,"\u2192"),(()=>{let v=u?.(C.figmaNodeId),A=m1(C.reason),B=A.summary+(A.candidates?` (${A.candidates} candidates)`:""),P=v?Ee.createElement(Uu,{title:B},Ee.createElement(pC,{src:v,alt:C.figmaFrameName})):Ee.createElement(Uu,{title:B},Ee.createElement("span",{style:{fontFamily:"Inter",fontSize:"10px",fontWeight:500,color:"#94a3b8"}},"No thumbnail"));return Ee.createElement(lC,null,P,Ee.createElement(cC,null,"Figma"))})(),Ee.createElement(uC,null,Ee.createElement(dC,null,C.componentSetName),Ee.createElement(h1,null,C.figmaFrameName),Ee.createElement(iC,{data:m1(C.reason),color:U$(h)})),Ee.createElement(z$,{level:h},C.confidence,"%"),p&&Ee.createElement(D$,{onClick:()=>p(C.componentSetName)},"Browse"))}),e.unmatched.length>0&&Ee.createElement(_$,null,Ee.createElement(h1,null,e.unmatched.length," stories couldn't be matched \u2014 map manually after applying"),Ee.createElement(N$,null,e.unmatched.map(C=>{let E=x.get(C);return Ee.createElement(O$,{key:C},Ee.createElement("span",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#cbd5e1"}}),E?`${E.name} (${E.title})`:C)})))),k&&s!=="cache"&&Ee.createElement("div",{style:{padding:"8px 24px",borderTop:"1px solid #f0f0f0"}},Ee.createElement($u,{inputTokens:k.inputTokens||0,outputTokens:k.outputTokens||0,costUsd:k.costUsd||0})))};De();He();import{useState as mi,useCallback as hi,useRef as j$}from"react";import{useStorybookApi as V$}from"storybook/manager-api";function mC({projectId:e}){let t=V$(),n=j$(null),[r,o]=mi(!1),[i,a]=mi(!1),[s,u]=mi(!1),[l,c]=mi(null),[p,g]=mi(null),[d,f]=mi(null),[y,I]=mi(""),[S,x]=mi(null),M=hi(async()=>{let E=await fetch("/index.json");if(!E.ok)throw new Error("Failed to fetch Storybook index");let h=await E.json(),b=h.entries||h.stories||{},R=Object.keys(b).filter(B=>b[B].type==="story");w.debug(`[useAutoMap] Found ${R.length} stories in index.json`);let v=[];for(let B of R){let P=b[B],N=t.getData(B),T={...N?.initialArgs||{}},D=N?.argTypes||{};for(let[H,F]of Object.entries(D))if(!(H in T)){let re=F;if(re.defaultValue!==void 0)T[H]=re.defaultValue;else if(re.table?.defaultValue?.summary!==void 0){let j=re.table.defaultValue.summary;j==="false"?T[H]=!1:j==="true"?T[H]=!0:T[H]=j}}v.push({id:B,name:P.name||B.split("--").pop()||B,title:P.title||"",initialArgs:T,argTypes:D})}let A=v.filter(B=>Object.keys(B.initialArgs).length>0);return w.debug(`[useAutoMap] Manifest: ${v.length} stories, ${A.length} with args`),v},[t]),z=hi(async()=>{if(!e)return!1;try{let E=K(),h=localStorage.getItem("uicopilot_session_token");if(!h)return!1;let b=await fetch(`${E}/api/figma/auto-map?projectId=${e}`,{headers:{Authorization:`Bearer ${h}`}});if(!b.ok)return!1;let R=await b.json();return R.hasSuggestions&&R.mappings?.length>0?(g(R),x("cache"),I(`Loaded ${R.mappings.length} saved suggestions`),w.debug(`[useAutoMap] Loaded ${R.mappings.length} existing suggestions from DB`),!0):!1}catch{return!1}},[e]),O=hi(async E=>{o(!0),I("Collecting story information...");let h;try{if(h=await M(),E?.length&&(h=h.filter(R=>!E.includes(R.id)),w.debug(`[useAutoMap] After excluding mapped: ${h.length} stories`)),h.length===0){c("No unmapped stories found"),o(!1);return}f(h)}catch(R){c(R instanceof Error?R.message:"Failed to collect story manifest"),o(!1);return}o(!1),a(!0),I(`Analyzing ${h.length} stories against Figma components...`);let b=new AbortController;n.current=b;try{let R=K(),v=localStorage.getItem("uicopilot_session_token");if(!v)throw new Error("Not authenticated");let A=await fetch(`${R}/api/figma/auto-map`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${v}`},body:JSON.stringify({projectId:e,stories:h.map(P=>({id:P.id,name:P.name,title:P.title,initialArgs:P.initialArgs,argTypes:P.argTypes}))}),signal:b.signal});if(!A.ok){let P=await A.json();throw new Error(P.error||"Auto-map failed")}let B=await A.json();g(B),x("llm"),I(`Found ${B.stats.matched} matches (${B.stats.highConfidence} high confidence)`),w.debug(`[useAutoMap] Results: ${B.stats.matched}/${B.stats.total} matched, ${B.unmatched.length} unmatched`)}catch(R){if(R instanceof DOMException&&R.name==="AbortError"){I("Cancelled");return}c(R instanceof Error?R.message:"Auto-map failed")}finally{a(!1),n.current=null}},[e,M]),L=hi(async E=>{if(!e)return;if(c(null),g(null),x(null),o(!0),I("Checking for existing suggestions..."),await z()){o(!1);return}await O(E)},[e,z,O]),_=hi(async E=>{e&&(c(null),g(null),x(null),await O(E))},[e,O]),m=hi(async E=>{if(!(!e||E.length===0)){u(!0),I(`Applying ${E.length} mappings...`);try{let h=K(),b=localStorage.getItem("uicopilot_session_token");if(!b)throw new Error("Not authenticated");let R=0;for(let v of E)try{(await fetch(`${h}/api/mappings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${b}`},body:JSON.stringify({projectId:e,storyId:v.storyId,figmaNodeId:v.figmaNodeId,name:v.figmaFrameName||v.componentSetName})})).ok?R++:w.warn(`[useAutoMap] Failed to apply mapping for ${v.storyId}`)}catch(A){w.error(`[useAutoMap] Error applying mapping for ${v.storyId}:`,A)}I(`Applied ${R}/${E.length} mappings`),w.debug(`[useAutoMap] Applied ${R}/${E.length} mappings`)}catch(h){c(h instanceof Error?h.message:"Failed to apply mappings")}finally{u(!1)}}},[e]),k=hi(()=>{n.current?.abort()},[]),C=hi(()=>{g(null),f(null),c(null),I(""),x(null)},[]);return{collectAndMap:L,rerun:_,loadExisting:z,applyMappings:m,cancel:k,reset:C,isCollecting:r,isMapping:i,isApplying:s,error:l,results:p,manifest:d,progress:y,source:S}}De();He();import{useState as Wu,useCallback as y1,useRef as hC}from"react";async function Vu(e,t,n,r){let o=new Array(e.length),i=0;async function a(){for(;i<e.length&&!r();){let s=i++;try{let u=await e[s]();o[s]=u,r()||n(s,u)}catch(u){o[s]=u,r()||n(s,u)}}}return await Promise.all(Array.from({length:Math.min(t,e.length)},()=>a())),o}ct();var W$=3;function G$(e){let t=Object.entries(e).filter(([,n])=>n!=null&&n>=.9).map(([n])=>n);return t.length?`matched: ${t.join(", ")}`:"weak signature match"}function q$(e,t){let n=`Signature ${Math.round(e.score*100)}% \u2014 ${G$(e.signals)}`;return t?`${n}; runner-up: ${t.name} (${Math.round(t.score*100)}%)`:n}function xC({projectId:e}){let[t,n]=Wu(!1),[r,o]=Wu(""),[i,a]=Wu(null),[s,u]=Wu(null),l=hC(!1),c=hC(!1),p=y1(async f=>{if(c.current)return;if(!e||f.length===0){a(f.length===0?"No unmapped stories found":null);return}let y=localStorage.getItem("uicopilot_session_token");if(!y){a("Not authenticated");return}c.current=!0,l.current=!1,n(!0),a(null),u(null),o("Preparing match index\u2026 first run can take ~30s, then it is cached");let I=K(),S=0,x=[],M=[],z={},O=f.map(L=>async()=>{let _=await Z(`${I}/api/figma/suggest-links`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y}`},body:JSON.stringify({projectId:e,story:{id:L.id,name:L.name,title:L.title,args:L.args}})},12e4);if(!_.ok){let m=await _.json().catch(()=>({}));throw new Error(m.error||`suggest-links failed (${_.status})`)}return await _.json()});try{let L=await Vu(O,W$,(C,E)=>{S+=1,o(`Matched ${S}/${f.length} stories\u2026`);let h=f[C];if(E instanceof Error){w.warn(`[useAutoLink] ${h.id}: ${E.message}`),M.push(h.id);return}let[b,R]=E.suggestions??[];if(!b){M.push(h.id);return}x.push({storyId:h.id,figmaNodeId:b.figmaNodeId,figmaFrameName:b.name,componentSetName:b.name,confidence:Math.round(b.score*100),reason:q$(b,R)});for(let v of E.suggestions)z[v.figmaNodeId]=v.thumbnailUrl},()=>l.current);if(l.current){o("Cancelled");return}let _=L.find(C=>C instanceof Error);if(x.length===0&&_)throw _;let m=new Set,k=x.filter(C=>m.has(C.storyId)?!1:(m.add(C.storyId),!0));w.debug(`[useAutoLink] ${f.length} stories \u2192 ${x.length} mappings (${k.length} unique)`),u({mappings:k,unmatched:M,thumbnailUrls:z,stats:{total:f.length,matched:k.length,highConfidence:k.filter(C=>C.confidence>=90).length}}),o(`Found ${k.length} matches (no AI)`)}catch(L){a(L instanceof Error?L.message:"Auto-link failed")}finally{c.current=!1,n(!1)}},[e]),g=y1(()=>{l.current=!0,n(!1)},[]),d=y1(()=>{u(null),a(null),o("")},[]);return{run:p,cancel:g,reset:d,isRunning:t,progress:r,error:i,results:s}}He();import{useState as b1,useEffect as Y$,useRef as yC}from"react";var bC=2;async function K$(e,t){try{let n=await fetch(`/__uicopilot/screenshot?storyId=${encodeURIComponent(e)}`,{signal:t});return n.ok&&(await n.json()).screenshot||null}catch{return null}}function wC(e){let[t,n]=b1({}),[r,o]=b1(0),[i,a]=b1(!1),s=yC(null),u=yC(""),l=e.join(",");return Y$(()=>{if(!e.length||l===u.current)return;u.current=l,n({}),o(0),a(!0);let c=new AbortController;s.current=c;let p=0;return(async()=>{for(let d=0;d<e.length&&!c.signal.aborted;d+=bC){let f=e.slice(d,d+bC),y=await Promise.all(f.map(S=>K$(S,c.signal).then(x=>({id:S,img:x}))));if(c.signal.aborted)break;let I={};for(let{id:S,img:x}of y)p++,x&&(I[S]=x);Object.keys(I).length>0&&n(S=>({...S,...I})),o(p)}a(!1),w.debug(`[useStoryScreenshots] Captured ${p}/${e.length} screenshots`)})().catch(()=>a(!1)),()=>{c.abort()}},[l]),{screenshots:t,isCapturing:i,progress:{done:r,total:e.length}}}import Fe,{useState as w1,useEffect as bl,useMemo as X$,useCallback as J$}from"react";import{styled as Q$}from"storybook/theming";He();var Z$=Q$.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"}})),Wa=({isOpen:e,onClose:t,onSelect:n,projectId:r,stories:o=[],currentStoryId:i,onStoryChange:a,multiSelect:s=!1,onMultiSelect:u,initialSearch:l})=>{let c=ul({projectId:r||"",enabled:e&&!!r}),p=Fe.useRef(!1);bl(()=>{e&&l&&!p.current&&(c.setSearch(l),p.current=!0),e||(p.current=!1)},[e,l]);let[g,d]=w1(new Set),[f,y]=w1(i||o[0]?.id||"");bl(()=>{i&&y(i)},[i]);let I=50,S=8,[x,M]=w1({}),z=J$(h=>{M(b=>({...b,[h]:(b[h]||1)+1}))},[]);bl(()=>{M({})},[c.variantFilters]),bl(()=>{c.expandedSets.forEach(h=>{let b=c.variantChildren[h];if(!b||b.length===0)return;let R=b;c.variantFilters.some(B=>B.value)&&(R=b.filter(B=>B.variantProperties?c.variantFilters.every(P=>P.value?B.variantProperties?.[P.property]===P.value:!0):!1));let v=x[h]||1,A=R.slice(0,v*I).map(B=>B.id);for(let B=0;B<A.length;B+=S){let P=A.slice(B,B+S),N=B/S*300;N===0?c.fetchVariantThumbnails(h,P):setTimeout(()=>c.fetchVariantThumbnails(h,P),N)}})},[c.expandedSets,c.variantChildren,c.variantFilters,x]),bl(()=>{d(new Set)},[f]);let O=X$(()=>{let h=[];return c.filteredFrames.forEach(b=>{if(b.type==="COMPONENT_SET"&&b.children){let R=c.variantFilters.some(v=>v.value)?b.children.filter(v=>v.variantProperties?c.variantFilters.every(A=>A.value?v.variantProperties?.[A.property]===A.value:!0):!1):b.children;h.push(...R)}else h.push(b)}),h},[c.filteredFrames,c.variantFilters]),L=h=>{if(s)d(b=>{let R=new Set(b);return R.has(h.id)?R.delete(h.id):R.add(h.id),R});else{let b=c.resolveThumbnail(h.id);try{n({...h,thumbnail:b})}catch(R){w.error("[ComponentBrowserModal] onSelect threw error:",R)}t()}},_=()=>{let h=O.map(R=>R.id),b=h.every(R=>g.has(R));d(b?new Set:new Set(h))},m=()=>{if(u&&g.size>0){let h=O.filter(b=>g.has(b.id)).map(b=>({...b,thumbnail:c.resolveThumbnail(b.id)}));u(h),d(new Set)}},k=h=>{y(h),a?.(h)},C=h=>{h.target===h.currentTarget&&t()},E=o.find(h=>h.id===f);return e?Fe.createElement(tk,{onClick:C},Fe.createElement(nk,null,Fe.createElement(rk,null,Fe.createElement(ok,null,"Link Figma Frames"),Fe.createElement("div",{style:{display:"flex",gap:"8px",alignItems:"center"}},Fe.createElement("button",{onClick:()=>c.refresh(),disabled:c.isLoading,style:{padding:"4px 8px",fontSize:"12px",cursor:c.isLoading?"not-allowed":"pointer",background:"transparent",border:"1px solid #ccc",borderRadius:"4px"},title:"Refresh from Figma"},"Refresh"),Fe.createElement(ik,{onClick:t},"\xD7"))),Fe.createElement(ak,null,c.error&&Fe.createElement(gk,null,c.error),!c.error&&Fe.createElement(Fe.Fragment,null,o.length>0&&Fe.createElement(Ck,null,Fe.createElement(Ik,null,"Story:"),Fe.createElement(Tk,{value:f,onChange:h=>k(h.target.value)},o.map(h=>Fe.createElement("option",{key:h.id,value:h.id},h.name,h.mappingsCount?` (${h.mappingsCount} linked)`:""))),E?.mappingsCount?Fe.createElement(Ek,{hasMapping:!0},E.mappingsCount," frames linked"):null),Fe.createElement(dk,null,Fe.createElement(Pu,null,Fe.createElement("input",{type:"checkbox",checked:c.showComponentSets,onChange:h=>c.setShowComponentSets(h.target.checked)}),"Component Sets"),Fe.createElement(Pu,null,Fe.createElement("input",{type:"checkbox",checked:c.showFrames,onChange:h=>c.setShowFrames(h.target.checked)}),"Frames"),Fe.createElement(Pu,null,Fe.createElement("input",{type:"checkbox",checked:c.showComponents,onChange:h=>c.setShowComponents(h.target.checked)}),"Components"),c.availablePages.length>1&&Fe.createElement(ja,{isActive:!!c.figmaPage,value:c.figmaPage,onChange:h=>c.setFigmaPage(h.target.value),style:{marginLeft:"auto"}},Fe.createElement("option",{value:""},"All pages"),c.availablePages.map(h=>Fe.createElement("option",{key:h,value:h},h)))),c.filterSuggestion&&Fe.createElement(Rk,null,Fe.createElement(Ak,null,"AI suggests:"),Fe.createElement(Fk,null,Object.entries(c.filterSuggestion.suggestedFilters).map(([h,b])=>`${h}=${b}`).join(", ")),Fe.createElement(Pk,{onClick:c.applySuggestedFilters},"Apply"),Fe.createElement(Mk,{onClick:c.dismissFilterSuggestion},"Dismiss")),c.filterSuggestionLoading&&Fe.createElement(Lk,null,"Matching story args to Figma filters..."),c.availableFilters.length>0&&Fe.createElement(Lu,null,Fe.createElement(hl,null,"Filters:"),c.availableFilters.map(({property:h,values:b})=>{let R=c.variantFilters.find(v=>v.property===h);return Fe.createElement(ja,{key:h,isActive:!!R?.value,value:R?.value||"",onChange:v=>c.handleFilterChange(h,v.target.value)},Fe.createElement("option",{value:""},h),b.map(v=>Fe.createElement("option",{key:v,value:v},h,"=",v)))}),c.variantFilters.some(h=>h.value)&&Fe.createElement(Bu,{onClick:c.clearFilters},"Clear All")),c.rateLimitError&&Fe.createElement("div",{style:{padding:"8px 12px",marginBottom:"8px",background:"rgba(234, 88, 12, 0.12)",border:"1px solid rgba(234, 88, 12, 0.3)",borderRadius:"6px",fontSize:"12px",color:"#ea580c"}},"\u26A0 Figma thumbnail previews unavailable \u2014"," ",c.rateLimitError,". You can still select by name."),Fe.createElement(sk,{type:"text",placeholder:"Search frames...",value:c.search,onChange:h=>c.setSearch(h.target.value),autoFocus:!0}),s&&O.length>0&&Fe.createElement(Bk,null,Fe.createElement(zk,{onClick:_},g.size===O.length?"Deselect All":"Select All Visible"),Fe.createElement(Dk,null,g.size>0?`${g.size} selected of `:"Showing ",O.length," frames")),c.isLoading&&Fe.createElement(Jh,null,Array.from({length:6}).map((h,b)=>Fe.createElement(kk,{key:b},Fe.createElement("div",{style:{width:"100%",aspectRatio:"4 / 3"}},Fe.createElement(Mu,{width:"100%",height:"100%"})),Fe.createElement("div",{style:{padding:"12px",display:"flex",flexDirection:"column",gap:"8px"}},Fe.createElement(Mu,{width:"80%",height:"16px"}),Fe.createElement(Mu,{width:"50%",height:"12px"}))))),!c.isLoading&&c.filteredFrames.length===0&&Fe.createElement(pk,null,c.search?"No components match your search":"No Figma components found. We index Figma components \u2014 component sets and standalone components. Plain design frames (screens, mockups) aren't included yet \u2014 frame support is planned \u2014 so a file made only of frames will look empty here for now."),!c.isLoading&&c.filteredFrames.length>0&&Fe.createElement(Jh,null,c.filteredFrames.map(h=>Fe.createElement(xl,{key:h.id,frame:h,thumbnail:c.thumbnails[h.id],thumbnails:c.thumbnails,variantThumbnails:c.variantThumbnails[h.id],variantChildren:c.variantChildren[h.id],variantFailed:c.variantFailed[h.id],isLoadingVariants:c.loadingVariants.has(h.id),isExpanded:c.expandedSets.has(h.id),isNew:c.recentlyAdded.has(h.name),onToggleExpand:c.toggleExpanded,onSelect:L,multiSelect:s,selectedFrames:g,variantFilters:c.variantFilters,variantPage:x[h.id]||1,onShowMore:z})),c.hasMore&&Fe.createElement(Z$,{onClick:c.loadMore,disabled:c.loadingMore},c.loadingMore?"Loading...":`Show more (${c.totalFrames-c.frames.length} remaining)`)))),s&&Fe.createElement(_k,null,Fe.createElement(Nk,{disabled:g.size===0,onClick:m},"Link ",g.size," Selected")))):null};ke();ct();var nH=An.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}),rH=An.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"})),oH=An.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app})),iH=An.div({display:"flex",alignItems:"center",gap:"20px"}),aH=An.h2(({theme:e})=>({fontSize:"16px",fontWeight:600,color:e.color.defaultText,margin:0,display:"flex",alignItems:"center",gap:"8px"})),sH=An.div({display:"flex",gap:"4px"}),vC=An(ti)(({theme:e,active:t})=>({padding:"8px 16px",borderBottom:"none",borderRadius:"6px",backgroundColor:t?e.background.hoverable:"transparent","&:hover":{backgroundColor:e.background.hoverable}})),lH=An(br)({width:"32px",height:"32px",fontSize:"20px",borderRadius:"6px"}),cH=An.div({flex:1,overflow:"hidden",display:"flex",flexDirection:"column"}),uH=An.div(({theme:e})=>({padding:"12px 20px",borderTop:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app,display:"flex",alignItems:"center",justifyContent:"space-between"})),dH=An.div(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,display:"flex",gap:"16px"})),v1=An.div({display:"flex",flexDirection:"column",flex:1,alignItems:"center",justifyContent:"center",backgroundColor:"rgba(255, 255, 255, 0.95)",padding:"40px"}),S1=An.div({display:"flex",flexDirection:"column",alignItems:"center",gap:"20px",maxWidth:"400px"}),k1=An.div(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText,textAlign:"center"})),C1=An.div(({theme:e})=>({fontFamily:e.typography.fonts.base,fontSize:e.typography.size.s2,color:e.color.mediumdark,textAlign:"center"})),SC=An.div(({theme:e})=>({width:"100%",height:"8px",backgroundColor:e.appBorderColor,borderRadius:"4px",overflow:"hidden"})),kC=An.div(({theme:e})=>({width:"100%",height:"100%",backgroundColor:e.color.secondary,borderRadius:"4px",opacity:.6})),CC=An.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"}})),IC=An.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"}})),TC=({isOpen:e,onClose:t,projectId:n})=>{let[r,o]=qi("map"),[i,a]=qi([]),[s,u]=qi(!0),[l,c]=qi(null),[p,g]=qi(!1),[d,f]=qi(null),y=tH(),I=mC({projectId:n}),S=xC({projectId:n}),[x,M]=qi(!1),{refreshMappings:z}=pt(),{featureFlags:O}=ge(),L=Pe.useMemo(()=>(I.results??S.results)?.mappings.map(H=>H.storyId)||[],[I.results,S.results]),_=wC(L),m=io(async()=>{u(!0);try{let H=await fetch("/index.json");if(!H.ok)throw new Error("Failed to fetch index.json");let F=await H.json(),re=F.entries||F.stories||{},j=Object.entries(re).filter(([,J])=>J.type==="story").map(([J,ne])=>({id:J,name:ne.name||J.split("--").pop()||J,title:ne.title||"",importPath:ne.importPath,componentTitle:ne.title?.split("/").slice(0,-1).join("/")||ne.title,figmaMapping:null}));try{let J=K(),ne=localStorage.getItem("uicopilot_session_token"),Re=await Z(`${J}/api/mappings?projectId=${n}&_t=${Date.now()}`,{headers:{Authorization:`Bearer ${ne}`}});if(Re.ok){let be=await Re.json(),fe=new Map((be.mappings||[]).map(Me=>[Me.storyId,Me]));j.forEach(Me=>{let me=fe.get(Me.id);me&&me.figmaNodeId&&(Me.figmaMapping={figmaNodeId:me.figmaNodeId,figmaFrameName:me.name||me.figmaFrameName||""})})}}catch(J){console.warn("[StoryMappingAssistant] Failed to fetch mappings (stories still loaded):",J)}a(j);let Y=j.find(J=>!J.figmaMapping);Y?c(Y.id):j.length>0&&c(j[0].id)}catch(H){console.error("[StoryMappingAssistant] Error fetching stories:",H)}finally{u(!1)}},[n]);eH(()=>{e&&m()},[e,m]);let k=io((H,F,re)=>{a(J=>J.map(ne=>ne.id===H?{...ne,figmaMapping:{figmaNodeId:F,figmaFrameName:re}}:ne));let j=i.findIndex(J=>J.id===H),Y=i.find((J,ne)=>ne>j&&!J.figmaMapping);Y&&c(Y.id)},[i]),C=io(H=>{a(F=>F.map(re=>re.id===H?{...re,figmaMapping:null}:re))},[]),E=io(H=>{c(H),o("map")},[]),h=io(()=>{let H=i.filter(F=>F.figmaMapping).map(F=>F.id);I.collectAndMap(H)},[i,I]),b=io(()=>{let H=i.filter(F=>F.figmaMapping).map(F=>F.id);g(!1),I.rerun(H)},[i,I]),R=io(async H=>{await I.applyMappings(H),g(!1),I.reset(),m(),z()},[I,m,z]),v=io(()=>{g(!1),I.reset()},[I]),A=io(()=>{let H=i.filter(F=>!F.figmaMapping).map(F=>{let re=y.getData(F.id);return{id:F.id,name:F.name,title:F.title,args:re?.initialArgs??{}}});S.run(H)},[i,S,y]),B=io(async H=>{await I.applyMappings(H),M(!1),S.reset(),m(),z()},[I,S,m,z]),P=io(()=>{M(!1),S.reset()},[S]);Pe.useEffect(()=>{I.results&&g(!0)},[I.results]),Pe.useEffect(()=>{S.results&&M(!0)},[S.results]);let N=H=>{H.target===H.currentTarget&&t()};if(!e)return null;let T=i.filter(H=>H.figmaMapping).length,D=i.length;return Pe.createElement(Pe.Fragment,null,Pe.createElement(nH,{onClick:N},Pe.createElement(rH,{onClick:H=>H.stopPropagation()},Pe.createElement(oH,null,Pe.createElement(iH,null,Pe.createElement(aH,null,Pe.createElement("span",null,"\u{1F517}"),"Link Stories to Figma"),Pe.createElement(sH,null,Pe.createElement(vC,{active:r==="map",onClick:()=>o("map")},"Map Stories"),Pe.createElement(vC,{active:r==="view",onClick:()=>o("view")},"View All Mappings"))),Pe.createElement("div",{style:{display:"flex",alignItems:"center",gap:"12px"}},O.enableAutoMap&&!p&&!I.isCollecting&&!I.isMapping&&Pe.createElement(CC,{onClick:h,disabled:s||i.length===0},Pe.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2"},Pe.createElement("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),Pe.createElement("path",{d:"M2 17l10 5 10-5"}),Pe.createElement("path",{d:"M2 12l10 5 10-5"})),"Auto-Map All"),O.enableAutoFigmaLinking&&!p&&!x&&!S.isRunning&&Pe.createElement(CC,{onClick:A,disabled:s||i.length===0,title:"Match stories to Figma sets by structural spec signatures \u2014 no LLM"},Pe.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2"},Pe.createElement("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),Pe.createElement("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})),"Auto-Link (No AI)"),Pe.createElement(lH,{onClick:t},"\xD7"))),Pe.createElement(cH,null,(I.isCollecting||I.isMapping)&&Pe.createElement(v1,null,Pe.createElement(S1,null,Pe.createElement(SC,null,Pe.createElement(kC,null)),Pe.createElement(k1,null,"Auto-mapping stories to Figma"),Pe.createElement(C1,null,I.progress),Pe.createElement(So,{onClick:I.cancel,variant:"ghost"},"Cancel"))),S.isRunning&&Pe.createElement(v1,null,Pe.createElement(S1,null,Pe.createElement(SC,null,Pe.createElement(kC,null)),Pe.createElement(k1,null,"Auto-linking stories to Figma (no AI)"),Pe.createElement(C1,null,S.progress),Pe.createElement(So,{onClick:S.cancel,variant:"ghost"},"Cancel"))),S.error&&!S.isRunning&&!x&&Pe.createElement(v1,null,Pe.createElement(S1,null,Pe.createElement(k1,null,"Auto-link failed"),Pe.createElement(C1,null,S.error),Pe.createElement(So,{onClick:S.reset,variant:"ghost"},"Dismiss"))),x&&S.results&&Pe.createElement(x1,{results:S.results,stories:i,onApply:B,onCancel:P,isApplying:I.isApplying,source:"deterministic",resolveThumbnail:H=>S.results?.thumbnailUrls?.[H],resolveStoryScreenshot:H=>_.screenshots[H],isCapturingScreenshots:_.isCapturing,onBrowse:H=>f(H)}),p&&I.results&&Pe.createElement(x1,{results:I.results,stories:i,onApply:R,onCancel:v,onRerun:b,isApplying:I.isApplying,isRerunning:I.isCollecting||I.isMapping,source:I.source,resolveThumbnail:H=>I.results?.thumbnailUrls?.[H],resolveStoryScreenshot:H=>_.screenshots[H],isCapturingScreenshots:_.isCapturing,onBrowse:H=>f(H)}),!p&&!x&&!S.isRunning&&!S.error&&!I.isCollecting&&!I.isMapping&&(r==="map"?Pe.createElement(Kk,{stories:i,loading:s,selectedStoryId:l,onSelectStory:c,onStoryMapped:k,projectId:n}):Pe.createElement(Zk,{stories:i,loading:s,onLink:E,onUnlink:C,projectId:n}))),Pe.createElement(uH,null,Pe.createElement(dH,null,Pe.createElement("span",null,"Total: ",D," stories"),Pe.createElement(IC,{type:"mapped"},Pe.createElement("span",{className:"dot"}),T," mapped"),Pe.createElement(IC,{type:"unmapped"},Pe.createElement("span",{className:"dot"}),D-T," unmapped"))))),Pe.createElement(Wa,{isOpen:!!d,onClose:()=>f(null),onSelect:()=>f(null),projectId:n,initialSearch:d||void 0}))};ct();var EC=Tr.div({display:"flex",flexDirection:"column",gap:"6px",padding:"12px 16px"}),gH=Tr.div({display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"}),fH=Tr.span(({theme:e})=>({fontSize:"10px",fontWeight:e.typography.weight.bold,letterSpacing:"0.06em",textTransform:"uppercase",color:e.color.mediumdark})),mH=Tr.div({display:"flex",alignItems:"center",gap:"12px",fontSize:"11px"}),hH=Tr.span(({theme:e,state:t})=>({fontFamily:e.typography.fonts.mono,fontWeight:e.typography.weight.bold,whiteSpace:"nowrap",color:t==="complete"?e.color.positive:t==="partial"?e.color.warning:e.color.mediumdark})),xH=Tr.div(({theme:e})=>({width:"100%",height:"4px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),yH=Tr.div(({theme:e,percent:t,state:n})=>({width:`${t}%`,height:"100%",borderRadius:"2px",backgroundColor:n==="complete"?e.color.positive:n==="partial"?e.color.warning:e.color.mediumlight,transition:"width 0.3s ease"})),bH=Tr(up)(({theme:e})=>({padding:0,fontSize:"11px",fontWeight:e.typography.weight.bold,color:e.color.defaultText})),wH=Tr(up)(({theme:e})=>({padding:0,fontSize:"11px",fontWeight:e.typography.weight.regular,color:e.color.mediumdark,"&:hover":{textDecoration:"none",color:e.color.defaultText}})),vH=Tr.div({display:"flex",alignItems:"center",gap:"8px"}),SH=Tr.span(({theme:e})=>({fontSize:"13px",color:e.color.mediumdark,fontStyle:"italic"})),kH=Tr.div(({theme:e})=>({width:"14px",height:"14px",border:`2px solid ${e.appBorderColor}`,borderTopColor:W,borderRadius:"50%",animation:"figma-mapping-spin 0.8s linear infinite","@keyframes figma-mapping-spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}})),CH=Tr.span(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark})),RC=({refreshKey:e=0})=>{let[t,n]=Gu(!1),[r,o]=Gu({totalStories:0,mappedStories:0,loading:!0}),{selectedProjectId:i}=Ke(),{sessionToken:a}=ye();pH(()=>{i&&a?s():o({totalStories:0,mappedStories:0,loading:!1})},[i,a,e]);let s=async()=>{o(L=>({...L,loading:!0}));try{let L=await fetch("/index.json");if(!L.ok)throw new Error("Failed to fetch Storybook index");let _=await L.json(),m=_.entries||_.stories||{},k=Object.keys(m).filter(R=>m[R].type==="story").length,C=Object.keys(m).filter(R=>m[R].type==="story"),E=K(),h=await Z(`${E}/api/mappings?projectId=${i}`,{headers:{Authorization:`Bearer ${a}`}}),b=0;if(h.ok){let R=await h.json(),v=R.mappings||R||[];if(Array.isArray(v)){let A=new Set(v.map(B=>B.storyId).filter(Boolean));b=C.filter(B=>A.has(B)).length}else{let A=await Z(`${E}/api/mappings/stats?projectId=${i}`,{headers:{Authorization:`Bearer ${a}`}});if(A.ok){let B=await A.json();b=Math.min(B.mappedStoriesCount||0,k)}}}o({totalStories:k,mappedStories:b,loading:!1})}catch(L){console.error("[FigmaMappingsSection] Error fetching stats:",L),o(_=>({..._,loading:!1}))}},[u,l]=Gu(!1),[c,p]=Gu(!1),g=async()=>{!i||!a||p(!0)},d=async()=>{p(!1),l(!0);try{let L=K(),_=await Z(`${L}/api/mappings?projectId=${i}`,{headers:{Authorization:`Bearer ${a}`}});if(!_.ok)throw new Error("Failed to fetch mappings");let k=(await _.json()).mappings||[];await Promise.all(k.map(C=>Z(`${L}/api/mappings?id=${encodeURIComponent(C.id)}`,{method:"DELETE",headers:{Authorization:`Bearer ${a}`}}))),s()}catch(L){console.error("[FigmaMappingsSection] Unlink all failed:",L)}finally{l(!1)}},f=()=>n(!0),y=()=>{n(!1),i&&a&&s()};if(!i)return kn.createElement(EC,null,kn.createElement(SH,null,"Select a project to link Figma designs"));let{totalStories:I,loading:S}=r,x=Math.min(r.mappedStories,I),M=x===0?"none":x>=I?"complete":"partial",z=I>0?Math.min(100,Math.round(x/I*100)):0,O=M==="none"?"Link designs":"Manage";return kn.createElement(kn.Fragment,null,kn.createElement(EC,null,kn.createElement(gH,null,kn.createElement(fH,null,"Figma mappings"),kn.createElement(mH,null,S?kn.createElement(vH,null,kn.createElement(kH,null),kn.createElement(CH,null,"Loading\u2026")):kn.createElement(kn.Fragment,null,kn.createElement(hH,{state:M},`${x} / ${I}`),x>0&&kn.createElement(wH,{onClick:g,disabled:S||u},u?"Unlinking\u2026":"Unlink all"),kn.createElement(bH,{onClick:f,disabled:S},O)))),!S&&kn.createElement(xH,null,kn.createElement(yH,{percent:z,state:M}))),t&&kn.createElement(TC,{isOpen:t,onClose:y,projectId:i}),kn.createElement(wo,{isOpen:c,title:"Unlink All Mappings",message:`Unlink all ${r.mappedStories} Figma mappings?`,confirmLabel:"Unlink All",variant:"danger",onConfirm:d,onCancel:()=>p(!1)}))};import q,{useState as xi,useEffect as vl,useCallback as l3,useRef as M1}from"react";import{styled as Pt,keyframes as nU}from"storybook/theming";import{addons as rU}from"storybook/manager-api";ke();De();ct();function AC(e){let{loading:t,reloading:n,crawlStatus:r,pagesFailed:o,tries:i,max:a}=e;return t||n||r!=="complete"||(o??0)<=0?!1:i<a}De();import{useEffect as IH,useRef as TH}from"react";import{addons as EH}from"storybook/manager-api";var qu="uicopilot/crawl-started",RH=3e3,AH=360*1e3;function FC(e){let t=TH({});IH(()=>{let n=EH.getChannel?.();if(!n)return;let r=a=>{let s=t.current[a];s&&(clearInterval(s),delete t.current[a])},o=a=>{try{e.addNotification?.(a)}catch{}},i=({projectId:a})=>{if(!a||t.current[a])return;let s=localStorage.getItem("uicopilot_session_token");if(!s)return;let u=K(),l=Date.now(),c=setInterval(async()=>{if(Date.now()-l>AH){r(a);return}try{let p=await fetch(`${u}/api/figma/cache-status?projectId=${a}`,{headers:{Authorization:`Bearer ${s}`}});if(!p.ok)return;let g=await p.json(),d=g?.crawlProgress?.status;if(d==="complete"){r(a);let f=g?.componentSetCount??0;o({id:`uicopilot-crawl-done-${a}-${Date.now()}`,content:{headline:"Figma cache ready",subHeadline:`${f} component set${f===1?"":"s"} cached \u2014 open Settings to map`},duration:8e3})}else d==="error"&&(r(a),o({id:`uicopilot-crawl-error-${a}-${Date.now()}`,content:{headline:"Figma crawl failed",subHeadline:g?.crawlProgress?.error||"Open Settings to retry."},duration:8e3}))}catch{}},RH);t.current[a]=c};return n.on(qu,i),()=>{n.off(qu,i),Object.keys(t.current).forEach(r)}},[e])}import mn,{useState as HH}from"react";import{styled as Er,keyframes as UH}from"storybook/theming";ke();De();ct();He();import{useCallback as FH,useEffect as PH,useState as wl}from"react";var MH=K();function Yu(e,t){let{sessionToken:n}=ye(),[r,o]=wl([]),[i,a]=wl(!1),[s,u]=wl(0),[l,c]=wl(!1),[p,g]=wl(null),d=FH(async()=>{if(!(!e||!n)){c(!0),g(null);try{let f=await Z(`${MH}/api/figma/pages?projectId=${e}`,{headers:{Authorization:`Bearer ${n}`}}),y=await f.json().catch(()=>({}));if(!f.ok||!y.success)throw new Error(y.error||"Couldn't read the file's pages.");o(Array.isArray(y.pages)?y.pages:[]),a(!!y.published),u(y.totalComponentSets??0)}catch(f){w.error("[useFigmaPages] failed to load pages:",f),g(f instanceof Error?f.message:"Couldn't read the file's pages.")}finally{c(!1)}}},[e,n]);return PH(()=>{t&&d()},[t,d]),{pages:r,published:i,totalComponentSets:s,loading:l,error:p,reload:d}}He();import{useEffect as LH,useState as PC}from"react";function BH(e){let t=e,n=t?.entries??t?.stories;if(!n||typeof n!="object")return[];let r=[],o=new Set;for(let i of Object.values(n)){if(!i||typeof i!="object"||i.type&&i.type!=="story")continue;let a=`${i.title??""}|${i.name??""}`;!i.title&&!i.name||o.has(a)||(o.add(a),r.push({name:i.name,title:i.title}))}return r}function Ku(){let[e,t]=PC([]),[n,r]=PC(!1);return LH(()=>{let o=!1;return(async()=>{try{let i=await fetch("/index.json");if(!i.ok)throw new Error(`index.json returned ${i.status}`);let a=BH(await i.json());o||t(a)}catch(i){w.debug("[useStoryNames] could not read story index:",i instanceof Error?i.message:i)}finally{o||r(!0)}})(),()=>{o=!0}},[]),{stories:e,ready:n}}import Et,{useEffect as OH,useMemo as i3,useRef as $H,useState as a3}from"react";on();function Ga(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"")}function zH(e){let t=Vv(e.title,e.name).trim();return t&&Ga(t).length>=3?[t]:[]}function MC(e){return e.length>3&&/(s|x|z|ch|sh)es$/.test(e)?e.slice(0,-2):e.length>3&&e.endsWith("s")?e.slice(0,-1):e}function DH(e,t){let n=Ga(e),r=Ga(t);return!n||!r?!1:MC(n)===MC(r)}function Xu(e,t){if(!e.length||!t.length)return[];let n=[],r=new Set;for(let i of t)for(let a of zH(i)){let s=Ga(a);r.has(s)||(r.add(s),n.push(a))}let o=[];for(let i of e){let a=null;for(let s of n)DH(i.name,s)&&(!a||Ga(s).length>Ga(a).length)&&(a=s);a&&o.push({pageId:i.id,matchedBy:a})}return o}var I1="uicopilot_figma_pages:";function LC(e,t,n,r){let o=new Set(e.map(i=>i.id));if(n?.length){let i=n.filter(a=>o.has(a));if(i.length)return i}if(t){let i=e.filter(a=>a.componentCount>0).map(a=>a.id);if(i.length)return i}if(r?.length){let i=Xu(e,r).map(a=>a.pageId);if(i.length)return i}return[]}function qa(e){try{let t=localStorage.getItem(I1+e);if(!t)return;let n=JSON.parse(t);if(Array.isArray(n)&&n.every(r=>typeof r=="string"))return n}catch{}}function Ju(e,t){try{localStorage.setItem(I1+e,JSON.stringify(t))}catch{}}function BC(e){try{localStorage.removeItem(I1+e)}catch{}}import Qu from"react";import{styled as zC}from"storybook/theming";var _H=zC.span(({state:e})=>({width:"16px",height:"16px",borderRadius:"4px",flex:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",border:e==="none"?`1.5px solid ${te.locked}`:"none",background:e==="none"?te.card:W})),NH=zC.span({width:"8px",height:"2px",background:te.card,borderRadius:"2px"}),T1=({state:e})=>Qu.createElement(_H,{state:e},e==="all"&&Qu.createElement("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:te.card,strokeWidth:"3.4","aria-hidden":!0},Qu.createElement("path",{d:"M5 13l4 4L19 7"})),e==="some"&&Qu.createElement(NH,null));import Ya from"react";import{styled as Jt}from"storybook/theming";var DC='ui-monospace, "SF Mono", Menlo, Consolas, monospace',E1=te.formBg,Zu=Jt.div({marginTop:"10px",border:`1px solid ${te.border}`,borderRadius:"6px",overflow:"hidden",background:te.card}),_C=Jt.div({display:"flex",alignItems:"center",justifyContent:"space-between",height:"32px",padding:"0 12px",borderBottom:`1px solid ${te.border}`}),NC=Jt.span({fontSize:"10px",fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",color:te.muted}),R1=Jt.button({border:"none",background:"none",padding:0,cursor:"pointer",fontSize:"11px",color:te.muted,"&:hover":{color:te.text}}),OC=Jt.div({display:"flex",alignItems:"center",justifyContent:"space-between",height:"32px",padding:"0 12px",background:E1,borderBottom:`1px solid ${te.border}`}),$C=Jt.span({fontSize:"11px",fontWeight:500,color:te.text}),HC=Jt.span({fontSize:"10.5px",color:te.muted,fontFamily:DC,fontVariantNumeric:"tabular-nums"}),UC=Jt.div({position:"relative",padding:"6px 12px",borderBottom:`1px solid ${te.border}`}),jC=Jt.span({position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:te.muted,display:"inline-flex",pointerEvents:"none"}),VC=Jt.input({width:"100%",height:"28px",paddingLeft:"20px",border:"none",outline:"none",background:"transparent",fontSize:"12px",color:te.text,"&::placeholder":{color:te.muted}}),WC=Jt.button({width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",height:"32px",padding:"0 12px",border:"none",borderBottom:`1px solid ${te.border}`,background:te.accentTint,cursor:"pointer","&:hover":{filter:"brightness(0.97)"}}),A1=Jt.span({display:"inline-flex",alignItems:"center",gap:"10px",minWidth:0}),GC=Jt.span({fontSize:"12px",fontWeight:500,color:te.text}),F1=Jt.span({fontSize:"11px",color:te.muted,fontFamily:DC,fontVariantNumeric:"tabular-nums",flex:"none"}),qC=Jt.div({maxHeight:"180px",overflowY:"auto"}),YC=Jt.button({width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",height:"32px",padding:"0 12px",border:"none",borderBottom:`1px solid ${te.track}`,background:"transparent",cursor:"pointer","&:last-of-type":{borderBottom:"none"},"&:hover":{background:E1}}),KC=Jt.span(({added:e})=>({fontSize:"12px",color:e?W:te.text,fontWeight:e?500:400,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),XC=Jt.span({fontSize:"10px",color:W,flex:"none"}),JC=Jt.div({display:"flex",alignItems:"center",justifyContent:"space-between",gap:"12px",padding:"8px 12px",borderTop:`1px solid ${te.border}`,background:E1}),QC=Jt.p({margin:0,fontSize:"10.5px",lineHeight:1.35,color:te.muted}),ZC=Jt.button(({disabled:e})=>({flex:"none",height:"28px",padding:"0 12px",border:"none",borderRadius:"6px",fontSize:"11px",fontWeight:600,color:te.card,background:W,cursor:e?"not-allowed":"pointer",opacity:e?.5:1,whiteSpace:"nowrap","&:hover":e?{}:{opacity:.9}})),ed=Jt.div({padding:"16px 12px",fontSize:"12px",color:te.muted,textAlign:"center"}),e3=Jt.div(({theme:e,tone:t})=>({display:"flex",alignItems:"center",gap:"8px",padding:`${e.layoutMargin*.8}px ${e.layoutMargin*1.2}px`,borderBottom:`1px solid ${e.appBorderColor}`,backgroundColor:t==="warn"?`${e.color.warning}14`:`${W}12`,fontSize:e.typography.size.s1,color:e.color.defaultText})),t3=Jt.span(({theme:e,tone:t})=>({width:"16px",height:"16px",borderRadius:"4px",flex:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"10px",fontWeight:e.typography.weight.bold,color:e.color.lightest,backgroundColor:t==="warn"?e.color.warning:W})),n3=Jt.span({lineHeight:1.4}),r3=Jt.span(({theme:e})=>({fontSize:"10px",fontFamily:e.typography.fonts.mono,color:W,backgroundColor:`${W}14`,padding:"1px 6px",borderRadius:"10px",flex:"none",maxWidth:"140px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}));var o3=({value:e,onChange:t,total:n})=>Ya.createElement(UC,null,Ya.createElement(jC,null,Ya.createElement("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":!0},Ya.createElement("circle",{cx:"11",cy:"11",r:"7"}),Ya.createElement("path",{d:"m21 21-4-4"}))),Ya.createElement(VC,{type:"text",value:e,onChange:r=>t(r.target.value),placeholder:`Filter ${n} pages\u2026`,"aria-label":"Filter pages"}));var td=({pages:e,published:t,loading:n,error:r,busy:o,initialSelection:i,stories:a,ctaVerb:s="Import",highlightAdded:u=!1,emptyHint:l,onReload:c,onCancel:p,onImport:g})=>{let[d,f]=a3(new Set),[y,I]=a3(""),S=$H("");OH(()=>{if(!e.length)return;let v=e.map(A=>A.id).join(",");v!==S.current&&(S.current=v,f(new Set(LC(e,t,i,a))))},[e,t,i,a]);let x=i3(()=>a?.length?Xu(e,a):[],[e,a]),M=i3(()=>new Map(x.map(v=>[v.pageId,v.matchedBy])),[x]);if(n)return Et.createElement(Zu,null,Et.createElement(ed,null,"Reading your file\u2019s pages\u2026"));if(r)return Et.createElement(Zu,null,Et.createElement(ed,null,"\u26A0 ",r," ",Et.createElement(R1,{onClick:c},"Retry")));let z=!t&&!!a?.length,O=z&&x.length===0,L=e.length>0&&d.size===e.length,_=d.size>0&&!L,m=d.size,k=e.filter(v=>d.has(v.id)).reduce((v,A)=>v+A.componentCount,0),C=v=>f(A=>{let B=new Set(A);return B.has(v)?B.delete(v):B.add(v),B}),E=()=>f(L?new Set:new Set(e.map(v=>v.id))),h=y.trim().toLowerCase(),b=h?e.filter(v=>v.name.toLowerCase().includes(h)):e,R=M.size?[...b.filter(v=>M.has(v.id)),...b.filter(v=>!M.has(v.id))]:b;return Et.createElement(Zu,null,Et.createElement(_C,null,Et.createElement(NC,null,"Choose pages to import"),p&&Et.createElement(R1,{onClick:p},"Cancel")),z&&Et.createElement(e3,{tone:O?"warn":"ok"},Et.createElement(t3,{tone:O?"warn":"ok"},O?"!":"\u2713"),Et.createElement(n3,null,O?"Couldn\u2019t match your stories to page names \u2014 choose the pages you need.":`Matched ${x.length} ${x.length===1?"page":"pages"} to your Storybook.`)),Et.createElement(OC,null,Et.createElement($C,null,e.length," pages"),Et.createElement(HC,null,m," selected",t?` \xB7 ~${k} components`:"")),Et.createElement(o3,{value:y,onChange:I,total:e.length}),Et.createElement(WC,{type:"button",onClick:E},Et.createElement(A1,null,Et.createElement(T1,{state:L?"all":_?"some":"none"}),Et.createElement(GC,null,"Select all")),Et.createElement(F1,null,e.length," pages")),Et.createElement(qC,null,R.length===0?Et.createElement(ed,null,"No pages match \u201C",y,"\u201D."):R.map(v=>{let A=u&&d.has(v.id)&&!(i??[]).includes(v.id);return Et.createElement(YC,{key:v.id,type:"button",onClick:()=>C(v.id)},Et.createElement(A1,null,Et.createElement(T1,{state:d.has(v.id)?"all":"none"}),Et.createElement(KC,{added:A},v.name),A&&Et.createElement(XC,null,"\xB7 just added"),M.has(v.id)&&Et.createElement(r3,{title:`Matches your story "${M.get(v.id)}"`},M.get(v.id))),t&&Et.createElement(F1,null,v.componentCount))})),Et.createElement(JC,null,Et.createElement(QC,null,m===0&&l?l:m===0&&O?"Pick the pages holding the components you want to review. Importing every page may exceed Figma\u2019s rate limit.":"Selected pages are fetched at full depth via the Figma API."),Et.createElement(ZC,{type:"button",disabled:m===0||o,onClick:()=>g([...d])},o?"Starting\u2026":`${s} ${m} ${m===1?"page":"pages"}`)))};var P1=Er.div({marginTop:"10px"}),jH=Er.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"12px",padding:"11px 13px",border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius*1.5})),VH=Er.div({minWidth:0,flex:1}),WH=Er.div(({theme:e})=>({fontSize:e.typography.size.s2,color:e.color.defaultText,"& b":{color:W}})),GH=Er.div(({theme:e})=>({marginTop:"2px",fontSize:e.typography.size.s1,color:e.color.mediumdark,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),qH=Er.button(({theme:e})=>({flex:"none",display:"inline-flex",alignItems:"center",gap:"6px",height:"28px",padding:"0 10px",border:`1px solid ${W}`,borderRadius:e.appBorderRadius*1.5,background:"transparent",color:W,fontSize:e.typography.size.s1,fontWeight:e.typography.weight.bold,fontFamily:e.typography.fonts.base,cursor:"pointer",whiteSpace:"nowrap","&:hover":{background:`${W}14`}})),YH=UH`from { transform: rotate(0deg); } to { transform: rotate(360deg); }`,KH=Er.div(({theme:e})=>({padding:"11px 13px",border:`1px solid ${e.appBorderColor}`,borderRadius:e.appBorderRadius*1.5,backgroundColor:e.background.content})),XH=Er.div({display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"}),JH=Er.span(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:"6px",fontSize:e.typography.size.s2,color:e.color.defaultText})),QH=Er.span({display:"inline-block",width:"12px",height:"12px",border:`1.5px solid ${W}40`,borderTopColor:W,borderRadius:"50%",animation:`${YH} 0.7s linear infinite`}),ZH=Er.span(({theme:e})=>({fontFamily:e.typography.fonts.mono,fontSize:e.typography.size.s1,color:e.color.mediumdark})),eU=Er.div(({theme:e})=>({marginTop:"8px",height:"4px",borderRadius:"2px",backgroundColor:e.appBorderColor,overflow:"hidden"})),tU=Er.div(({pct:e})=>({width:`${e}%`,height:"100%",backgroundColor:W,transition:"width 0.3s ease"})),s3=({projectId:e,busy:t,importing:n=!1,importPct:r=0,onReimport:o})=>{let[i,a]=HH(!1),s=Yu(e,!0),u=Ku(),l=qa(e);if(n)return mn.createElement(P1,null,mn.createElement(KH,null,mn.createElement(XH,null,mn.createElement(JH,null,mn.createElement(QH,null),"Re-reading components from Figma\u2026"),mn.createElement(ZH,null,r,"%")),mn.createElement(eU,null,mn.createElement(tU,{pct:r}))));if(i)return mn.createElement(P1,null,mn.createElement(td,{stories:u.stories,pages:s.pages,published:s.published,loading:s.loading,error:s.error,busy:t,initialSelection:l,ctaVerb:"Re-import",highlightAdded:!0,emptyHint:"Select at least one page \u2014 or use Clear (above) to remove everything.",onReload:s.reload,onCancel:()=>a(!1),onImport:f=>{Ju(e,f),o(f),a(!1)}}));let c=s.pages.length,p=l?.length??0,g=l?.length&&s.pages.length?s.pages.find(f=>l.includes(f.id))?.name:void 0,d=c>p?c-p:0;return mn.createElement(P1,null,mn.createElement(jH,null,mn.createElement(VH,null,mn.createElement(WH,null,p>0?mn.createElement(mn.Fragment,null,"Importing"," ",mn.createElement("b",null,p,c?` of ${c}`:""," ",p===1&&!c?"page":"pages")):"Choose which pages to import"),g&&mn.createElement(GH,null,g,d>0?` \xB7 ${d} pages not imported`:"")),mn.createElement(qH,{onClick:()=>a(!0)},mn.createElement("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":!0},mn.createElement("path",{d:"M12 5v14M5 12h14"})),"Add or change pages")))};var L1=Pt.div(({theme:e})=>({padding:"12px 16px",backgroundColor:e.background.content,fontSize:"12px"})),B1=Pt.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),z1=Pt.span(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:"8px",fontSize:"10px",fontWeight:e.typography.weight.bold,letterSpacing:"0.06em",textTransform:"uppercase",color:e.color.mediumdark})),h0e=Pt(mo)({padding:"5px 12px",fontSize:"12px"}),oU=Pt.dl(({theme:e})=>({display:"grid",gridTemplateColumns:"repeat(4, 1fr)",margin:"0 0 8px",borderRadius:e.appBorderRadius,backgroundColor:e.background.hoverable,overflow:"hidden"})),nd=Pt.div({padding:"8px 10px",minWidth:0}),c3=Pt.div(({theme:e})=>({fontSize:"12px",color:e.color.mediumdark,padding:"4px 0"})),iU=Pt.div({display:"flex",flexDirection:"column",gap:"6px",marginTop:"6px"}),aU=Pt.div({display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"}),sU=Pt.div({display:"flex",alignItems:"center",gap:"8px"}),lU=Pt.span(({theme:e})=>({fontSize:"12px",color:e.color.defaultText})),cU=Pt.span(({theme:e})=>({fontFamily:e.typography.fonts.mono,color:e.color.defaultText})),uU=Pt.span(({theme:e,ready:t})=>({display:"inline-flex",alignItems:"center",gap:"4px",padding:"1px 6px",borderRadius:"3px",fontSize:"9px",fontWeight:e.typography.weight.bold,textTransform:"uppercase",letterSpacing:"0.06em",backgroundColor:t?`${e.color.positive}1a`:e.background.hoverable,color:t?e.color.positive:e.color.mediumdark})),dU=Pt.button(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:"4px",padding:0,border:"none",background:"transparent",cursor:"pointer",fontSize:"11px",color:e.color.mediumdark,transition:"color 0.15s","&:hover":{color:e.color.defaultText},"&:disabled":{opacity:.5,cursor:"not-allowed"}})),pU=Pt.div(({theme:e})=>({width:"100%",height:"4px",borderRadius:"2px",backgroundColor:e.appBorderColor,overflow:"hidden"})),gU=Pt.div(({theme:e,pct:t,ready:n})=>({width:`${t}%`,height:"100%",borderRadius:"2px",backgroundColor:n?e.color.positive:e.color.secondary,transition:"width 0.3s ease"})),rd=Pt.dt(({theme:e})=>({fontSize:"9px",fontWeight:e.typography.weight.bold,letterSpacing:"0.06em",textTransform:"uppercase",color:e.color.mediumdark,whiteSpace:"nowrap"})),od=Pt.dd(({theme:e,plain:t})=>({margin:"2px 0 0",fontSize:"12px",color:e.color.defaultText,fontFamily:t?e.typography.fonts.base:e.typography.fonts.mono,whiteSpace:"nowrap"})),fU=Pt.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})),g3=nU`
|
|
89
89
|
from { transform: rotate(0deg); }
|
|
90
90
|
to { transform: rotate(360deg); }
|
|
91
|
-
`,u3=Pt.span(({theme:e,tone:t})=>({display:"inline-flex",alignItems:"center",gap:"4px",padding:"1px 6px",borderRadius:"3px",fontSize:"9px",fontWeight:e.typography.weight.bold,textTransform:"uppercase",letterSpacing:"0.05em",backgroundColor:t==="green"?`${e.color.positive}1a`:`${W}1a`,color:t==="green"?e.color.positive:W})),mU=Pt.span({display:"inline-block",width:"10px",height:"10px",border:`1.5px solid ${W}40`,borderTopColor:W,borderRadius:"50%",animation:`${g3} 0.6s linear infinite`}),hU=()=>q.createElement("svg",{viewBox:"0 0 24 24",width:"10",height:"10",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0},q.createElement("path",{d:"M20 6 9 17l-5-5"})),D1=Pt.button(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:"4px",height:"25px",padding:"2px 8px",border:"none",background:"transparent",borderRadius:e.appBorderRadius,cursor:"pointer",fontSize:"11px",fontFamily:e.typography.fonts.base,color:e.color.mediumdark,transition:"all 0.15s","&:hover:not(:disabled)":{color:e.color.defaultText,backgroundColor:e.background.hoverable},"&:disabled":{opacity:.5,cursor:"not-allowed"}})),_1=Pt.span({display:"inline-block",width:"10px",height:"10px",border:"1.5px solid currentColor",borderTopColor:"transparent",borderRadius:"50%",opacity:.6,animation:`${g3} 0.6s linear infinite`}),xU=()=>q.createElement("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"currentColor","aria-hidden":!0},q.createElement("path",{d:"M12 2.5l1.6 5.9 5.9 1.6-5.9 1.6L12 17.5l-1.6-5.9L4.5 10l5.9-1.6z"})),yU=()=>q.createElement("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0},q.createElement("path",{d:"M23 4v6h-6M1 20v-6h6"}),q.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"})),bU=Pt.div(({theme:e})=>({marginTop:"6px",padding:"6px 8px",backgroundColor:e.background.hoverable,borderRadius:"4px",color:e.color.mediumdark,lineHeight:"1.4"})),N1=Pt.span(({theme:e,type:t})=>({fontWeight:500,color:t==="added"?e.color.positive:t==="removed"?e.color.negative:e.color.warning})),Sl=Pt.div(({theme:e})=>({marginTop:"8px",padding:"8px 10px",backgroundColor:`${e.color.negative}1a`,border:`1px solid ${e.color.negative}4d`,borderRadius:"4px",fontSize:"12px",color:e.color.negative,lineHeight:"1.4"})),wU=Pt.div(({theme:e})=>({marginTop:"8px",padding:"8px 10px",backgroundColor:`${e.color.warning}1a`,border:`1px solid ${e.color.warning}4d`,borderRadius:"4px",fontSize:"12px",color:e.color.warning,lineHeight:"1.4"})),vU=Pt.div(({theme:e})=>({marginTop:"8px",padding:"8px 10px",backgroundColor:`${e.color.positive}1a`,border:`1px solid ${e.color.positive}4d`,borderRadius:"4px",fontSize:"12px",color:e.color.positive,lineHeight:"1.4"})),SU=Pt.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",marginTop:"8px",padding:"6px 8px",borderRadius:e.appBorderRadius,backgroundColor:e.background.hoverable,fontSize:"11px",lineHeight:"1.4",color:e.color.defaultText})),Ka=Pt.div(({theme:e})=>({width:"100%",height:"8px",backgroundColor:e.appBorderColor,borderRadius:"4px",overflow:"hidden",marginTop:"10px"})),Xa=Pt.div(({percent:e})=>({width:`${e}%`,height:"100%",backgroundColor:W,borderRadius:"3px",transition:"width 0.5s ease"})),Yi=Pt.div(({theme:e})=>({display:"flex",justifyContent:"space-between",marginTop:"6px",fontSize:"12px",fontWeight:500,color:e.color.defaultText})),d3=new Set,p3=new Map,kU=2,f3=()=>{let{userRole:e,featureFlags:t}=ge(),[n,r]=xi(null),[o,i]=xi(!0),[a,s]=xi(!1),[u,l]=xi(null),[c,p]=xi(null),[g,d]=xi(!1),[f,y]=xi(!1),[I,S]=xi(!1),{selectedProjectId:x,projects:M}=Ke(),{sessionToken:z}=ye(),O=M1(null),L=M1(null),_=M1(null),m=l3(()=>{O.current&&(clearInterval(O.current),O.current=null),L.current&&(clearInterval(L.current),L.current=null),_.current&&(clearTimeout(_.current),_.current=null)},[]);vl(()=>m,[m]);let k=l3(async()=>{if(!(!x||!z))try{let j=K(),Y=await Z(`${j}/api/figma/cache-status?projectId=${x}`,{headers:{Authorization:`Bearer ${z}`}});if(Y.ok){let J=await Y.json();r(J)}}catch(j){console.error("[FigmaCacheSection] Error:",j)}finally{i(!1)}},[x,z]);vl(()=>{k()},[k]),vl(()=>{if(o||a||!n||n.structureStatus!=="none"||!x||d3.has(x))return;let j=M.find(J=>J.id===x);(j?.figmaFileUrl||j?.figmaFileId)&&(d3.add(x),C())},[o,a,n?.structureStatus,x,M]),vl(()=>{if(!x)return;let j=p3.get(x)??0;AC({loading:o,reloading:a,crawlStatus:n?.crawlProgress?.status,pagesFailed:n?.crawlProgress?.pagesFailed,tries:j,max:kU})&&(p3.set(x,j+1),C())},[o,a,n?.crawlProgress?.status,n?.crawlProgress?.pagesFailed,x]),vl(()=>{let j=n?.thumbnailProgress?.status,Y=n?.enrichmentProgress?.status,J=n?.thumbnailProgress?.cached??0,ne=n?.thumbnailProgress?.total??0,Re=j==="in-progress"||j==="pending"||ne>0&&J<ne,be=Y==="in-progress"||Y==="pending",fe=!n?.thumbnailProgress&&n?.structureStatus==="cached",Me=n?.crawlProgress?.status==="crawling"||n?.crawlProgress?.status==="cancelling";if(!(Me||Re||be||fe)||!Me&&(!n||n.structureStatus==="none"))return;let ze=setInterval(()=>{k()},3e3);return()=>{clearInterval(ze)}},[n?.thumbnailProgress?.status,n?.thumbnailProgress?.cached,n?.thumbnailProgress?.total,n?.enrichmentProgress?.status,n?.crawlProgress?.status,n?.structureStatus,k]);let C=async j=>{if(!x||!z)return;let Y=Array.isArray(j)?j:void 0;s(!0),l(null),p(null);try{let J=K(),ne=await Z(`${J}/api/figma/crawl`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${z}`},body:JSON.stringify(Y?.length?{projectId:x,pageIds:Y}:{projectId:x})});if(!ne.ok){if(ne.status===403){let be=await ne.json().catch(()=>({}));l(be.requiresAuth?"auth":"generic")}else l("generic");return}let Re=await ne.json().catch(()=>({}));if(Re?.status==="skipped-unchanged")p("Figma file unchanged \u2014 reused cached structure.");else if(Re?.status==="crawl-started"||Re?.status==="retry-started"){if(Re?.status==="retry-started"){let be=Re.retryPages;p(`Retrying ${be?`${be} `:""}page${be===1?"":"s"} that hit Figma's rate limit\u2026`)}try{rU.getChannel()?.emit(qu,{projectId:x})}catch{}}await k()}catch(J){console.error("[FigmaCacheSection] Crawl start error:",J),l("generic")}finally{s(!1)}},E=async()=>{if(!(!x||!z)){d(!0);try{let j=K(),Y=await Z(`${j}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${z}`},body:JSON.stringify({projectId:x})});if(console.log("[FigmaCacheSection] Cache invalidate response:",Y.status),!Y.ok){l("generic");return}await Z(`${j}/api/figma/frames/invalidate?projectId=${x}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${z}`}}).catch(()=>{}),x&&BC(x),r({structureStatus:"none",structureCachedAt:null,componentSetCount:0,componentCount:0,pageCount:0,pages:[],cacheDiff:null,thumbnailProgress:null,enrichmentProgress:null,crawlProgress:null})}catch(j){console.error("[FigmaCacheSection] Clear cache error:",j)}finally{d(!1)}}},h=async()=>{if(!(!x||!z)){m(),y(!0);try{let j=K();await Z(`${j}/api/figma/enrich`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${z}`},body:JSON.stringify({projectId:x})}),O.current=setInterval(async()=>{await k()},3e3),L.current=setInterval(()=>{(n?.enrichmentProgress?.status==="complete"||n?.enrichmentProgress?.status==="error")&&(m(),y(!1),k())},3e3),_.current=setTimeout(()=>{m(),y(!1)},6e5)}catch(j){console.error("[FigmaCacheSection] Enrich error:",j),m(),y(!1)}}},b=async()=>{if(!(!x||!z)){S(!0);try{let j=K();await Z(`${j}/api/figma/cancel`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${z}`},body:JSON.stringify({projectId:x})}),await k()}catch(j){console.error("[FigmaCacheSection] Cancel error:",j)}finally{S(!1),y(!1),s(!1)}}},R=n?.crawlProgress?.status==="crawling"||n?.crawlProgress?.status==="cancelling"||n?.thumbnailProgress?.status==="in-progress"||n?.enrichmentProgress?.status==="in-progress";if(!x)return null;if(o)return q.createElement(L1,null,q.createElement(B1,null,q.createElement(z1,null,"Figma Sync")),q.createElement(c3,null,"Loading sync status\u2026"),q.createElement(Ka,null,q.createElement(Xa,{percent:100,style:{opacity:.3}})));if(!n||n.structureStatus==="none")return q.createElement(L1,null,q.createElement(B1,null,q.createElement(z1,null,"Figma Sync"),q.createElement(So,{loading:a,onClick:C,loadingText:"Loading..."},"\u21BB Load")),n?.crawlProgress?.status==="crawling"?q.createElement(q.Fragment,null,q.createElement(Ka,null,q.createElement(Xa,{percent:(n.crawlProgress.pagesTotal??0)>0?Math.round(n.crawlProgress.pagesDone/n.crawlProgress.pagesTotal*100):100,style:(n.crawlProgress.pagesTotal??0)>0?void 0:{opacity:.3}})),q.createElement(Yi,null,q.createElement("span",null,"Reading components from Figma\u2026"),q.createElement("span",null,(n.crawlProgress.pagesTotal??0)>0?`page ${n.crawlProgress.pagesDone} of ${n.crawlProgress.pagesTotal}`:"starting\u2026"))):a?q.createElement(q.Fragment,null,q.createElement(Ka,null,q.createElement(Xa,{percent:100,style:{animation:"none",opacity:.3}})),q.createElement(Yi,null,q.createElement("span",null,"Starting crawl\u2026"))):q.createElement(c3,null,"No cache \u2014 click Load to fetch from Figma"),n?.crawlProgress?.status==="error"&&q.createElement(Sl,null,"Crawl failed",n.crawlProgress.error?`: ${n.crawlProgress.error}`:"",". Try Load again."),u==="auth"&&q.createElement(Sl,null,"Figma authentication expired \u2014 reconnect your Figma account in the Figma Integration section above."),u==="generic"&&q.createElement(Sl,null,"Failed to load Figma cache. Check the browser console for details."));let v=j=>{let Y=Date.now()-new Date(j).getTime(),J=Math.floor(Y/6e4);if(J<1)return"just now";if(J<60)return`${J}m ago`;let ne=Math.floor(J/60);return ne<24?`${ne}h ago`:`${Math.floor(ne/24)}d ago`},A=j=>j>=1024*1024*1024?`${(j/1024/1024/1024).toFixed(1)} GB`:j>=1024*1024?`${Math.round(j/1024/1024)} MB`:`${Math.max(1,Math.round(j/1024))} KB`,B=n.crawlProgress?.bytesDownloaded,P=n.cacheDiff,N=P&&(P.added.length>0||P.removed.length>0||P.renamed.length>0),T=n.crawlProgress,D=T?.pagesTotal??0,H=T?.pagesDone??0,F=T?.status==="crawling"||a,re=D>0?Math.round(H/D*100):a?8:0;return q.createElement(L1,null,q.createElement(B1,null,q.createElement(z1,null,"Figma Sync"," ",n.crawlProgress?.status==="crawling"?q.createElement(u3,{tone:"orange"},q.createElement(mU,null),"Importing"):n.structureStatus==="cached"?q.createElement(u3,{tone:"green"},q.createElement(hU,null),"Synced"):q.createElement(fU,{status:n.structureStatus},n.structureStatus)),q.createElement("div",{style:{display:"flex",gap:"2px"}},e==="admin"&&q.createElement(D1,{onClick:h,disabled:f},f?q.createElement(_1,null):q.createElement(xU,null),f?"Enriching\u2026":"Enrich"),q.createElement(D1,{onClick:E,disabled:g},g&&q.createElement(_1,null),g?"Clearing\u2026":"Clear"),q.createElement(D1,{onClick:()=>C(x?qa(x):void 0),disabled:a},a?q.createElement(_1,null):q.createElement(yU,null),a?"Reloading\u2026":"Reload"),R&&q.createElement(So,{loading:I||n?.crawlProgress?.status==="cancelling",onClick:b,variant:"ghost",loadingText:"Stopping..."},"\u2715 Stop"))),n?.crawlProgress?.status==="crawling"&&!((n.crawlProgress.pagesTotal??0)>0&&n.crawlProgress.pagesDone>=n.crawlProgress.pagesTotal)&&q.createElement(q.Fragment,null,q.createElement(Ka,null,q.createElement(Xa,{percent:(n.crawlProgress.pagesTotal??0)>0?Math.round(n.crawlProgress.pagesDone/n.crawlProgress.pagesTotal*100):100,style:(n.crawlProgress.pagesTotal??0)>0?void 0:{opacity:.3}})),q.createElement(Yi,null,q.createElement("span",null,"Re-reading components from Figma\u2026"),q.createElement("span",null,(n.crawlProgress.pagesTotal??0)>0?`page ${n.crawlProgress.pagesDone} of ${n.crawlProgress.pagesTotal}`:"starting\u2026"))),a&&n?.crawlProgress?.status!=="crawling"&&q.createElement(Yi,null,q.createElement("span",null,"Starting crawl\u2026")),u==="auth"&&q.createElement(Sl,null,"Figma authentication expired \u2014 reconnect your Figma account in the Figma Integration section above."),u==="generic"&&q.createElement(Sl,null,"Failed to reload Figma sync. Check the browser console for details."),q.createElement(oU,null,q.createElement(nd,null,q.createElement(rd,null,"Component sets"),q.createElement(od,null,n.componentSetCount)),q.createElement(nd,null,q.createElement(rd,null,"Pages"),q.createElement(od,null,n.pageCount)),typeof B=="number"&&B>0&&q.createElement(nd,null,q.createElement(rd,null,"Size"),q.createElement(od,null,"\u2248 ",A(B))),n.structureCachedAt&&q.createElement(nd,null,q.createElement(rd,null,"Updated"),q.createElement(od,{plain:!0},v(n.structureCachedAt)))),q.createElement(SU,null,q.createElement("span",{"aria-hidden":!0},"\u2139\uFE0F"),q.createElement("span",null,q.createElement("strong",null,"Components only")," for now \u2014 plain Figma frames aren't indexed yet (support planned).")),x&&q.createElement(s3,{projectId:x,busy:a,importing:F,importPct:re,onReimport:C}),n.crawlProgress?.status==="complete"&&n.crawlProgress.pagesFailed>0&&q.createElement(wU,null,"\u26A0 ",n.crawlProgress.pagesFailed," of"," ",n.crawlProgress.pagesTotal," pages couldn\u2019t be read (Figma rate limit) \u2014 some components may be missing. Reload to retry."),c&&q.createElement(vU,null,"\u2713 ",c),N&&q.createElement(bU,null,"Since last reload:"," ",P.added.length>0&&q.createElement(N1,{type:"added"},"+",P.added.length," added"),P.added.length>0&&P.removed.length>0&&" \xB7 ",P.removed.length>0&&q.createElement(N1,{type:"removed"},"\u2212",P.removed.length," removed"),(P.added.length>0||P.removed.length>0)&&P.renamed.length>0&&" \xB7 ",P.renamed.length>0&&q.createElement(N1,{type:"renamed"},P.renamed.length," renamed")),n.thumbnailProgress&&n.thumbnailProgress.status==="in-progress"&&q.createElement(q.Fragment,null,q.createElement(Ka,null,q.createElement(Xa,{percent:n.thumbnailProgress.total>0?Math.round(n.thumbnailProgress.cached/n.thumbnailProgress.total*100):0})),q.createElement(Yi,null,q.createElement("span",null,"Preparing thumbnails\u2026",n.thumbnailProgress.currentName&&q.createElement(q.Fragment,null," ",n.thumbnailProgress.currentName)),q.createElement("span",null,n.thumbnailProgress.cached,"/",n.thumbnailProgress.total))),n.thumbnailProgress?.status!=="in-progress"&&(()=>{let j=n.thumbnailProgress,Y=j?.cached??0,J=j?.total??0,ne=J>0&&Y>=J,Re=J>0&&Y<J,be=J>0?Math.min(100,Math.round(Y/J*100)):0;return q.createElement(iU,null,q.createElement(aU,null,q.createElement(sU,null,q.createElement(lU,null,"Thumbnails",J>0&&q.createElement(q.Fragment,null," ",q.createElement(cU,null,Y," / ",J))),q.createElement(uU,{ready:ne},ne?"\u2713 Ready":Re?"Partial":"Not generated")),q.createElement(dU,{onClick:C,disabled:a},"\u21BB ",ne?"Rebuild":"Reload")),J>0&&q.createElement(pU,null,q.createElement(gU,{pct:ne?100:be,ready:ne})))})(),n.enrichmentProgress&&n.enrichmentProgress.status==="in-progress"&&q.createElement(q.Fragment,null,q.createElement(Ka,null,q.createElement(Xa,{percent:n.enrichmentProgress.total>0?Math.round(n.enrichmentProgress.enriched/n.enrichmentProgress.total*100):0})),q.createElement(Yi,null,q.createElement("span",null,"AI descriptions: generating\u2026",n.enrichmentProgress.currentName&&q.createElement(q.Fragment,null," ",n.enrichmentProgress.currentName)),q.createElement("span",null,n.enrichmentProgress.enriched," of"," ",n.enrichmentProgress.total," component sets"))),n.enrichmentProgress&&n.enrichmentProgress.status==="complete"&&q.createElement(q.Fragment,null,q.createElement(Yi,null,q.createElement("span",null,"AI descriptions: ",n.enrichmentProgress.enriched," of"," ",n.enrichmentProgress.total," component sets \u2713"))),n.enrichmentProgress&&n.enrichmentProgress.status==="in-progress"&&t.showCosts&&n.enrichmentProgress.costUsd!=null&&n.enrichmentProgress.costUsd>0&&q.createElement("div",{style:{marginTop:"6px"}},q.createElement($u,{inputTokens:n.enrichmentProgress.inputTokens||0,outputTokens:n.enrichmentProgress.outputTokens||0,costUsd:n.enrichmentProgress.costUsd,compact:!0})))};import zt,{useState as Ja}from"react";import{styled as ko}from"storybook/theming";ke();De();ct();var O1=ko.div({padding:"12px 16px"}),CU=ko.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),m3=ko.label(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),h3=ko.button(({theme:e})=>({background:"none",border:"none",fontSize:"12px",color:W,cursor:"pointer",padding:0,"&:hover":{textDecoration:"underline"}})),IU=ko.div({display:"flex",gap:"8px",alignItems:"center"}),TU=ko.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:W,boxShadow:`0 0 0 1px ${W}`},"&::placeholder":{color:e.color.mediumlight,fontFamily:"inherit"}})),x3=ko.span(({theme:e,variant:t})=>({fontSize:"12px",color:t==="success"?e.color.positive:t==="error"?e.color.negative:e.color.mediumdark,marginTop:"6px",display:"block",lineHeight:1.4})),EU=ko.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,marginTop:"8px",lineHeight:1.5,"& a":{color:W,textDecoration:"none","&:hover":{textDecoration:"underline"}},"& ol":{margin:"4px 0 0 16px",padding:0},"& li":{marginBottom:"2px"}})),RU=ko.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})),AU=ko.button(({theme:e})=>({background:"none",border:"none",fontSize:"11px",color:"#dc2626",cursor:"pointer",marginLeft:"auto","&:hover":{textDecoration:"underline"}})),y3=({onConnected:e,defaultExpanded:t=!1})=>{let{sessionToken:n}=ye(),[r,o]=Ja(t),[i,a]=Ja(""),[s,u]=Ja(!1),[l,c]=Ja(null),[p,g]=Ja(null),[d,f]=Ja(!1),y=async()=>{if(!(!i.trim()||!n)){u(!0),c(null);try{let I=K(),S=await Z(`${I}/api/figma/pat`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({token:i.trim()})}),x=await S.json();if(!S.ok){c({type:"error",message:x.error||"Failed to save token"});return}g(x.figmaUser?.handle||x.figmaUser?.email||"Connected"),c({type:"success",message:`Connected as ${x.figmaUser?.handle||"Figma user"}`}),a(""),e?.()}catch{c({type:"error",message:"Failed to connect. Check your token and try again."})}finally{u(!1)}}};return p?zt.createElement(O1,null,zt.createElement(m3,null,"Figma Personal Access Token"),zt.createElement(RU,null,zt.createElement("span",null,"\u2713 Connected as ",zt.createElement("strong",null,p)),zt.createElement(AU,{onClick:()=>{g(null),c(null)}},"Change token"))):r?zt.createElement(O1,null,zt.createElement(CU,null,zt.createElement(m3,null,"Figma Personal Access Token"),zt.createElement(h3,{onClick:()=>f(!d)},d?"Hide instructions":"How to generate")),d&&zt.createElement(EU,null,zt.createElement("ol",null,zt.createElement("li",null,"Open"," ",zt.createElement("a",{href:"https://www.figma.com/settings",target:"_blank",rel:"noopener noreferrer"},"Figma Settings")),zt.createElement("li",null,"Click the ",zt.createElement("strong",null,"Security")," tab"),zt.createElement("li",null,"Scroll to ",zt.createElement("strong",null,"Personal access tokens")),zt.createElement("li",null,"Click ",zt.createElement("strong",null,"Generate new token")),zt.createElement("li",null,"Enable ",zt.createElement("strong",null,"File content: Read only")," under Scopes"),zt.createElement("li",null,"Copy the token and paste it below"))),zt.createElement(IU,null,zt.createElement(TU,{type:"password",value:i,onChange:I=>a(I.target.value),placeholder:"figd_...",onKeyDown:I=>{I.key==="Enter"&&i.trim()&&y()}}),zt.createElement(Qt,{onClick:y,disabled:!i.trim()||s},s?"Verifying...":"Save & Verify")),l&&zt.createElement(x3,{variant:l.type},l.message),zt.createElement(x3,{variant:"info"},"Read-only access. Your token is stored securely and never shared.")):zt.createElement(O1,null,zt.createElement(h3,{onClick:()=>o(!0)},"Or use a Personal Access Token \u2192"))};ke();De();ct();var MU=Dt.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Dt.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"}),Dt.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"}),Dt.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),Dt.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"}),Dt.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"})),$1=yi.div({}),LU=yi.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",padding:"10px 16px",backgroundColor:e.background.hoverable,borderBottom:`1px solid ${e.appBorderColor}`})),BU=yi.div({width:"16px",height:"16px",display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}),zU=yi.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,flex:1})),H1=yi.div({"& > *":{border:"none",borderRadius:0,marginBottom:0,borderBottom:"1px solid rgba(0,0,0,0.06)","&:last-child":{borderBottom:"none"}}}),DU=yi.div({padding:"20px 16px",display:"flex",flexDirection:"column",gap:"12px"}),N0e=yi.button({display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",width:"100%",padding:"8px 16px",backgroundColor:Xx,color:"#fff",border:"none",borderRadius:"6px",fontSize:"13px",fontWeight:600,cursor:"pointer","&:hover":{backgroundColor:Jx}}),_U=yi.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}})),w3=({hideHeader:e=!1})=>{let{sessionToken:t}=ye(),n=!!t&&t.startsWith("uic_anon_"),[r,o]=kl(!1),[i,a]=kl(0),[s,u]=kl(()=>{try{let S=sessionStorage.getItem("uicopilot_figma_connection");if(S){let{connected:x,ts:M}=JSON.parse(S);if(Date.now()-M<300*1e3)return x}}catch{}return null}),[l,c]=kl(!1),[p,g]=kl(!1),d=PU();FU(()=>{if(!t)return;let S=K();Z(`${S}/api/figma/connection-status`,{headers:{Authorization:`Bearer ${t}`}}).then(x=>x.json()).then(x=>{let M=!!x.connected;c(!!x.expired),u(M);try{sessionStorage.setItem("uicopilot_figma_connection",JSON.stringify({connected:M,ts:Date.now()}))}catch{}}).catch(()=>u(!1))},[t]);let f=b3(()=>{let S=K(),x=`${S}/api/auth/figma/login?addon=true`;window.open(x,"figma-oauth","width=600,height=700,left=200,top=100");let M=setInterval(async()=>{try{(await(await Z(`${S}/api/figma/connection-status`,{headers:t?{Authorization:`Bearer ${t}`}:{}})).json()).connected&&(clearInterval(M),u(!0))}catch{}},2e3);setTimeout(()=>clearInterval(M),300*1e3)},[t]),y=b3(async()=>{try{o(!0);let S=K(),x=await Z(`${S}/api/figma/disconnect`,{method:"POST",headers:{Authorization:`Bearer ${t}`}});if(x.ok||x.status===404){u(!1);try{sessionStorage.removeItem("uicopilot_figma_connection")}catch{}}}catch{}finally{o(!1)}},[t]),I=e?null:Dt.createElement(LU,null,Dt.createElement(BU,null,MU),Dt.createElement(zU,null,"Figma Integration"));return s===null?Dt.createElement($1,null,I,Dt.createElement(H1,null,Dt.createElement("div",{style:{padding:"16px",fontSize:"13px",color:d.color.mediumdark}},"Checking Figma connection..."))):s===!1?Dt.createElement($1,null,I,Dt.createElement(H1,null,Dt.createElement(DU,null,l&&Dt.createElement("div",{style:{padding:"10px 12px",backgroundColor:"rgba(245, 158, 11, 0.1)",border:"1px solid rgba(245, 158, 11, 0.4)",borderRadius:"6px",fontSize:"12px",color:d.color.warning}},"\u26A0\uFE0F Your Figma access has expired. Please reconnect."),Dt.createElement("div",{style:{padding:"8px 10px",backgroundColor:"rgba(100, 116, 139, 0.1)",border:"1px solid rgba(100, 116, 139, 0.3)",borderRadius:"6px",fontSize:"11px",lineHeight:1.4,color:d.color.mediumdark}},"Requires a Figma ",Dt.createElement("strong",null,"Dev or Full seat"),". Free/Viewer seats can't grant design-read access."),!n&&Dt.createElement(Dt.Fragment,null,Dt.createElement(Qt,{onClick:f,style:{width:"100%"}},l?"Reconnect Figma":"Connect with Figma"),Dt.createElement(_U,null,"or")),Dt.createElement(y3,{onConnected:()=>u(!0),defaultExpanded:n})))):Dt.createElement($1,null,I,Dt.createElement(Au,{connected:!0,label:"Connected to Figma",actionLabel:r?"Disconnecting\u2026":"Disconnect",actionDisabled:r,actionTitle:"Disconnect Figma",onAction:()=>g(!0)}),Dt.createElement(wo,{isOpen:p,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:()=>{g(!1),y()},onCancel:()=>g(!1)}),Dt.createElement(H1,null,Dt.createElement(ek,{onFigmaFileChanged:()=>a(S=>S+1)}),Dt.createElement(RC,{refreshKey:i}),Dt.createElement(f3,null)))};ke();on();import{styled as rn}from"storybook/theming";var v3=rn.div({position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.4)",zIndex:1e3,display:"flex",justifyContent:"center",alignItems:"flex-start",paddingTop:"40px"}),S3=rn.div(({theme:e})=>({backgroundColor:e.background.content,borderRadius:"14px",border:`1px solid ${e.appBorderColor}`,boxShadow:"0 16px 48px rgba(0, 0, 0, 0.22)",width:"820px",maxWidth:"94%",maxHeight:"calc(100vh - 80px)",display:"flex",flexDirection:"column",overflow:"hidden",position:"relative"})),k3=rn.header(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",height:"48px",padding:"0 16px",borderBottom:`1px solid ${e.appBorderColor}`,flexShrink:0})),C3=rn.div({display:"flex",alignItems:"center",gap:"8px"}),I3=rn.span(({theme:e})=>({fontSize:"14px",fontWeight:e.typography.weight.bold,letterSpacing:"-0.01em",color:e.color.defaultText})),T3=rn.span(({theme:e})=>({fontSize:"10px",fontFamily:e.typography.fonts.mono,color:e.color.mediumdark})),E3=rn.button(({theme:e})=>({width:"28px",height:"28px",display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:e.appBorderRadius,color:e.color.mediumdark,backgroundColor:"transparent",border:"none",cursor:"pointer",fontSize:"18px",lineHeight:1,transition:"all 0.15s","&:hover":{color:e.color.defaultText,backgroundColor:e.background.hoverable}})),R3=rn.div({display:"flex",flex:1,minHeight:"440px",overflow:"hidden"}),A3=rn.nav(({theme:e})=>({width:"178px",flexShrink:0,backgroundColor:e.background.app,padding:"12px 8px",display:"flex",flexDirection:"column",gap:"2px"})),F3=rn.button(({theme:e,active:t})=>({position:"relative",width:"100%",display:"flex",alignItems:"center",gap:"10px",padding:"0 8px 0 12px",height:"32px",borderRadius:e.appBorderRadius,border:"none",cursor:"pointer",textAlign:"left",backgroundColor:t?e.background.hoverable:"transparent",color:t?e.color.defaultText:e.color.mediumdark,transition:"all 0.15s","&:hover":{color:e.color.defaultText,backgroundColor:e.background.hoverable},"& svg":{flexShrink:0}})),P3=rn.span({position:"absolute",left:0,top:"6px",bottom:"6px",width:"2px",borderRadius:"2px",backgroundColor:W}),M3=rn.span(({theme:e})=>({fontSize:"12px",fontWeight:e.typography.weight.bold,lineHeight:1})),L3=rn.div(({theme:e})=>({flex:1,overflowY:"auto",backgroundColor:e.background.content,borderLeft:`1px solid ${e.appBorderColor}`,padding:"20px"})),id=rn.header({display:"flex",alignItems:"center",gap:"10px",marginBottom:"16px"}),B3=rn.div({width:"28px",height:"28px",borderRadius:"7px",backgroundColor:W,color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",fontWeight:700,letterSpacing:"0.3px",flexShrink:0}),U1=rn.div(({theme:e})=>({width:"28px",height:"28px",borderRadius:"7px",backgroundColor:e.background.hoverable,border:`1px solid ${e.appBorderColor}`,color:e.color.mediumdark,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0})),ad=rn.h3(({theme:e})=>({margin:0,fontSize:"13px",fontWeight:e.typography.weight.bold,color:e.color.defaultText,lineHeight:1.2})),sd=rn.p(({theme:e})=>({margin:"3px 0 0",fontSize:"11px",color:e.color.mediumdark,lineHeight:1.2})),ld=rn.div({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"}}),j1=rn.div(({theme:e})=>({padding:"16px",borderRadius:"10px",border:`1px dashed ${e.appBorderColor}`,backgroundColor:e.background.app,fontSize:"12px",color:e.color.mediumdark,lineHeight:1.5})),z3=rn.footer(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",height:"44px",padding:"0 16px",borderTop:`1px solid ${e.appBorderColor}`,flexShrink:0})),D3=rn.span(({theme:e})=>({fontSize:"10px",fontFamily:e.typography.fonts.mono,color:e.color.mediumdark})),_3=rn.div({display:"flex",alignItems:"center",gap:"6px"}),N3=rn.button(({theme:e})=>({height:"28px",padding:"0 12px",fontSize:"11px",fontWeight:e.typography.weight.bold,fontFamily:e.typography.fonts.base,border:"none",borderRadius:e.appBorderRadius*2,background:"transparent",color:e.color.mediumdark,cursor:"pointer",transition:"all 0.15s","&:hover":{color:e.color.defaultText,backgroundColor:e.background.hoverable}}));var O3=()=>_e.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"},_e.createElement("path",{d:"M4 4h5l2 3h9a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z"})),HU=[{id:"account",label:"Account",icon:gs},{id:"project",label:"Project",icon:O3},{id:"figma",label:"Figma",icon:Mo}],$3=({onClose:e})=>{let{isConnected:t}=ye(),{selectedProjectId:n}=Ke(),[r,o]=$U("account"),i=cd(t),a=cd(!t),s=cd(!1),u=cd(!1);OU(()=>{a.current&&!s.current&&!i.current&&t&&n&&(s.current=!0,e()),i.current=t},[t,n,e]);let l=()=>r==="account"?_e.createElement(_e.Fragment,null,_e.createElement(id,null,_e.createElement(B3,null,"UI"),_e.createElement("div",null,_e.createElement(ad,null,jt.NAME," account"),_e.createElement(sd,null,"Deterministic Figma \u2194 code comparison"))),_e.createElement(ld,null,_e.createElement(q4,{onConnect:e}))):r==="project"?_e.createElement(_e.Fragment,null,_e.createElement(id,null,_e.createElement(U1,null,_e.createElement(O3,null)),_e.createElement("div",null,_e.createElement(ad,null,"Project"),_e.createElement(sd,null,"The Storybook project being compared"))),t?_e.createElement(ld,null,_e.createElement(J4,null)):_e.createElement(j1,null,"Sign in on the ",_e.createElement("strong",null,"Account")," tab first to choose a project.")):_e.createElement(_e.Fragment,null,_e.createElement(id,null,_e.createElement(U1,null,_e.createElement(Mo,null)),_e.createElement("div",null,_e.createElement(ad,null,"Figma integration"),_e.createElement(sd,null,"Source of truth for design tokens"))),t&&n?_e.createElement(ld,null,_e.createElement(w3,{hideHeader:!0})):_e.createElement(j1,null,t?"Select a project on the Project tab before connecting Figma.":"Sign in on the Account tab first, then pick a project to connect Figma."));return _e.createElement(v3,{onMouseDown:c=>{u.current=c.target===c.currentTarget},onClick:c=>{u.current&&c.target===c.currentTarget&&e()}},_e.createElement(S3,{onClick:c=>c.stopPropagation()},_e.createElement(k3,null,_e.createElement(C3,null,_e.createElement(I3,null,"Settings"),_e.createElement(T3,null,"v","0.12.1")),_e.createElement(E3,{onClick:e,title:"Close settings","aria-label":"Close"},"\xD7")),_e.createElement(R3,null,_e.createElement(A3,null,HU.map(c=>{let p=c.icon,g=r===c.id;return _e.createElement(F3,{key:c.id,active:g,onClick:()=>o(c.id)},g&&_e.createElement(P3,null),_e.createElement(p,null),_e.createElement(M3,null,c.label))})),_e.createElement(L3,null,l())),_e.createElement(z3,null,_e.createElement(D3,null,jt.NAME," \xB7 settings synced"),_e.createElement(_3,null,_e.createElement(N3,{onClick:e},"Cancel"),_e.createElement(Qt,{onClick:e},"Done")))))};ke();on();import Wt from"react";import so from"react";import{styled as hn,keyframes as UU}from"storybook/theming";var bi=hn.div({marginTop:"10px",padding:"12px",borderRadius:"8px",border:`1px solid ${te.border}`,background:te.formBg,display:"flex",flexDirection:"column",gap:"10px"}),H3=hn.button({display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",width:"100%",padding:"9px",borderRadius:"8px",border:`1px solid ${te.border}`,background:te.card,color:te.text,fontSize:"13px",fontWeight:600,cursor:"pointer","&:hover":{background:te.formBg}}),Cl=hn.div({fontSize:"11px",color:te.muted,textAlign:"center"}),U3=hn.div({display:"flex",alignItems:"center",gap:"8px","&::before, &::after":{content:'""',flex:1,height:"1px",background:te.border},fontSize:"11px",color:te.muted}),j3=hn.button({width:"100%",padding:"9px",borderRadius:"6px",border:`1px dashed ${W}`,background:te.card,color:W,fontSize:"12px",fontWeight:600,cursor:"pointer","&:hover":{background:te.accentTint},"&:disabled":{opacity:.6,cursor:"default"}}),wi=hn.label({fontSize:"11px",fontWeight:600,color:te.subText,display:"block",marginBottom:"4px"}),Ki=hn.input({width:"100%",padding:"7px 10px",fontSize:"12px",borderRadius:"6px",border:`1px solid ${te.border}`,background:te.card,color:te.text,outline:"none","&:focus":{borderColor:W},"&:disabled":{background:te.formBg,color:te.muted}}),V3=hn.select({width:"100%",padding:"7px 10px",fontSize:"12px",borderRadius:"6px",border:`1px solid ${te.border}`,background:te.card,color:te.text}),ao=hn.button(({disabled:e})=>({width:"100%",padding:"8px",borderRadius:"6px",border:"none",fontSize:"12px",fontWeight:600,color:te.card,cursor:e?"not-allowed":"pointer",background:W,opacity:e?.5:1,"&:hover":e?{}:{background:ei}})),V1=hn.div({marginTop:"10px",fontSize:"11px",lineHeight:1.4,padding:"8px 10px",borderRadius:"6px",background:te.calloutBg,color:te.calloutText}),W3=hn.div({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"}),G3=hn.div({display:"flex",flexDirection:"column",gap:"8px",padding:"10px",borderRadius:"6px",border:`1px solid ${te.border}`,background:te.card}),q3=hn.div({display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:"11px",color:te.subText}),Y3=hn.span({fontVariantNumeric:"tabular-nums",color:te.muted}),K3=hn.div({height:"4px",width:"100%",borderRadius:"999px",background:te.track,overflow:"hidden"}),X3=hn.div(({pct:e})=>({height:"100%",width:`${Math.min(100,Math.max(0,e))}%`,borderRadius:"999px",background:W,transition:"width 0.3s ease"})),jU=UU`
|
|
91
|
+
`,u3=Pt.span(({theme:e,tone:t})=>({display:"inline-flex",alignItems:"center",gap:"4px",padding:"1px 6px",borderRadius:"3px",fontSize:"9px",fontWeight:e.typography.weight.bold,textTransform:"uppercase",letterSpacing:"0.05em",backgroundColor:t==="green"?`${e.color.positive}1a`:`${W}1a`,color:t==="green"?e.color.positive:W})),mU=Pt.span({display:"inline-block",width:"10px",height:"10px",border:`1.5px solid ${W}40`,borderTopColor:W,borderRadius:"50%",animation:`${g3} 0.6s linear infinite`}),hU=()=>q.createElement("svg",{viewBox:"0 0 24 24",width:"10",height:"10",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0},q.createElement("path",{d:"M20 6 9 17l-5-5"})),D1=Pt.button(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:"4px",height:"25px",padding:"2px 8px",border:"none",background:"transparent",borderRadius:e.appBorderRadius,cursor:"pointer",fontSize:"11px",fontFamily:e.typography.fonts.base,color:e.color.mediumdark,transition:"all 0.15s","&:hover:not(:disabled)":{color:e.color.defaultText,backgroundColor:e.background.hoverable},"&:disabled":{opacity:.5,cursor:"not-allowed"}})),_1=Pt.span({display:"inline-block",width:"10px",height:"10px",border:"1.5px solid currentColor",borderTopColor:"transparent",borderRadius:"50%",opacity:.6,animation:`${g3} 0.6s linear infinite`}),xU=()=>q.createElement("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"currentColor","aria-hidden":!0},q.createElement("path",{d:"M12 2.5l1.6 5.9 5.9 1.6-5.9 1.6L12 17.5l-1.6-5.9L4.5 10l5.9-1.6z"})),yU=()=>q.createElement("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0},q.createElement("path",{d:"M23 4v6h-6M1 20v-6h6"}),q.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"})),bU=Pt.div(({theme:e})=>({marginTop:"6px",padding:"6px 8px",backgroundColor:e.background.hoverable,borderRadius:"4px",color:e.color.mediumdark,lineHeight:"1.4"})),N1=Pt.span(({theme:e,type:t})=>({fontWeight:500,color:t==="added"?e.color.positive:t==="removed"?e.color.negative:e.color.warning})),Sl=Pt.div(({theme:e})=>({marginTop:"8px",padding:"8px 10px",backgroundColor:`${e.color.negative}1a`,border:`1px solid ${e.color.negative}4d`,borderRadius:"4px",fontSize:"12px",color:e.color.negative,lineHeight:"1.4"})),wU=Pt.div(({theme:e})=>({marginTop:"8px",padding:"8px 10px",backgroundColor:`${e.color.warning}1a`,border:`1px solid ${e.color.warning}4d`,borderRadius:"4px",fontSize:"12px",color:e.color.warning,lineHeight:"1.4"})),vU=Pt.div(({theme:e})=>({marginTop:"8px",padding:"8px 10px",backgroundColor:`${e.color.positive}1a`,border:`1px solid ${e.color.positive}4d`,borderRadius:"4px",fontSize:"12px",color:e.color.positive,lineHeight:"1.4"})),SU=Pt.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"6px",marginTop:"8px",padding:"6px 8px",borderRadius:e.appBorderRadius,backgroundColor:e.background.hoverable,fontSize:"11px",lineHeight:"1.4",color:e.color.defaultText})),Ka=Pt.div(({theme:e})=>({width:"100%",height:"8px",backgroundColor:e.appBorderColor,borderRadius:"4px",overflow:"hidden",marginTop:"10px"})),Xa=Pt.div(({percent:e})=>({width:`${e}%`,height:"100%",backgroundColor:W,borderRadius:"3px",transition:"width 0.5s ease"})),Yi=Pt.div(({theme:e})=>({display:"flex",justifyContent:"space-between",marginTop:"6px",fontSize:"12px",fontWeight:500,color:e.color.defaultText})),d3=new Set,p3=new Map,kU=2,f3=()=>{let{userRole:e,featureFlags:t}=ge(),[n,r]=xi(null),[o,i]=xi(!0),[a,s]=xi(!1),[u,l]=xi(null),[c,p]=xi(null),[g,d]=xi(!1),[f,y]=xi(!1),[I,S]=xi(!1),{selectedProjectId:x,projects:M}=Ke(),{sessionToken:z}=ye(),O=M1(null),L=M1(null),_=M1(null),m=l3(()=>{O.current&&(clearInterval(O.current),O.current=null),L.current&&(clearInterval(L.current),L.current=null),_.current&&(clearTimeout(_.current),_.current=null)},[]);vl(()=>m,[m]);let k=l3(async()=>{if(!(!x||!z))try{let j=K(),Y=await Z(`${j}/api/figma/cache-status?projectId=${x}`,{headers:{Authorization:`Bearer ${z}`}});if(Y.ok){let J=await Y.json();r(J)}}catch(j){console.error("[FigmaCacheSection] Error:",j)}finally{i(!1)}},[x,z]);vl(()=>{k()},[k]),vl(()=>{if(o||a||!n||n.structureStatus!=="none"||!x||d3.has(x))return;let j=M.find(J=>J.id===x);(j?.figmaFileUrl||j?.figmaFileId)&&(d3.add(x),C())},[o,a,n?.structureStatus,x,M]),vl(()=>{if(!x)return;let j=p3.get(x)??0;AC({loading:o,reloading:a,crawlStatus:n?.crawlProgress?.status,pagesFailed:n?.crawlProgress?.pagesFailed,tries:j,max:kU})&&(p3.set(x,j+1),C())},[o,a,n?.crawlProgress?.status,n?.crawlProgress?.pagesFailed,x]),vl(()=>{let j=n?.thumbnailProgress?.status,Y=n?.enrichmentProgress?.status,J=n?.thumbnailProgress?.cached??0,ne=n?.thumbnailProgress?.total??0,Re=j==="in-progress"||j==="pending"||ne>0&&J<ne,be=Y==="in-progress"||Y==="pending",fe=!n?.thumbnailProgress&&n?.structureStatus==="cached",Me=n?.crawlProgress?.status==="crawling"||n?.crawlProgress?.status==="cancelling";if(!(Me||Re||be||fe)||!Me&&(!n||n.structureStatus==="none"))return;let ze=setInterval(()=>{k()},3e3);return()=>{clearInterval(ze)}},[n?.thumbnailProgress?.status,n?.thumbnailProgress?.cached,n?.thumbnailProgress?.total,n?.enrichmentProgress?.status,n?.crawlProgress?.status,n?.structureStatus,k]);let C=async j=>{if(!x||!z)return;let Y=Array.isArray(j)?j:void 0;s(!0),l(null),p(null);try{let J=K(),ne=await Z(`${J}/api/figma/crawl`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${z}`},body:JSON.stringify(Y?.length?{projectId:x,pageIds:Y}:{projectId:x})});if(!ne.ok){if(ne.status===403){let be=await ne.json().catch(()=>({}));l(be.requiresAuth?"auth":"generic")}else l("generic");return}let Re=await ne.json().catch(()=>({}));if(Re?.status==="skipped-unchanged")p("Figma file unchanged \u2014 reused cached structure.");else if(Re?.status==="crawl-started"||Re?.status==="retry-started"){if(Re?.status==="retry-started"){let be=Re.retryPages;p(`Retrying ${be?`${be} `:""}page${be===1?"":"s"} that hit Figma's rate limit\u2026`)}try{rU.getChannel()?.emit(qu,{projectId:x})}catch{}}await k()}catch(J){console.error("[FigmaCacheSection] Crawl start error:",J),l("generic")}finally{s(!1)}},E=async()=>{if(!(!x||!z)){d(!0);try{let j=K(),Y=await Z(`${j}/api/figma/cache/invalidate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${z}`},body:JSON.stringify({projectId:x})});if(console.log("[FigmaCacheSection] Cache invalidate response:",Y.status),!Y.ok){l("generic");return}await Z(`${j}/api/figma/frames/invalidate?projectId=${x}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${z}`}}).catch(()=>{}),x&&BC(x),r({structureStatus:"none",structureCachedAt:null,componentSetCount:0,componentCount:0,pageCount:0,pages:[],cacheDiff:null,thumbnailProgress:null,enrichmentProgress:null,crawlProgress:null})}catch(j){console.error("[FigmaCacheSection] Clear cache error:",j)}finally{d(!1)}}},h=async()=>{if(!(!x||!z)){m(),y(!0);try{let j=K();await Z(`${j}/api/figma/enrich`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${z}`},body:JSON.stringify({projectId:x})}),O.current=setInterval(async()=>{await k()},3e3),L.current=setInterval(()=>{(n?.enrichmentProgress?.status==="complete"||n?.enrichmentProgress?.status==="error")&&(m(),y(!1),k())},3e3),_.current=setTimeout(()=>{m(),y(!1)},6e5)}catch(j){console.error("[FigmaCacheSection] Enrich error:",j),m(),y(!1)}}},b=async()=>{if(!(!x||!z)){S(!0);try{let j=K();await Z(`${j}/api/figma/cancel`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${z}`},body:JSON.stringify({projectId:x})}),await k()}catch(j){console.error("[FigmaCacheSection] Cancel error:",j)}finally{S(!1),y(!1),s(!1)}}},R=n?.crawlProgress?.status==="crawling"||n?.crawlProgress?.status==="cancelling"||n?.thumbnailProgress?.status==="in-progress"||n?.enrichmentProgress?.status==="in-progress";if(!x)return null;if(o)return q.createElement(L1,null,q.createElement(B1,null,q.createElement(z1,null,"Figma Sync")),q.createElement(c3,null,"Loading sync status\u2026"),q.createElement(Ka,null,q.createElement(Xa,{percent:100,style:{opacity:.3}})));if(!n||n.structureStatus==="none")return q.createElement(L1,null,q.createElement(B1,null,q.createElement(z1,null,"Figma Sync"),q.createElement(So,{loading:a,onClick:C,loadingText:"Loading..."},"\u21BB Load")),n?.crawlProgress?.status==="crawling"?q.createElement(q.Fragment,null,q.createElement(Ka,null,q.createElement(Xa,{percent:(n.crawlProgress.pagesTotal??0)>0?Math.round(n.crawlProgress.pagesDone/n.crawlProgress.pagesTotal*100):100,style:(n.crawlProgress.pagesTotal??0)>0?void 0:{opacity:.3}})),q.createElement(Yi,null,q.createElement("span",null,"Reading components from Figma\u2026"),q.createElement("span",null,(n.crawlProgress.pagesTotal??0)>0?`page ${n.crawlProgress.pagesDone} of ${n.crawlProgress.pagesTotal}`:"starting\u2026"))):a?q.createElement(q.Fragment,null,q.createElement(Ka,null,q.createElement(Xa,{percent:100,style:{animation:"none",opacity:.3}})),q.createElement(Yi,null,q.createElement("span",null,"Starting crawl\u2026"))):q.createElement(c3,null,"No cache \u2014 click Load to fetch from Figma"),n?.crawlProgress?.status==="error"&&q.createElement(Sl,null,"Crawl failed",n.crawlProgress.error?`: ${n.crawlProgress.error}`:"",". Try Load again."),u==="auth"&&q.createElement(Sl,null,"Figma authentication expired \u2014 reconnect your Figma account in the Figma Integration section above."),u==="generic"&&q.createElement(Sl,null,"Failed to load Figma cache. Check the browser console for details."));let v=j=>{let Y=Date.now()-new Date(j).getTime(),J=Math.floor(Y/6e4);if(J<1)return"just now";if(J<60)return`${J}m ago`;let ne=Math.floor(J/60);return ne<24?`${ne}h ago`:`${Math.floor(ne/24)}d ago`},A=j=>j>=1024*1024*1024?`${(j/1024/1024/1024).toFixed(1)} GB`:j>=1024*1024?`${Math.round(j/1024/1024)} MB`:`${Math.max(1,Math.round(j/1024))} KB`,B=n.crawlProgress?.bytesDownloaded,P=n.cacheDiff,N=P&&(P.added.length>0||P.removed.length>0||P.renamed.length>0),T=n.crawlProgress,D=T?.pagesTotal??0,H=T?.pagesDone??0,F=T?.status==="crawling"||a,re=D>0?Math.round(H/D*100):a?8:0;return q.createElement(L1,null,q.createElement(B1,null,q.createElement(z1,null,"Figma Sync"," ",n.crawlProgress?.status==="crawling"?q.createElement(u3,{tone:"orange"},q.createElement(mU,null),"Importing"):n.structureStatus==="cached"?q.createElement(u3,{tone:"green"},q.createElement(hU,null),"Synced"):q.createElement(fU,{status:n.structureStatus},n.structureStatus)),q.createElement("div",{style:{display:"flex",gap:"2px"}},e==="admin"&&q.createElement(D1,{onClick:h,disabled:f},f?q.createElement(_1,null):q.createElement(xU,null),f?"Enriching\u2026":"Enrich"),q.createElement(D1,{onClick:E,disabled:g},g&&q.createElement(_1,null),g?"Clearing\u2026":"Clear"),q.createElement(D1,{onClick:()=>C(x?qa(x):void 0),disabled:a},a?q.createElement(_1,null):q.createElement(yU,null),a?"Reloading\u2026":"Reload"),R&&q.createElement(So,{loading:I||n?.crawlProgress?.status==="cancelling",onClick:b,variant:"ghost",loadingText:"Stopping..."},"\u2715 Stop"))),n?.crawlProgress?.status==="crawling"&&!((n.crawlProgress.pagesTotal??0)>0&&n.crawlProgress.pagesDone>=n.crawlProgress.pagesTotal)&&q.createElement(q.Fragment,null,q.createElement(Ka,null,q.createElement(Xa,{percent:(n.crawlProgress.pagesTotal??0)>0?Math.round(n.crawlProgress.pagesDone/n.crawlProgress.pagesTotal*100):100,style:(n.crawlProgress.pagesTotal??0)>0?void 0:{opacity:.3}})),q.createElement(Yi,null,q.createElement("span",null,"Re-reading components from Figma\u2026"),q.createElement("span",null,(n.crawlProgress.pagesTotal??0)>0?`page ${n.crawlProgress.pagesDone} of ${n.crawlProgress.pagesTotal}`:"starting\u2026"))),a&&n?.crawlProgress?.status!=="crawling"&&q.createElement(Yi,null,q.createElement("span",null,"Starting crawl\u2026")),u==="auth"&&q.createElement(Sl,null,"Figma authentication expired \u2014 reconnect your Figma account in the Figma Integration section above."),u==="generic"&&q.createElement(Sl,null,"Failed to reload Figma sync. Check the browser console for details."),q.createElement(oU,null,q.createElement(nd,null,q.createElement(rd,null,"Component sets"),q.createElement(od,null,n.componentSetCount)),q.createElement(nd,null,q.createElement(rd,null,"Pages"),q.createElement(od,null,n.pageCount)),typeof B=="number"&&B>0&&q.createElement(nd,null,q.createElement(rd,null,"Size"),q.createElement(od,null,"\u2248 ",A(B))),n.structureCachedAt&&q.createElement(nd,null,q.createElement(rd,null,"Updated"),q.createElement(od,{plain:!0},v(n.structureCachedAt)))),q.createElement(SU,null,q.createElement("span",{"aria-hidden":!0},"\u2139\uFE0F"),q.createElement("span",null,q.createElement("strong",null,"Components only")," for now \u2014 plain Figma frames aren't indexed yet (support planned).")),x&&q.createElement(s3,{projectId:x,busy:a,importing:F,importPct:re,onReimport:C}),n.crawlProgress?.status==="complete"&&n.crawlProgress.pagesFailed>0&&q.createElement(wU,null,"\u26A0 ",n.crawlProgress.pagesFailed," of"," ",n.crawlProgress.pagesTotal," pages couldn\u2019t be read (Figma rate limit) \u2014 some components may be missing. Reload to retry."),c&&q.createElement(vU,null,"\u2713 ",c),N&&q.createElement(bU,null,"Since last reload:"," ",P.added.length>0&&q.createElement(N1,{type:"added"},"+",P.added.length," added"),P.added.length>0&&P.removed.length>0&&" \xB7 ",P.removed.length>0&&q.createElement(N1,{type:"removed"},"\u2212",P.removed.length," removed"),(P.added.length>0||P.removed.length>0)&&P.renamed.length>0&&" \xB7 ",P.renamed.length>0&&q.createElement(N1,{type:"renamed"},P.renamed.length," renamed")),n.thumbnailProgress&&n.thumbnailProgress.status==="in-progress"&&q.createElement(q.Fragment,null,q.createElement(Ka,null,q.createElement(Xa,{percent:n.thumbnailProgress.total>0?Math.round(n.thumbnailProgress.cached/n.thumbnailProgress.total*100):0})),q.createElement(Yi,null,q.createElement("span",null,"Preparing thumbnails\u2026",n.thumbnailProgress.currentName&&q.createElement(q.Fragment,null," ",n.thumbnailProgress.currentName)),q.createElement("span",null,n.thumbnailProgress.cached,"/",n.thumbnailProgress.total))),n.thumbnailProgress?.status!=="in-progress"&&(()=>{let j=n.thumbnailProgress,Y=j?.cached??0,J=j?.total??0,ne=J>0&&Y>=J,Re=J>0&&Y<J,be=J>0?Math.min(100,Math.round(Y/J*100)):0;return q.createElement(iU,null,q.createElement(aU,null,q.createElement(sU,null,q.createElement(lU,null,"Thumbnails",J>0&&q.createElement(q.Fragment,null," ",q.createElement(cU,null,Y," / ",J))),q.createElement(uU,{ready:ne},ne?"\u2713 Ready":Re?"Partial":"Not generated")),q.createElement(dU,{onClick:C,disabled:a},"\u21BB ",ne?"Rebuild":"Reload")),J>0&&q.createElement(pU,null,q.createElement(gU,{pct:ne?100:be,ready:ne})))})(),n.enrichmentProgress&&n.enrichmentProgress.status==="in-progress"&&q.createElement(q.Fragment,null,q.createElement(Ka,null,q.createElement(Xa,{percent:n.enrichmentProgress.total>0?Math.round(n.enrichmentProgress.enriched/n.enrichmentProgress.total*100):0})),q.createElement(Yi,null,q.createElement("span",null,"AI descriptions: generating\u2026",n.enrichmentProgress.currentName&&q.createElement(q.Fragment,null," ",n.enrichmentProgress.currentName)),q.createElement("span",null,n.enrichmentProgress.enriched," of"," ",n.enrichmentProgress.total," component sets"))),n.enrichmentProgress&&n.enrichmentProgress.status==="complete"&&q.createElement(q.Fragment,null,q.createElement(Yi,null,q.createElement("span",null,"AI descriptions: ",n.enrichmentProgress.enriched," of"," ",n.enrichmentProgress.total," component sets \u2713"))),n.enrichmentProgress&&n.enrichmentProgress.status==="in-progress"&&t.showCosts&&n.enrichmentProgress.costUsd!=null&&n.enrichmentProgress.costUsd>0&&q.createElement("div",{style:{marginTop:"6px"}},q.createElement($u,{inputTokens:n.enrichmentProgress.inputTokens||0,outputTokens:n.enrichmentProgress.outputTokens||0,costUsd:n.enrichmentProgress.costUsd,compact:!0})))};import zt,{useState as Ja}from"react";import{styled as ko}from"storybook/theming";ke();De();ct();var O1=ko.div({padding:"12px 16px"}),CU=ko.div({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"}),m3=ko.label(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText})),h3=ko.button(({theme:e})=>({background:"none",border:"none",fontSize:"12px",color:W,cursor:"pointer",padding:0,"&:hover":{textDecoration:"underline"}})),IU=ko.div({display:"flex",gap:"8px",alignItems:"center"}),TU=ko.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:W,boxShadow:`0 0 0 1px ${W}`},"&::placeholder":{color:e.color.mediumlight,fontFamily:"inherit"}})),x3=ko.span(({theme:e,variant:t})=>({fontSize:"12px",color:t==="success"?e.color.positive:t==="error"?e.color.negative:e.color.mediumdark,marginTop:"6px",display:"block",lineHeight:1.4})),EU=ko.div(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark,marginTop:"8px",lineHeight:1.5,"& a":{color:W,textDecoration:"none","&:hover":{textDecoration:"underline"}},"& ol":{margin:"4px 0 0 16px",padding:0},"& li":{marginBottom:"2px"}})),RU=ko.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})),AU=ko.button(({theme:e})=>({background:"none",border:"none",fontSize:"11px",color:"#dc2626",cursor:"pointer",marginLeft:"auto","&:hover":{textDecoration:"underline"}})),y3=({onConnected:e,defaultExpanded:t=!1})=>{let{sessionToken:n}=ye(),[r,o]=Ja(t),[i,a]=Ja(""),[s,u]=Ja(!1),[l,c]=Ja(null),[p,g]=Ja(null),[d,f]=Ja(!1),y=async()=>{if(!(!i.trim()||!n)){u(!0),c(null);try{let I=K(),S=await Z(`${I}/api/figma/pat`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({token:i.trim()})}),x=await S.json();if(!S.ok){c({type:"error",message:x.error||"Failed to save token"});return}g(x.figmaUser?.handle||x.figmaUser?.email||"Connected"),c({type:"success",message:`Connected as ${x.figmaUser?.handle||"Figma user"}`}),a(""),e?.()}catch{c({type:"error",message:"Failed to connect. Check your token and try again."})}finally{u(!1)}}};return p?zt.createElement(O1,null,zt.createElement(m3,null,"Figma Personal Access Token"),zt.createElement(RU,null,zt.createElement("span",null,"\u2713 Connected as ",zt.createElement("strong",null,p)),zt.createElement(AU,{onClick:()=>{g(null),c(null)}},"Change token"))):r?zt.createElement(O1,null,zt.createElement(CU,null,zt.createElement(m3,null,"Figma Personal Access Token"),zt.createElement(h3,{onClick:()=>f(!d)},d?"Hide instructions":"How to generate")),d&&zt.createElement(EU,null,zt.createElement("ol",null,zt.createElement("li",null,"Open"," ",zt.createElement("a",{href:"https://www.figma.com/settings",target:"_blank",rel:"noopener noreferrer"},"Figma Settings")),zt.createElement("li",null,"Click the ",zt.createElement("strong",null,"Security")," tab"),zt.createElement("li",null,"Scroll to ",zt.createElement("strong",null,"Personal access tokens")),zt.createElement("li",null,"Click ",zt.createElement("strong",null,"Generate new token")),zt.createElement("li",null,"Enable ",zt.createElement("strong",null,"File content: Read only")," under Scopes"),zt.createElement("li",null,"Copy the token and paste it below"))),zt.createElement(IU,null,zt.createElement(TU,{type:"password",value:i,onChange:I=>a(I.target.value),placeholder:"figd_...",onKeyDown:I=>{I.key==="Enter"&&i.trim()&&y()}}),zt.createElement(Qt,{onClick:y,disabled:!i.trim()||s},s?"Verifying...":"Save & Verify")),l&&zt.createElement(x3,{variant:l.type},l.message),zt.createElement(x3,{variant:"info"},"Read-only access. Your token is stored securely and never shared.")):zt.createElement(O1,null,zt.createElement(h3,{onClick:()=>o(!0)},"Or use a Personal Access Token \u2192"))};ke();De();ct();var MU=Dt.createElement("svg",{viewBox:"0 0 38 57",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Dt.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"}),Dt.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"}),Dt.createElement("path",{d:"M19 0V19H28.5C33.7467 19 38 14.7467 38 9.5C38 4.25329 33.7467 0 28.5 0H19Z",fill:"#FF7262"}),Dt.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"}),Dt.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"})),$1=yi.div({}),LU=yi.div(({theme:e})=>({display:"flex",alignItems:"center",gap:"8px",padding:"10px 16px",backgroundColor:e.background.hoverable,borderBottom:`1px solid ${e.appBorderColor}`})),BU=yi.div({width:"16px",height:"16px",display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}),zU=yi.span(({theme:e})=>({fontSize:"13px",fontWeight:600,color:e.color.defaultText,flex:1})),H1=yi.div({"& > *":{border:"none",borderRadius:0,marginBottom:0,borderBottom:"1px solid rgba(0,0,0,0.06)","&:last-child":{borderBottom:"none"}}}),DU=yi.div({padding:"20px 16px",display:"flex",flexDirection:"column",gap:"12px"}),N0e=yi.button({display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",width:"100%",padding:"8px 16px",backgroundColor:Xx,color:"#fff",border:"none",borderRadius:"6px",fontSize:"13px",fontWeight:600,cursor:"pointer","&:hover":{backgroundColor:Jx}}),_U=yi.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}})),w3=({hideHeader:e=!1})=>{let{sessionToken:t}=ye(),n=!!t&&t.startsWith("uic_anon_"),[r,o]=kl(!1),[i,a]=kl(0),[s,u]=kl(()=>{try{let S=sessionStorage.getItem("uicopilot_figma_connection");if(S){let{connected:x,ts:M}=JSON.parse(S);if(Date.now()-M<300*1e3)return x}}catch{}return null}),[l,c]=kl(!1),[p,g]=kl(!1),d=PU();FU(()=>{if(!t)return;let S=K();Z(`${S}/api/figma/connection-status`,{headers:{Authorization:`Bearer ${t}`}}).then(x=>x.json()).then(x=>{let M=!!x.connected;c(!!x.expired),u(M);try{sessionStorage.setItem("uicopilot_figma_connection",JSON.stringify({connected:M,ts:Date.now()}))}catch{}}).catch(()=>u(!1))},[t]);let f=b3(()=>{let S=K(),x=`${S}/api/auth/figma/login?addon=true`;window.open(x,"figma-oauth","width=600,height=700,left=200,top=100");let M=setInterval(async()=>{try{(await(await Z(`${S}/api/figma/connection-status`,{headers:t?{Authorization:`Bearer ${t}`}:{}})).json()).connected&&(clearInterval(M),u(!0))}catch{}},2e3);setTimeout(()=>clearInterval(M),300*1e3)},[t]),y=b3(async()=>{try{o(!0);let S=K(),x=await Z(`${S}/api/figma/disconnect`,{method:"POST",headers:{Authorization:`Bearer ${t}`}});if(x.ok||x.status===404){u(!1);try{sessionStorage.removeItem("uicopilot_figma_connection")}catch{}}}catch{}finally{o(!1)}},[t]),I=e?null:Dt.createElement(LU,null,Dt.createElement(BU,null,MU),Dt.createElement(zU,null,"Figma Integration"));return s===null?Dt.createElement($1,null,I,Dt.createElement(H1,null,Dt.createElement("div",{style:{padding:"16px",fontSize:"13px",color:d.color.mediumdark}},"Checking Figma connection..."))):s===!1?Dt.createElement($1,null,I,Dt.createElement(H1,null,Dt.createElement(DU,null,l&&Dt.createElement("div",{style:{padding:"10px 12px",backgroundColor:"rgba(245, 158, 11, 0.1)",border:"1px solid rgba(245, 158, 11, 0.4)",borderRadius:"6px",fontSize:"12px",color:d.color.warning}},"\u26A0\uFE0F Your Figma access has expired. Please reconnect."),Dt.createElement("div",{style:{padding:"8px 10px",backgroundColor:"rgba(100, 116, 139, 0.1)",border:"1px solid rgba(100, 116, 139, 0.3)",borderRadius:"6px",fontSize:"11px",lineHeight:1.4,color:d.color.mediumdark}},"Requires a Figma ",Dt.createElement("strong",null,"Dev or Full seat"),". Free/Viewer seats can't grant design-read access."),!n&&Dt.createElement(Dt.Fragment,null,Dt.createElement(Qt,{onClick:f,style:{width:"100%"}},l?"Reconnect Figma":"Connect with Figma"),Dt.createElement(_U,null,"or")),Dt.createElement(y3,{onConnected:()=>u(!0),defaultExpanded:n})))):Dt.createElement($1,null,I,Dt.createElement(Au,{connected:!0,label:"Connected to Figma",actionLabel:r?"Disconnecting\u2026":"Disconnect",actionDisabled:r,actionTitle:"Disconnect Figma",onAction:()=>g(!0)}),Dt.createElement(wo,{isOpen:p,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:()=>{g(!1),y()},onCancel:()=>g(!1)}),Dt.createElement(H1,null,Dt.createElement(ek,{onFigmaFileChanged:()=>a(S=>S+1)}),Dt.createElement(RC,{refreshKey:i}),Dt.createElement(f3,null)))};ke();on();import{styled as rn}from"storybook/theming";var v3=rn.div({position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.4)",zIndex:1e3,display:"flex",justifyContent:"center",alignItems:"flex-start",paddingTop:"40px"}),S3=rn.div(({theme:e})=>({backgroundColor:e.background.content,borderRadius:"14px",border:`1px solid ${e.appBorderColor}`,boxShadow:"0 16px 48px rgba(0, 0, 0, 0.22)",width:"820px",maxWidth:"94%",maxHeight:"calc(100vh - 80px)",display:"flex",flexDirection:"column",overflow:"hidden",position:"relative"})),k3=rn.header(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",height:"48px",padding:"0 16px",borderBottom:`1px solid ${e.appBorderColor}`,flexShrink:0})),C3=rn.div({display:"flex",alignItems:"center",gap:"8px"}),I3=rn.span(({theme:e})=>({fontSize:"14px",fontWeight:e.typography.weight.bold,letterSpacing:"-0.01em",color:e.color.defaultText})),T3=rn.span(({theme:e})=>({fontSize:"10px",fontFamily:e.typography.fonts.mono,color:e.color.mediumdark})),E3=rn.button(({theme:e})=>({width:"28px",height:"28px",display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:e.appBorderRadius,color:e.color.mediumdark,backgroundColor:"transparent",border:"none",cursor:"pointer",fontSize:"18px",lineHeight:1,transition:"all 0.15s","&:hover":{color:e.color.defaultText,backgroundColor:e.background.hoverable}})),R3=rn.div({display:"flex",flex:1,minHeight:"440px",overflow:"hidden"}),A3=rn.nav(({theme:e})=>({width:"178px",flexShrink:0,backgroundColor:e.background.app,padding:"12px 8px",display:"flex",flexDirection:"column",gap:"2px"})),F3=rn.button(({theme:e,active:t})=>({position:"relative",width:"100%",display:"flex",alignItems:"center",gap:"10px",padding:"0 8px 0 12px",height:"32px",borderRadius:e.appBorderRadius,border:"none",cursor:"pointer",textAlign:"left",backgroundColor:t?e.background.hoverable:"transparent",color:t?e.color.defaultText:e.color.mediumdark,transition:"all 0.15s","&:hover":{color:e.color.defaultText,backgroundColor:e.background.hoverable},"& svg":{flexShrink:0}})),P3=rn.span({position:"absolute",left:0,top:"6px",bottom:"6px",width:"2px",borderRadius:"2px",backgroundColor:W}),M3=rn.span(({theme:e})=>({fontSize:"12px",fontWeight:e.typography.weight.bold,lineHeight:1})),L3=rn.div(({theme:e})=>({flex:1,overflowY:"auto",backgroundColor:e.background.content,borderLeft:`1px solid ${e.appBorderColor}`,padding:"20px"})),id=rn.header({display:"flex",alignItems:"center",gap:"10px",marginBottom:"16px"}),B3=rn.div({width:"28px",height:"28px",borderRadius:"7px",backgroundColor:W,color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",fontWeight:700,letterSpacing:"0.3px",flexShrink:0}),U1=rn.div(({theme:e})=>({width:"28px",height:"28px",borderRadius:"7px",backgroundColor:e.background.hoverable,border:`1px solid ${e.appBorderColor}`,color:e.color.mediumdark,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0})),ad=rn.h3(({theme:e})=>({margin:0,fontSize:"13px",fontWeight:e.typography.weight.bold,color:e.color.defaultText,lineHeight:1.2})),sd=rn.p(({theme:e})=>({margin:"3px 0 0",fontSize:"11px",color:e.color.mediumdark,lineHeight:1.2})),ld=rn.div({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"}}),j1=rn.div(({theme:e})=>({padding:"16px",borderRadius:"10px",border:`1px dashed ${e.appBorderColor}`,backgroundColor:e.background.app,fontSize:"12px",color:e.color.mediumdark,lineHeight:1.5})),z3=rn.footer(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",height:"44px",padding:"0 16px",borderTop:`1px solid ${e.appBorderColor}`,flexShrink:0})),D3=rn.span(({theme:e})=>({fontSize:"10px",fontFamily:e.typography.fonts.mono,color:e.color.mediumdark})),_3=rn.div({display:"flex",alignItems:"center",gap:"6px"}),N3=rn.button(({theme:e})=>({height:"28px",padding:"0 12px",fontSize:"11px",fontWeight:e.typography.weight.bold,fontFamily:e.typography.fonts.base,border:"none",borderRadius:e.appBorderRadius*2,background:"transparent",color:e.color.mediumdark,cursor:"pointer",transition:"all 0.15s","&:hover":{color:e.color.defaultText,backgroundColor:e.background.hoverable}}));var O3=()=>_e.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"},_e.createElement("path",{d:"M4 4h5l2 3h9a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z"})),HU=[{id:"account",label:"Account",icon:gs},{id:"project",label:"Project",icon:O3},{id:"figma",label:"Figma",icon:Mo}],$3=({onClose:e})=>{let{isConnected:t}=ye(),{selectedProjectId:n}=Ke(),[r,o]=$U("account"),i=cd(t),a=cd(!t),s=cd(!1),u=cd(!1);OU(()=>{a.current&&!s.current&&!i.current&&t&&n&&(s.current=!0,e()),i.current=t},[t,n,e]);let l=()=>r==="account"?_e.createElement(_e.Fragment,null,_e.createElement(id,null,_e.createElement(B3,null,"UI"),_e.createElement("div",null,_e.createElement(ad,null,jt.NAME," account"),_e.createElement(sd,null,"Deterministic Figma \u2194 code comparison"))),_e.createElement(ld,null,_e.createElement(q4,{onConnect:e}))):r==="project"?_e.createElement(_e.Fragment,null,_e.createElement(id,null,_e.createElement(U1,null,_e.createElement(O3,null)),_e.createElement("div",null,_e.createElement(ad,null,"Project"),_e.createElement(sd,null,"The Storybook project being compared"))),t?_e.createElement(ld,null,_e.createElement(J4,null)):_e.createElement(j1,null,"Sign in on the ",_e.createElement("strong",null,"Account")," tab first to choose a project.")):_e.createElement(_e.Fragment,null,_e.createElement(id,null,_e.createElement(U1,null,_e.createElement(Mo,null)),_e.createElement("div",null,_e.createElement(ad,null,"Figma integration"),_e.createElement(sd,null,"Source of truth for design tokens"))),t&&n?_e.createElement(ld,null,_e.createElement(w3,{hideHeader:!0})):_e.createElement(j1,null,t?"Select a project on the Project tab before connecting Figma.":"Sign in on the Account tab first, then pick a project to connect Figma."));return _e.createElement(v3,{onMouseDown:c=>{u.current=c.target===c.currentTarget},onClick:c=>{u.current&&c.target===c.currentTarget&&e()}},_e.createElement(S3,{onClick:c=>c.stopPropagation()},_e.createElement(k3,null,_e.createElement(C3,null,_e.createElement(I3,null,"Settings"),_e.createElement(T3,null,"v","0.12.2")),_e.createElement(E3,{onClick:e,title:"Close settings","aria-label":"Close"},"\xD7")),_e.createElement(R3,null,_e.createElement(A3,null,HU.map(c=>{let p=c.icon,g=r===c.id;return _e.createElement(F3,{key:c.id,active:g,onClick:()=>o(c.id)},g&&_e.createElement(P3,null),_e.createElement(p,null),_e.createElement(M3,null,c.label))})),_e.createElement(L3,null,l())),_e.createElement(z3,null,_e.createElement(D3,null,jt.NAME," \xB7 settings synced"),_e.createElement(_3,null,_e.createElement(N3,{onClick:e},"Cancel"),_e.createElement(Qt,{onClick:e},"Done")))))};ke();on();import Wt from"react";import so from"react";import{styled as hn,keyframes as UU}from"storybook/theming";var bi=hn.div({marginTop:"10px",padding:"12px",borderRadius:"8px",border:`1px solid ${te.border}`,background:te.formBg,display:"flex",flexDirection:"column",gap:"10px"}),H3=hn.button({display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",width:"100%",padding:"9px",borderRadius:"8px",border:`1px solid ${te.border}`,background:te.card,color:te.text,fontSize:"13px",fontWeight:600,cursor:"pointer","&:hover":{background:te.formBg}}),Cl=hn.div({fontSize:"11px",color:te.muted,textAlign:"center"}),U3=hn.div({display:"flex",alignItems:"center",gap:"8px","&::before, &::after":{content:'""',flex:1,height:"1px",background:te.border},fontSize:"11px",color:te.muted}),j3=hn.button({width:"100%",padding:"9px",borderRadius:"6px",border:`1px dashed ${W}`,background:te.card,color:W,fontSize:"12px",fontWeight:600,cursor:"pointer","&:hover":{background:te.accentTint},"&:disabled":{opacity:.6,cursor:"default"}}),wi=hn.label({fontSize:"11px",fontWeight:600,color:te.subText,display:"block",marginBottom:"4px"}),Ki=hn.input({width:"100%",padding:"7px 10px",fontSize:"12px",borderRadius:"6px",border:`1px solid ${te.border}`,background:te.card,color:te.text,outline:"none","&:focus":{borderColor:W},"&:disabled":{background:te.formBg,color:te.muted}}),V3=hn.select({width:"100%",padding:"7px 10px",fontSize:"12px",borderRadius:"6px",border:`1px solid ${te.border}`,background:te.card,color:te.text}),ao=hn.button(({disabled:e})=>({width:"100%",padding:"8px",borderRadius:"6px",border:"none",fontSize:"12px",fontWeight:600,color:te.card,cursor:e?"not-allowed":"pointer",background:W,opacity:e?.5:1,"&:hover":e?{}:{background:ei}})),V1=hn.div({marginTop:"10px",fontSize:"11px",lineHeight:1.4,padding:"8px 10px",borderRadius:"6px",background:te.calloutBg,color:te.calloutText}),W3=hn.div({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"}),G3=hn.div({display:"flex",flexDirection:"column",gap:"8px",padding:"10px",borderRadius:"6px",border:`1px solid ${te.border}`,background:te.card}),q3=hn.div({display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:"11px",color:te.subText}),Y3=hn.span({fontVariantNumeric:"tabular-nums",color:te.muted}),K3=hn.div({height:"4px",width:"100%",borderRadius:"999px",background:te.track,overflow:"hidden"}),X3=hn.div(({pct:e})=>({height:"100%",width:`${Math.min(100,Math.max(0,e))}%`,borderRadius:"999px",background:W,transition:"width 0.3s ease"})),jU=UU`
|
|
92
92
|
0% { transform: translateX(-120%); }
|
|
93
93
|
100% { transform: translateX(520%); }
|
|
94
94
|
`,J3=hn.div({height:"100%",width:"20%",borderRadius:"999px",background:W,animation:`${jU} 1.1s ease-in-out infinite`}),Q3=hn.span({fontVariantNumeric:"tabular-nums",color:te.muted}),Z3=hn.div({fontSize:"11px",color:te.muted}),e6=hn.div({fontSize:"11px",fontStyle:"italic",color:te.muted}),Xi=hn.div({fontSize:"11px",lineHeight:1.4,color:Ye.redText});var VU=so.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24","aria-hidden":"true"},so.createElement("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.75h3.57c2.08-1.92 3.28-4.74 3.28-8.07z"}),so.createElement("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.75c-.99.66-2.25 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),so.createElement("path",{fill:"#FBBC05",d:"M5.84 14.12A6.6 6.6 0 0 1 5.49 12c0-.74.13-1.46.35-2.12V7.04H2.18A11 11 0 0 0 1 12c0 1.78.43 3.45 1.18 4.96l3.66-2.84z"}),so.createElement("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.04l3.66 2.84C6.71 7.31 9.14 5.38 12 5.38z"})),t6=()=>{let{startOAuth:e,oauthPending:t,startAnonymous:n,anonPending:r}=no(),o=t||r;return so.createElement(bi,null,so.createElement(H3,{onClick:e,disabled:o},VU," ",t?"Opening sign-in\u2026":"Continue with Google"),so.createElement(Cl,null,"New or returning \u2014 we'll take you to the right place."),so.createElement(U3,null,"or"),so.createElement(j3,{onClick:n,disabled:o},r?"Starting\u2026":"Try without signing in \u2192"),so.createElement(Cl,null,"Explore with your own Figma file \u2014 no sign-up needed. Sign up later to save your work."))};ke();import zn,{useEffect as WU,useState as dd}from"react";import{styled as cn}from"storybook/theming";var n6='Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif',r6=cn.div({width:"100%",maxWidth:"520px",margin:"24px auto",background:te.card,border:`1px solid ${te.border}`,borderRadius:"14px",boxShadow:"0 4px 16px rgba(0,0,0,0.06)",padding:"20px",fontFamily:n6,color:te.text}),o6=cn.div({display:"flex",alignItems:"center",gap:"10px"}),i6=cn.div({width:"28px",height:"28px",borderRadius:"7px",background:W,color:te.card,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",fontWeight:700,flexShrink:0}),a6=cn.h3({margin:0,flex:1,fontSize:"16px",fontWeight:600,color:te.text}),s6=cn.span({fontSize:"12px",fontWeight:600,color:te.muted,background:te.track,borderRadius:"999px",padding:"3px 10px",whiteSpace:"nowrap"}),l6=cn.div({height:"4px",borderRadius:"999px",background:te.track,margin:"12px 0 4px",overflow:"hidden"}),c6=cn.div(({pct:e})=>({height:"100%",width:`${e}%`,background:W,transition:"width 0.3s ease"})),u6=cn.div(({current:e})=>({display:"flex",alignItems:"flex-start",gap:"12px",padding:"16px 6px 16px 12px",borderTop:`1px solid ${te.border}`,borderLeft:e?`3px solid ${W}`:"3px solid transparent"})),d6=cn.div(({state:e})=>({width:"22px",height:"22px",borderRadius:"50%",flexShrink:0,marginTop:"1px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",fontWeight:700,...e==="complete"?{background:te.green,color:te.card,border:"none"}:e==="current"?{background:te.card,color:W,border:`2px solid ${W}`}:{background:te.card,color:te.locked,border:`1px solid ${te.border}`}})),p6=cn.div({flex:1,minWidth:0}),g6=cn.div({display:"flex",alignItems:"center",justifyContent:"space-between",gap:"12px"}),f6=cn.div(({locked:e})=>({fontSize:"14px",fontWeight:600,color:e?te.locked:te.text})),m6=cn.div({fontSize:"12px",color:te.muted,marginTop:"2px",lineHeight:1.4}),h6=cn.span({fontSize:"12px",color:te.muted,flexShrink:0}),x6=cn.button({flexShrink:0,fontSize:"12px",fontWeight:600,padding:"6px 12px",borderRadius:"6px",border:"none",cursor:"not-allowed",background:te.lockedBtnBg,color:te.locked}),y6=cn.div({textAlign:"center",padding:"20px 0 6px",borderTop:`1px solid ${te.border}`,marginTop:"8px"}),b6=cn.div({width:"40px",height:"40px",borderRadius:"50%",background:te.green,color:te.card,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"20px",margin:"0 auto 10px"}),w6=cn.div({fontSize:"16px",fontWeight:600,color:te.text,marginBottom:"14px"}),v6=cn.button({background:W,color:te.card,border:"none",borderRadius:"8px",padding:"10px 20px",fontSize:"13px",fontWeight:600,cursor:"pointer","&:hover":{background:ei}}),S6=cn.div({fontSize:"11px",color:te.muted,marginTop:"12px"}),k6=cn.div({borderTop:`1px solid ${te.border}`,marginTop:"4px",paddingTop:"14px",textAlign:"center"}),ud=cn.button({background:"none",border:"none",fontSize:"12px",fontWeight:500,color:te.muted,cursor:"pointer",fontFamily:n6,"&:hover":{color:te.text}});var C6=e=>(e||"").replace(/\/+$/,"").split("/").pop()||"",I6=()=>{let{projects:e,selectedProjectId:t,setSelectedProjectId:n,currentStorybookPath:r}=Ke(),{createProject:o}=Ir(),i=qh(e,t,r),[a,s]=dd(i.length>0?"select":"create"),[u,l]=dd(()=>C6(r)),[c,p]=dd(r||""),[g,d]=dd(!1);WU(()=>{r&&(p(y=>y||r),l(y=>y||C6(r)))},[r]);let f=async()=>{if(!(!u.trim()||g))try{d(!0);let y=await o({name:u.trim(),storybookRoot:c.trim()||void 0});n(y.id)}finally{d(!1)}};return a==="select"&&i.length>0?zn.createElement(bi,null,zn.createElement("div",null,zn.createElement(wi,null,"Project"),zn.createElement(V3,{value:t||"",onChange:y=>y.target.value==="__new"?s("create"):n(y.target.value||null)},zn.createElement("option",{value:""},"Select a project\u2026"),i.map(y=>zn.createElement("option",{key:y.id,value:y.id},y.name)),zn.createElement("option",{value:"__new"},"+ Create new project"))),zn.createElement(ao,{disabled:!t,onClick:()=>{}},"Use this project")):zn.createElement(bi,null,zn.createElement(W3,null,zn.createElement("div",null,zn.createElement(wi,null,"Name"),zn.createElement(Ki,{value:u,onChange:y=>l(y.target.value),placeholder:"my-storybook"})),zn.createElement("div",null,zn.createElement(wi,null,"Storybook path"),zn.createElement(Ki,{value:c,onChange:y=>p(y.target.value),placeholder:".storybook"}))),i.length>0&&zn.createElement(ud,{onClick:()=>s("select")},"\u2190 Use an existing project"),zn.createElement(ao,{disabled:!u.trim()||g,onClick:f},g?"Creating\u2026":"Create project"))};ke();import Vt,{useEffect as _6,useState as gd}from"react";ke();De();ct();He();import{useCallback as Qa,useEffect as GU,useRef as W1,useState as qU}from"react";var pd=K(),T6=3e3,YU=3,KU=12e4,E6={status:"idle",pagesDone:0,pagesTotal:0,componentSets:0,componentCount:0,needsFigmaAuth:!1,fileForbidden:!1};function R6(){let{sessionToken:e}=ye(),[t,n]=qU(E6),r=W1(null),o=W1(null),i=W1({lastDone:-1,stalls:0}),a=Qa(()=>{o.current&&(clearInterval(o.current),o.current=null)},[]),s=Qa(g=>{let d=g?.crawlProgress;if(!d)return"none";let f=g.thumbnailProgress?.total??g.enrichmentProgress?.total??0,y=g.componentCount??0;if(d.status==="complete")return n({status:"complete",pagesDone:d.pagesTotal||d.pagesDone||0,pagesTotal:d.pagesTotal||d.pagesDone||0,componentSets:f,componentCount:y}),"stop";if(d.status==="error")return n(S=>({...S,status:"error",error:d.error||"Figma sync failed."})),"stop";let I=d.status==="paused";if(!I&&d.updatedAt){let S=Date.now()-Date.parse(d.updatedAt);if(Number.isFinite(S)&&S>KU)return y>0?(n({status:"complete",pagesDone:d.pagesDone??0,pagesTotal:d.pagesTotal??d.pagesDone??0,componentSets:f,componentCount:y}),"stop"):(n(x=>({...x,status:"error",error:"Figma indexing stopped responding before it finished. Reload to retry."})),"stop")}return n({status:"crawling",pagesDone:d.pagesDone??0,pagesTotal:d.pagesTotal??0,componentSets:f,componentCount:y}),I?"paused":"active"},[]),u=Qa(g=>{let d=r.current;if(!d||!e)return;let f=i.current;if(g>f.lastDone)f.lastDone=g,f.stalls=0;else if(++f.stalls>YU){n(y=>({...y,status:"error",error:"Figma indexing stalled \u2014 reload to retry."})),a();return}Z(`${pd}/api/figma/crawl`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify({projectId:d})}).catch(()=>{})},[e,a]),l=Qa(async()=>{let g=r.current;if(!(!g||!e))try{let d=await Z(`${pd}/api/figma/cache-status?projectId=${g}`,{headers:{Authorization:`Bearer ${e}`}});if(!d.ok)return;let f=await d.json(),y=s(f);y==="stop"?a():y==="paused"&&u(f?.crawlProgress?.pagesDone??0)}catch(d){w.debug("[useFigmaSync] poll error (will retry):",d)}},[e,a,s,u]),c=Qa(async(g,d)=>{if(e){r.current=g,i.current={lastDone:-1,stalls:0},n({...E6,status:"starting"});try{let f=await Z(`${pd}/api/figma/crawl`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify(d?.length?{projectId:g,pageIds:d}:{projectId:g})});if(!f.ok&&f.status!==202){let y=!1,I=!1,S="Couldn't start the Figma sync. Check your connection.";try{let x=await f.json();x?.requiresAuth?(y=!0,S="Your Figma connection expired. Reconnect Figma to sync."):x?.fileForbidden?(I=!0,S=x.error||"You don't have access to this Figma file."):x?.error&&(S=x.error)}catch{}w.error("[useFigmaSync] crawl rejected:",f.status,S),n(x=>({...x,status:"error",error:S,needsFigmaAuth:y,fileForbidden:I}));return}}catch(f){w.error("[useFigmaSync] failed to start crawl:",f),n(y=>({...y,status:"error",error:"Couldn't start the Figma sync. Check your connection."}));return}a(),o.current=setInterval(l,T6),l()}},[e,l,a]),p=Qa(async g=>{if(!(!e||!g)){r.current=g;try{let d=await Z(`${pd}/api/figma/cache-status?projectId=${g}`,{headers:{Authorization:`Bearer ${e}`}});if(!d.ok)return;let f=await d.json(),y=s(f);(y==="active"||y==="paused")&&(a(),o.current=setInterval(l,T6),y==="paused"&&u(f?.crawlProgress?.pagesDone??0))}catch(d){w.debug("[useFigmaSync] resume error (ignored):",d)}}},[e,l,a,s,u]);return GU(()=>a,[a]),{...t,startSync:c,resume:p,isComplete:t.status==="complete"}}De();ct();import{useCallback as A6,useState as Il}from"react";var XU=K(),G1="uicopilot_guest_pat_saved";function F6(e){let[t,n]=Il(""),[r,o]=Il(!1),[i,a]=Il(!1),[s,u]=Il(null),[l,c]=Il(()=>typeof localStorage<"u"&&!!e&&localStorage.getItem(G1)===e),p=A6(d=>{c(d),!(typeof localStorage>"u")&&(d&&e?localStorage.setItem(G1,e):localStorage.removeItem(G1))},[e]),g=A6(async()=>{let d=t.trim();if(!d)return!1;let f=Yh(d);if(f)return u(Kh(f)),!1;a(!0),u(null);try{let y=await Z(`${XU}/api/figma/pat`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify({token:d})}),I=await y.json().catch(()=>({}));if(!y.ok||!I.success)throw new Error(I.error||"Invalid Figma token.");return p(!0),!0}catch(y){return u(y instanceof Error?y.message:"Couldn't save the Figma token."),!1}finally{a(!1)}},[t,e,p]);return{pat:t,setPat:n,showPat:r,setShowPat:o,patBusy:i,patError:s,patInputError:Kh(Yh(t)),patSaved:l,setPatSaved:p,savePat:g}}import Za from"react";import{styled as q1}from"storybook/theming";var JU=q1.div({marginTop:"10px",border:`1px solid ${te.border}`,borderRadius:"8px",background:te.card,padding:"14px 12px",display:"flex",flexDirection:"column",gap:"8px"}),QU=q1.div({fontSize:"12px",fontWeight:700,color:te.text}),ZU=q1.div({fontSize:"11px",lineHeight:1.5,color:te.muted}),P6=({published:e,onChoosePages:t})=>Za.createElement(JU,null,Za.createElement(QU,null,"No indexable components on the pages you picked"),Za.createElement(ZU,null,"Only ",Za.createElement("strong",null,"component sets")," and"," ",Za.createElement("strong",null,"standalone components")," are indexed \u2014 not plain frames or example screens."," ",e?"Pick the pages that showed a component count.":"This file has no published components, so we couldn't tell which pages hold them \u2014 try selecting the pages with your component library."),Za.createElement(ao,{onClick:t},"Choose different pages"));import Wo from"react";import{styled as B6}from"storybook/theming";import*as Co from"react";var M6=Co.forwardRef(({color:e="currentColor",size:t=14,...n},r)=>Co.createElement("svg",{width:t,height:t,viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:r,...n},Co.createElement("path",{d:"M7 9.5a2.5 2.5 0 100-5 2.5 2.5 0 000 5z",fill:e}),Co.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M14 7l-.21.293C13.669 7.465 10.739 11.5 7 11.5S.332 7.465.21 7.293L0 7l.21-.293C.331 6.536 3.261 2.5 7 2.5s6.668 4.036 6.79 4.207L14 7zM2.896 5.302A12.725 12.725 0 001.245 7c.296.37.874 1.04 1.65 1.698C4.043 9.67 5.482 10.5 7 10.5c1.518 0 2.958-.83 4.104-1.802A12.72 12.72 0 0012.755 7c-.297-.37-.875-1.04-1.65-1.698C9.957 4.33 8.517 3.5 7 3.5c-1.519 0-2.958.83-4.104 1.802z",fill:e}))),L6=Co.forwardRef(({color:e="currentColor",size:t=14,...n},r)=>Co.createElement("svg",{width:t,height:t,viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:r,...n},Co.createElement("path",{d:"M1.854 1.146a.5.5 0 10-.708.708l11 11a.5.5 0 00.708-.708l-11-11zM11.104 8.698c-.177.15-.362.298-.553.439l.714.714a13.25 13.25 0 002.526-2.558L14 7l-.21-.293C13.669 6.536 10.739 2.5 7 2.5c-.89 0-1.735.229-2.506.58l.764.763A4.859 4.859 0 017 3.5c1.518 0 2.958.83 4.104 1.802A12.724 12.724 0 0112.755 7a12.72 12.72 0 01-1.65 1.698zM.21 6.707c.069-.096 1.03-1.42 2.525-2.558l.714.714c-.191.141-.376.288-.553.439A12.725 12.725 0 001.245 7c.296.37.874 1.04 1.65 1.698C4.043 9.67 5.482 10.5 7 10.5a4.86 4.86 0 001.742-.344l.764.764c-.772.351-1.616.58-2.506.58C3.262 11.5.332 7.465.21 7.293L0 7l.21-.293z",fill:e}),Co.createElement("path",{d:"M4.5 7c0-.322.061-.63.172-.914l3.242 3.242A2.5 2.5 0 014.5 7zM9.328 7.914L6.086 4.672a2.5 2.5 0 013.241 3.241z",fill:e})));var ej=B6.div({position:"relative"}),tj=B6.button(({theme:e})=>({position:"absolute",right:6,top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center",justifyContent:"center",background:"none",border:"none",padding:4,cursor:"pointer",color:e.color.mediumdark,"&:hover":{color:e.color.defaultText}})),z6=({pat:e,setPat:t,showPat:n,setShowPat:r,error:o,disabled:i=!1,onSubmit:a})=>Wo.createElement("div",null,Wo.createElement(wi,null,"Figma personal access token"),Wo.createElement(ej,null,Wo.createElement(Ki,{type:n?"text":"password",value:e,onChange:s=>t(s.target.value),onKeyDown:s=>{s.key==="Enter"&&e.trim()&&!i&&a?.()},placeholder:"figd_\u2026",disabled:i,style:{paddingRight:32}}),Wo.createElement(tj,{type:"button",onClick:()=>r(s=>!s),"aria-label":n?"Hide token":"Show token",title:n?"Hide token":"Show token"},n?Wo.createElement(L6,null):Wo.createElement(M6,null))),o&&Wo.createElement(Xi,null,"\u26A0 ",o),Wo.createElement(Cl,null,"Used only to fetch your frames \u2014 it isn't stored anywhere."));import Ur,{useEffect as nj,useState as rj}from"react";var oj=15,ij=e=>`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`,D6=({complete:e,pagesDone:t,pagesTotal:n,componentSets:r})=>{let[o,i]=rj(0);nj(()=>{if(e)return;let u=setInterval(()=>i(l=>l+1),1e3);return()=>clearInterval(u)},[e]);let a=n>1,s=a?t/n*100:0;return Ur.createElement(G3,null,Ur.createElement(q3,null,Ur.createElement("span",null,e?"Indexed your Figma components \u2713":"Reading your Figma components\u2026"),!e&&Ur.createElement(Y3,null,a&&Ur.createElement("span",null,`${t} / ${n}`),a&&Ur.createElement("span",{"aria-hidden":!0}," \xB7 "),Ur.createElement(Q3,null,ij(o)))),Ur.createElement(K3,null,e||a?Ur.createElement(X3,{pct:e?100:s}):Ur.createElement(J3,null)),r>0&&Ur.createElement(Z3,null,r," component sets"),!e&&o>=oj&&Ur.createElement(e6,null,"Large component sets can take a minute to index\u2026"))};var N6=({figmaExpired:e=!1})=>{let{selectedProjectId:t}=Ke(),{updateProject:n,fetchProjects:r,selectedProject:o}=Ir(),{startOAuth:i,oauthPending:a,isAnonymous:s,sessionToken:u}=no(),l=F6(u),{patSaved:c,setPatSaved:p,savePat:g}=l,d=R6(),{resume:f}=d,[y,I]=gd(()=>o?.figmaFileId??""),[S,x]=gd(!1),[M,z]=gd(!1),[O,L]=gd(!1),_=M&&(d.status==="idle"||O),m=Yu(t,_),k=Ku(),C=B=>{I(B),M&&(z(!1),L(!1))},E=B=>{t&&(Ju(t,B),L(!1),d.startSync(t,B))},h=()=>{L(!0),m.reload()};_6(()=>{t&&f(t)},[t,f]),_6(()=>{d.isComplete&&r()},[d.isComplete,r]);let b=async()=>{if(!(!y.trim()||!t||S)&&!gi(pl(y)))try{if(x(!0),s&&!c&&!await g())return;await n(t,{figmaFileUrl:y.trim()}),L(!1),z(!0)}finally{x(!1)}},R=pl(y);if(e&&d.status==="idle")return Vt.createElement(Vt.Fragment,null,Vt.createElement(V1,null,"\u26A0 Requires a Figma Dev or Full seat \u2014 free/Viewer seats can't grant design-read access."),Vt.createElement(bi,null,Vt.createElement(Xi,null,"Your Figma connection expired. Reconnect to finish setup and run reviews."),Vt.createElement(ao,{disabled:a,onClick:i},a?"Opening Figma sign-in\u2026":"Reconnect Figma")));let v=s&&!c,A=v&&(!l.pat.trim()||!!l.patInputError);return Vt.createElement(Vt.Fragment,null,Vt.createElement(V1,null,"\u26A0 Requires a Figma Dev or Full seat \u2014 free/Viewer seats can't grant design-read access."),Vt.createElement(bi,null,Vt.createElement("div",null,Vt.createElement(wi,null,"Figma file URL"),Vt.createElement(Ki,{value:y,onChange:B=>C(B.target.value),onKeyDown:B=>{B.key==="Enter"&&y.trim()&&!S&&!gi(R)&&b()},placeholder:"https://figma.com/file/...",disabled:d.status!=="idle"&&d.status!=="error"})),v&&Vt.createElement(z6,{pat:l.pat,setPat:l.setPat,showPat:l.showPat,setShowPat:l.setShowPat,error:l.patError||l.patInputError,disabled:S,onSubmit:()=>{!gi(R)&&!A&&b()}}),d.status==="error"?Vt.createElement(Vt.Fragment,null,Vt.createElement(Xi,null,"\u26A0 ",d.error||"Figma sync failed."),R&&Vt.createElement(Xi,null,"\u26A0 ",gl(R)),d.needsFigmaAuth?s?Vt.createElement(ao,{onClick:()=>p(!1)},"Re-enter Figma token"):Vt.createElement(ao,{disabled:a,onClick:i},a?"Opening Figma sign-in\u2026":"Reconnect Figma"):Vt.createElement(ao,{disabled:!y.trim()||S||gi(R)||A,onClick:b},S?"Connecting\u2026":"Try again")):_?Vt.createElement(td,{stories:k.stories,pages:m.pages,published:m.published,loading:m.loading,error:m.error,busy:S,initialSelection:t?qa(t):void 0,emptyHint:"Select at least one page to import.",onReload:m.reload,onCancel:()=>{z(!1),L(!1)},onImport:E}):d.status==="complete"&&d.componentCount===0?Vt.createElement(P6,{published:m.published,onChoosePages:h}):d.status==="idle"?Vt.createElement(Vt.Fragment,null,R&&Vt.createElement(Xi,null,"\u26A0 ",gl(R)),Vt.createElement(ao,{disabled:!y.trim()||S||gi(R)||A,onClick:b},S?"Connecting\u2026":"Choose pages to import")):Vt.createElement(D6,{complete:d.status==="complete",pagesDone:d.pagesDone,pagesTotal:d.pagesTotal,componentSets:d.componentSets})))};var aj=["Sign in with Google \u2014 one click, no password.","Pick an existing project or create a new one.","Connect Figma and we'll index your components."],O6=[null,"Set up project","Connect Figma"],$6=({onSkip:e,canSkip:t=!1,figmaExpired:n=!1})=>{let{isConnected:r,sessionToken:o}=ye(),{projects:i,selectedProjectId:a}=Ke(),s=!!o&&o.startsWith("uic_anon_"),u=i.find(S=>S.id===a),l=r,c=l&&!!a,p=!!u?.figmaFileId&&!!u?.figmaFramesCacheUrl,d=[{title:s?"Trying without an account":"Connect your account",done:l},{title:"Set up your project",done:c},{title:"Connect Figma & sync",done:c&&p&&!n}],f=d.filter(S=>S.done).length,y=f===d.length,I=d.findIndex(S=>!S.done);return Wt.createElement(r6,null,Wt.createElement(o6,null,Wt.createElement(i6,null,"UI"),Wt.createElement(a6,null,"Get started with ",jt.NAME),Wt.createElement(s6,null,"Setup \xB7 ",f," of ",d.length)),Wt.createElement(l6,null,Wt.createElement(c6,{pct:f/d.length*100})),y?Wt.createElement(y6,null,Wt.createElement(b6,null,"\u2713"),Wt.createElement(w6,null,"You're all set."),Wt.createElement(v6,{onClick:e},"Go to your stories \u2192"),Wt.createElement(S6,null,"\u2728 AI review coming soon.")):Wt.createElement(Wt.Fragment,null,d.map((S,x)=>{let M=S.done?"complete":x===I?"current":"locked",z=M==="current";return Wt.createElement(u6,{key:S.title,current:z},Wt.createElement(d6,{state:M},M==="complete"?"\u2713":x+1),Wt.createElement(p6,null,Wt.createElement(g6,null,Wt.createElement("div",null,Wt.createElement(f6,{locked:M==="locked"},S.title),M!=="complete"&&Wt.createElement(m6,null,aj[x])),M==="complete"?Wt.createElement(h6,null,x===0&&s?"Guest":"Done"):M==="locked"&&O6[x]&&Wt.createElement(x6,{disabled:!0},O6[x])),z&&x===0&&Wt.createElement(t6,null),z&&x===1&&Wt.createElement(I6,null),z&&x===2&&Wt.createElement(N6,{figmaExpired:n})))}),t&&Wt.createElement(k6,null,Wt.createElement(ud,{onClick:e},"Already set up? Skip to the review panel \u2192"))))};import Ie,{useEffect as i5,useMemo as lV,useState as a5,useRef as cV}from"react";import{styled as xn,keyframes as uV}from"storybook/theming";ke();on();on();function Y1(e){let t=e.complianceScore??0;if(!e.issues||e.issues.length===0)return{score:t,band:e.issues?"A":void 0};let n=eu(e.issues.map(r=>({...r,dismissed:r.dismissed??!1})));return{score:Math.min(t,js[n]),band:n}}ke();import Dn,{useState as sj}from"react";import{styled as hr}from"storybook/theming";var Go=[{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",provider:"anthropic",description:"Current default \u2014 latest Sonnet, best balance of speed and quality"},{id:"claude-sonnet-4-5-20250929",name:"Claude Sonnet 4.5",provider:"anthropic",description:"Previous default \u2014 proven for design comparison"},{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 lj=hr.div(({theme:e})=>({display:"inline-flex",alignItems:"center",flexWrap:"wrap",gap:`${e.layoutMargin*.6}px`})),cj=hr.span(({theme:e,disabled:t})=>({display:"inline-flex",alignItems:"center",gap:"4px",height:"18px",padding:"0 2px 0 6px",backgroundColor:e.background.content,color:e.color.defaultText,fontSize:"10.5px",fontWeight:500,borderRadius:"3px",border:`1px solid ${e.appBorderColor}`,opacity:t?.6:1,whiteSpace:"nowrap"})),uj=hr.span({width:"4px",height:"4px",borderRadius:"50%",backgroundColor:Ye.green,flexShrink:0}),dj=hr.button(({theme:e})=>({width:"12px",height:"12px",display:"inline-flex",alignItems:"center",justifyContent:"center",background:"none",border:"none",borderRadius:"2px",color:e.color.mediumdark,fontSize:"11px",lineHeight:1,cursor:"pointer",padding:0,"&:hover":{color:e.color.defaultText,backgroundColor:e.background.hoverable},"&:disabled":{cursor:"not-allowed",opacity:.5}})),pj=hr.div({position:"relative",display:"inline-block"}),gj=hr.button(({theme:e,disabled:t})=>({display:"inline-flex",alignItems:"center",gap:"2px",height:"18px",padding:"0 6px",background:"none",border:`1px dashed ${e.appBorderColor}`,borderRadius:"3px",color:e.color.mediumdark,fontSize:"10.5px",fontWeight:500,cursor:t?"not-allowed":"pointer",opacity:t?.5:1,whiteSpace:"nowrap",transition:"color 0.15s, border-color 0.15s","&:hover":{color:t?e.color.mediumdark:e.color.defaultText,borderColor:t?e.appBorderColor:e.color.mediumdark}})),fj=hr.div(({theme:e})=>({position:"absolute",top:"100%",left:0,marginTop:"4px",width:"240px",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"})),K1=hr.div(({theme:e})=>({borderBottom:`1px solid ${e.appBorderColor}`,"&:last-child":{borderBottom:"none"}})),X1=hr.div(({theme:e})=>({padding:"8px 12px",fontSize:"10px",fontWeight:600,color:e.textMutedColor,textTransform:"uppercase",letterSpacing:"0.5px",backgroundColor:e.background.app})),mj=hr.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}})),hj=hr.input({cursor:"pointer",flexShrink:0,"&:disabled":{cursor:"not-allowed"}}),xj=hr.div({flex:1,minWidth:0}),yj=hr.div({fontSize:"12px",fontWeight:500,marginBottom:"2px"}),bj=hr.div(({theme:e})=>({fontSize:"10px",color:e.textMutedColor,lineHeight:"1.2"})),wj=5,H6=()=>{let{selectedModels:e,toggleModel:t,isReviewing:n}=ge(),[r,o]=sj(!1),i=Go.filter(d=>d.provider==="anthropic"&&!e.includes(d.id)),a=Go.filter(d=>d.provider==="openai"&&!e.includes(d.id)),s=Go.filter(d=>d.provider==="google"&&!e.includes(d.id)),u=Go.filter(d=>e.includes(d.id)),l=e.length<wj,c=(d,f)=>{f.stopPropagation(),e.length>1&&!n&&t(d)},p=d=>{let f=e.includes(d);f&&e.length===1||!f&&!l||n||(t(d),o(!1))},g=d=>{let f=e.includes(d.id),y=f&&e.length===1,I=n||y||!f&&!l;return Dn.createElement(mj,{key:d.id,disabled:I,onClick:()=>p(d.id)},Dn.createElement(hj,{type:"checkbox",checked:f,disabled:I,onChange:()=>{},onClick:S=>S.stopPropagation()}),Dn.createElement(xj,null,Dn.createElement(yj,null,d.name),d.description&&Dn.createElement(bj,null,d.description)))};return Dn.createElement(lj,null,u.map(d=>Dn.createElement(cj,{key:d.id,disabled:n},Dn.createElement(uj,null),d.name,e.length>1&&Dn.createElement(dj,{disabled:n,onClick:f=>c(d.id,f),title:"Remove model"},"\xD7"))),l&&Dn.createElement(pj,null,Dn.createElement(gj,{disabled:n,onClick:()=>o(!r),title:"Add a model"},"+ Add"),r&&Dn.createElement(fj,null,i.length>0&&Dn.createElement(K1,null,Dn.createElement(X1,null,"Anthropic"),i.map(g)),a.length>0&&Dn.createElement(K1,null,Dn.createElement(X1,null,"OpenAI"),a.map(g)),s.length>0&&Dn.createElement(K1,null,Dn.createElement(X1,null,"Google"),s.map(g)))))};import jr,{useState as J1,useEffect as Tj,useCallback as Ej}from"react";import{styled as vi}from"storybook/theming";import fd,{useState as vj,useCallback as U6}from"react";import{styled as md}from"storybook/theming";var Sj=md.span({position:"relative",display:"inline-flex"}),kj=md.div(({theme:e,side:t,align:n,visible:r})=>({position:"absolute",...t==="top"?{bottom:"calc(100% + 6px)"}:{top:"calc(100% + 6px)"},...n==="center"?{left:"50%",transform:"translateX(-50%)"}:n==="end"?{right:0}:{left:0},zIndex:2e3,width:"max-content",maxWidth:"240px",padding:`${e.layoutMargin*.6}px ${e.layoutMargin}px`,borderRadius:e.appBorderRadius*2,backgroundColor:e.background.content,color:e.color.defaultText,border:`1px solid ${e.appBorderColor}`,boxShadow:e.base==="dark"?"0 6px 20px rgba(0, 0, 0, 0.5)":"0 6px 20px rgba(0, 0, 0, 0.15)",fontSize:"11px",lineHeight:1.5,textAlign:"left",whiteSpace:"normal",pointerEvents:"none",opacity:r?1:0,visibility:r?"visible":"hidden",transition:"opacity 0.12s ease"})),Cj=md.div(({theme:e})=>({fontWeight:e.typography.weight.bold,marginBottom:"2px",color:e.color.defaultText})),Ij=md.div(({theme:e})=>({color:e.color.mediumdark})),Io=({text:e,title:t,side:n="top",align:r="center",children:o,className:i})=>{let[a,s]=vj(!1),u=U6(()=>s(!0),[]),l=U6(()=>s(!1),[]);return fd.createElement(Sj,{className:i,onMouseEnter:u,onMouseLeave:l,onFocus:u,onBlur:l},o,fd.createElement(kj,{side:n,align:r,visible:a,role:"tooltip"},t&&fd.createElement(Cj,null,t),fd.createElement(Ij,null,e)))};ke();De();ct();var Rj=vi.div(({theme:e})=>({display:"flex",alignItems:"center",flexWrap:"wrap",gap:"10px",padding:`${e.layoutMargin*.7}px ${e.layoutMargin*1.2}px`,backgroundColor:e.background.content,borderBottom:`1px solid ${e.appBorderColor}`})),Aj=vi.span(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:"6px",height:"26px",padding:"0 10px 0 5px",borderRadius:"999px",border:`1px solid ${Mi.pillBorder}`,background:`linear-gradient(90deg, ${Mi.pillBg} 0%, ${e.background.content} 60%)`,boxShadow:"0 1px 2px rgba(0,0,0,0.06)",cursor:"help",userSelect:"none"})),Fj=vi.span({width:"20px",height:"20px",display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",color:"#fff",background:`linear-gradient(135deg, ${Mi.iconFrom} 0%, ${Mi.iconTo} 100%)`,"& svg":{width:"12px",height:"12px"}}),Pj=vi.span(({theme:e})=>({fontSize:"11px",fontWeight:e.typography.weight.bold,color:e.color.defaultText,lineHeight:1})),Mj=vi.span({display:"inline-flex",alignItems:"center",height:"16px",padding:"0 6px",borderRadius:"3px",backgroundColor:Mi.badgeBg,color:Mi.badgeText,fontSize:"9px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em"}),Lj=vi.button(({theme:e,active:t})=>({display:"inline-flex",alignItems:"center",gap:"6px",height:"26px",padding:"0 10px",borderRadius:"999px",fontSize:"11px",fontWeight:e.typography.weight.bold,cursor:"pointer",transition:"all 0.15s",border:`1px solid ${t?W:e.appBorderColor}`,backgroundColor:t?W:e.background.content,color:t?"#fff":e.color.mediumdark,boxShadow:t?"0 1px 2px rgba(0,0,0,0.08)":"none","& svg":{width:"12px",height:"12px"},"&:hover":{borderColor:W,color:t?"#fff":W},"&:disabled":{opacity:.6,cursor:"default"}})),Bj=vi.span(({theme:e,active:t})=>({marginLeft:"2px",padding:"1px 6px",borderRadius:"999px",fontFamily:e.typography.fonts.mono,fontVariantNumeric:"tabular-nums",fontSize:"10px",backgroundColor:t?"rgba(255,255,255,0.25)":e.background.app,color:t?"#fff":e.color.mediumdark})),zj=vi.span(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark})),Dj="Semantic review powered by UI Parity \u2014 catches what the deterministic checks can't (visual hierarchy, contrast intent, layout drift). Rolling out to everyone soon.",j6=()=>{let{sessionToken:e}=ye(),[t,n]=J1(null),[r,o]=J1(!1),[i,a]=J1(!1),s=l=>{typeof l.count=="number"&&n(l.count),typeof l.interested=="boolean"&&o(l.interested)};Tj(()=>{if(!e)return;let l=!0;return Z(`${K()}/api/ai-interest`,{headers:{Authorization:`Bearer ${e}`}}).then(c=>c.json()).then(c=>l&&s(c)).catch(()=>{}),()=>{l=!1}},[e]);let u=Ej(async()=>{if(!(!e||i)){a(!0);try{let l=await Z(`${K()}/api/ai-interest`,{method:r?"DELETE":"POST",headers:{Authorization:`Bearer ${e}`}});s(await l.json())}catch{}finally{a(!1)}}},[e,r,i]);return jr.createElement(Rj,null,jr.createElement(Io,{side:"bottom",text:Dj},jr.createElement(Aj,null,jr.createElement(Fj,{"aria-hidden":!0},jr.createElement(sc,null)),jr.createElement(Pj,null,"AI review with Claude"),jr.createElement(Mj,null,"Coming soon"))),jr.createElement(Io,{side:"bottom",text:r?"We'll prioritise the AI review rollout based on this signal. Click again to undo.":"Tell us you'd use this \u2014 helps us prioritise the rollout."},jr.createElement(Lj,{type:"button",active:r,disabled:i||!e,"aria-pressed":r,onClick:u},jr.createElement(my,null),r?"Thanks \u2014 noted!":"I want this",t!==null&&jr.createElement(Bj,{active:r},t))),jr.createElement(zj,null,"Today: deterministic checks (color, font, spacing, radius, border)."))};import ft,{useState as _j,useEffect as Nj}from"react";import{styled as _t,keyframes as es}from"storybook/theming";ke();var Oj=es`
|
|
@@ -249,7 +249,7 @@ ${"=".repeat(40)}
|
|
|
249
249
|
&:hover {
|
|
250
250
|
background: rgba(255, 255, 255, 0.3);
|
|
251
251
|
}
|
|
252
|
-
`,VQ=nr.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",gap:`${e.layoutMargin}px`,height:"28px",padding:`0 ${e.layoutMargin*1.2}px`,borderTop:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app,fontSize:"10px",color:e.color.mediumdark})),WQ=nr.span(({theme:e})=>({fontFamily:e.typography.fonts.mono,opacity:.7})),GQ=nr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*1.2}px`,fontFamily:e.typography.fonts.mono})),QT=nr.span(({theme:e,tone:t})=>({display:"inline-flex",alignItems:"center",gap:"4px",color:t,"& .muted":{color:e.color.mediumdark,fontWeight:400},"& .val":{fontWeight:e.typography.weight.bold}})),ZT=nr.div(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 24px",textAlign:"center",gap:"16px"})),eE=nr.div({fontSize:"32px"}),tE=nr.h3(({theme:e})=>({margin:0,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),nE=nr.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s2,color:e.color.mediumdark,maxWidth:"320px",lineHeight:1.5})),rE=nr.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})),oE=nr.span({flex:1}),iE=nr.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`}})),aE=()=>{let{selectedProjectId:e,projects:t,loadingProjects:n}=Ke(),{isConnected:r,sessionToken:o,authError:i}=ye(),{currentStoryId:a}=pt(),{currentReviewId:s,userRole:u,roleOverride:l,setRoleOverride:c,setFeatureFlags:p,pendingSettingsOpen:g,setPendingSettingsOpen:d,reviewHistory:f,validationUsage:y,featureFlags:I}=ge(),{figmaExpired:S}=KT(),[x,M]=NQ(!1);JT(()=>{g&&(M(!0),d(!1))},[g,d]);let z=()=>{c(null),o&&fetch(`${K()}/api/addon/flags`,{headers:{Authorization:`Bearer ${o}`}}).then(T=>T.json()).then(T=>{p({enableFixGeneration:!!T.enableFixGeneration,enableFixApply:!!T.enableFixApply,enableAutoMap:!!T.enableAutoMap,enableReviewBadges:!!T.enableReviewBadges,showCosts:!!T.showCosts,enableParallelReview:!!T.enableParallelReview,enableModelSelection:!!T.enableModelSelection,enableAiReview:!!T.enableAiReview})}).catch(()=>{})};Th(),jh(),YT(),zh(),Mh();let{notification:O,dismissNotification:L}=jT();JT(()=>{if(O){let T=setTimeout(L,5e3);return()=>clearTimeout(T)}},[O,L]);let _=t.find(T=>T.id===e),m=r&&!!e&&!!_,{onboarded:k,dismiss:C}=WT(),E=XT({sessionToken:o,selectedProjectId:e,selectedProjectLoaded:!!_,loadingProjects:n,projectsCount:t.length}),{loadingMapping:h}=pt(),b=m&&!!a&&!s&&h,R=f.find(T=>T.id===s),v=(R?.costUsd||0)+(y?.costUsd||0),A=(R?.inputTokens||0)+(R?.outputTokens||0)+(y?.inputTokens||0)+(y?.outputTokens||0),B=!!I.showCosts&&v>0,P=T=>T<.01?T.toFixed(4):T<.1?T.toFixed(3):T.toFixed(2),N=T=>T>=1e3?`${(T/1e3).toFixed(1)}K`:String(T);return st.createElement(pp,{header:st.createElement(gp,{toolbar:st.createElement(qm,{onOpenSettings:()=>M(!0)})}),footer:st.createElement(VQ,null,st.createElement(WQ,null,jt.NAME," v","0.12.
|
|
252
|
+
`,VQ=nr.div(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",gap:`${e.layoutMargin}px`,height:"28px",padding:`0 ${e.layoutMargin*1.2}px`,borderTop:`1px solid ${e.appBorderColor}`,backgroundColor:e.background.app,fontSize:"10px",color:e.color.mediumdark})),WQ=nr.span(({theme:e})=>({fontFamily:e.typography.fonts.mono,opacity:.7})),GQ=nr.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*1.2}px`,fontFamily:e.typography.fonts.mono})),QT=nr.span(({theme:e,tone:t})=>({display:"inline-flex",alignItems:"center",gap:"4px",color:t,"& .muted":{color:e.color.mediumdark,fontWeight:400},"& .val":{fontWeight:e.typography.weight.bold}})),ZT=nr.div(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 24px",textAlign:"center",gap:"16px"})),eE=nr.div({fontSize:"32px"}),tE=nr.h3(({theme:e})=>({margin:0,fontSize:e.typography.size.s3,fontWeight:e.typography.weight.bold,color:e.color.defaultText})),nE=nr.p(({theme:e})=>({margin:0,fontSize:e.typography.size.s2,color:e.color.mediumdark,maxWidth:"320px",lineHeight:1.5})),rE=nr.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})),oE=nr.span({flex:1}),iE=nr.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`}})),aE=()=>{let{selectedProjectId:e,projects:t,loadingProjects:n}=Ke(),{isConnected:r,sessionToken:o,authError:i}=ye(),{currentStoryId:a}=pt(),{currentReviewId:s,userRole:u,roleOverride:l,setRoleOverride:c,setFeatureFlags:p,pendingSettingsOpen:g,setPendingSettingsOpen:d,reviewHistory:f,validationUsage:y,featureFlags:I}=ge(),{figmaExpired:S}=KT(),[x,M]=NQ(!1);JT(()=>{g&&(M(!0),d(!1))},[g,d]);let z=()=>{c(null),o&&fetch(`${K()}/api/addon/flags`,{headers:{Authorization:`Bearer ${o}`}}).then(T=>T.json()).then(T=>{p({enableFixGeneration:!!T.enableFixGeneration,enableFixApply:!!T.enableFixApply,enableAutoMap:!!T.enableAutoMap,enableReviewBadges:!!T.enableReviewBadges,showCosts:!!T.showCosts,enableParallelReview:!!T.enableParallelReview,enableModelSelection:!!T.enableModelSelection,enableAiReview:!!T.enableAiReview})}).catch(()=>{})};Th(),jh(),YT(),zh(),Mh();let{notification:O,dismissNotification:L}=jT();JT(()=>{if(O){let T=setTimeout(L,5e3);return()=>clearTimeout(T)}},[O,L]);let _=t.find(T=>T.id===e),m=r&&!!e&&!!_,{onboarded:k,dismiss:C}=WT(),E=XT({sessionToken:o,selectedProjectId:e,selectedProjectLoaded:!!_,loadingProjects:n,projectsCount:t.length}),{loadingMapping:h}=pt(),b=m&&!!a&&!s&&h,R=f.find(T=>T.id===s),v=(R?.costUsd||0)+(y?.costUsd||0),A=(R?.inputTokens||0)+(R?.outputTokens||0)+(y?.inputTokens||0)+(y?.outputTokens||0),B=!!I.showCosts&&v>0,P=T=>T<.01?T.toFixed(4):T<.1?T.toFixed(3):T.toFixed(2),N=T=>T>=1e3?`${(T/1e3).toFixed(1)}K`:String(T);return st.createElement(pp,{header:st.createElement(gp,{toolbar:st.createElement(qm,{onOpenSettings:()=>M(!0)})}),footer:st.createElement(VQ,null,st.createElement(WQ,null,jt.NAME," v","0.12.2"),B&&st.createElement(GQ,null,st.createElement(QT,{tone:Ye.green},st.createElement("span",{className:"muted"},"cost"),st.createElement("span",{className:"val"},"$",P(v)),st.createElement("span",{className:"muted"},"/"),st.createElement("span",{className:"val"},"\u20AA",P(v*3.65))),A>0&&st.createElement(QT,{tone:nc},st.createElement("span",{className:"val"},"#"),st.createElement("span",{className:"val"},N(A)),st.createElement("span",{className:"muted"},"tokens"))))},O&&st.createElement($Q,{variant:O.variant||"success"},st.createElement(HQ,null,O.variant==="error"?"!":O.variant==="warning"?"\u26A0":"+"),st.createElement(UQ,null,O.message),st.createElement(jQ,{onClick:L},"x")),i&&st.createElement(rE,null,st.createElement("span",null,"\u26A0"),st.createElement(oE,null,i),st.createElement(iE,{onClick:()=>M(!0)},"Reconnect")),u==="admin"&&l&&st.createElement(rE,null,st.createElement("span",null,"\u{1F441}"),st.createElement(oE,null,"Previewing as ",l),st.createElement(iE,{onClick:z},"Exit preview")),E||b?st.createElement(Hl,{label:E?"Loading...":"Loading review..."}):i?st.createElement(ZT,null,st.createElement(eE,null,"\u2699"),st.createElement(tE,null,"Connection issue"),st.createElement(nE,null,"Session expired or dashboard unreachable. Please reconnect."),st.createElement(Qt,{onClick:()=>M(!0)},"Reconnect")):k&&!S&&o&&!n&&!e?st.createElement(ZT,null,st.createElement(eE,null,"\u{1F4C1}"),st.createElement(tE,null,"No project selected"),st.createElement(nE,null,"Select or create a project for this Storybook to start reviewing."),st.createElement(Qt,{onClick:()=>M(!0)},"Open Settings")):k&&!S?st.createElement(Nx,null):st.createElement($6,{onSkip:C,canSkip:m&&!S,figmaExpired:S}),x&&st.createElement($3,{onClose:()=>M(!1)}))};import sE,{useCallback as qQ}from"react";import{useStorybookApi as YQ}from"storybook/manager-api";import{IconButton as KQ}from"storybook/internal/components";var XQ="uireview",JQ=`${XQ}/panel`,lE=()=>{let e=YQ();FC(e);let t=qQ(()=>{e.togglePanel(!0),e.setSelectedPanel(JQ)},[e]);return sE.createElement(KQ,{key:"uireview-tool",title:"UI Review - Compare with Figma",onClick:t},sE.createElement(ly,null))};ke();import wn,{useState as op,useCallback as dE,useEffect as pE}from"react";import{styled as Jo,useTheme as lZ}from"storybook/theming";import{addons as ip}from"storybook/manager-api";De();He();import{addons as rZ,experimental_getStatusStore as rp}from"storybook/manager-api";De();He();var QQ=K(),ZQ="uireview/badge";async function eZ(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;w.warn(`[reviewAll] Rate limited, retrying in ${i}ms`),await new Promise(a=>setTimeout(a,i))}throw new Error("Max retries exceeded")}async function tZ(e,t){let n=new TextDecoder,r="",o=null,i=0,a=0,s=0,u=0,l=0,c=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(`
|
|
253
253
|
`);r=d.pop()||"";for(let f of d)if(f.startsWith("data: "))try{let y=JSON.parse(f.slice(6));if(y.type==="complete"){o=y.complianceScore??y.validation?.complianceScore??null;let S=(y.issues||[]).filter(x=>!x.dismissed);i=S.filter(x=>x.severity==="critical").length,a=S.filter(x=>x.severity==="major").length,s=S.filter(x=>x.severity==="minor").length,u=y.costUsd||0,l=y.inputTokens||0,c=y.outputTokens||0}}catch{}}return{score:o,criticalCount:i,majorCount:a,minorCount:s,costUsd:u,inputTokens:l,outputTokens:c}}function np(e,t,n,r,o){e&&e.set([{value:n,typeId:ZQ,storyId:t,title:r,description:o}])}async function nZ(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 cE(e,t,n,r,o,i){np(o,e.storyId,"status-value:pending","Reviewing...",e.storyName);try{console.warn(`[reviewAll] Capturing for: ${e.storyName} (${e.storyId})`);let a=await nZ(e.storyId);console.warn(`[reviewAll] Captured: screenshot=${!!a.screenshot} domTree=${!!a.domTree} styles=${!!a.computedStyles} for: ${e.storyName}`);let s=await eZ(`${QQ}/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:a.screenshot,computedStyles:a.computedStyles,domTree:a.domTree,aiModels:[r]})});if(console.warn(`[reviewAll] API response for ${e.storyName}: HTTP ${s.status}`),!s.ok)throw new Error(`HTTP ${s.status}`);let u=s.body?.getReader();if(!u)throw new Error("No response body");let l=await tZ(u,i),{score:c,criticalCount:p,majorCount:g,minorCount:d,costUsd:f,inputTokens:y,outputTokens:I}=l;if(c!==null){let S=p>0||c<70?"status-value:error":g>0||c<90?"status-value:warning":"status-value:success",x=[`Score: ${c}`];p>0&&x.push(`${p} critical`),g>0&&x.push(`${g} major`),d>0&&x.push(`${d} minor`);let M=c>=90?`\u2713 Score ${c}`:c>=70?`\u26A0 Score ${c}`:`\u2717 Score ${c}`;return np(o,e.storyId,S,M,x.join(" \xB7 ")),{passed:c>=70,score:c,costUsd:f,inputTokens:y,outputTokens:I}}return np(o,e.storyId,"status-value:error","Review Failed","No score received"),{passed:!1,score:null,costUsd:0,inputTokens:0,outputTokens:0}}catch(a){w.error(`[reviewAll] Failed to review ${e.storyName}:`,a);let s=a instanceof Error?a.message:"Unknown error";return np(o,e.storyId,"status-value:error","Review Failed",s),{passed:!1,score:null,costUsd:0,inputTokens:0,outputTokens:0}}}var oZ=K(),Xl="uireview/badge";function uE(){let e=!1,t=!1;try{let n=rZ.getChannel();n.on(Gx,async()=>{if(!t){t=!0,e=!1;try{await sZ(n,()=>e)}finally{t=!1}}}),n.on(qx,()=>{e=!0})}catch{}}async function Wx(){try{let e=localStorage.getItem("uicopilot_session_token"),t=localStorage.getItem("uicopilot_selected_project_id");if(!e||!t)return[];let n=await fetch(`${oZ}/api/mappings?projectId=${t}`,{headers:{Authorization:`Bearer ${e}`}});if(!n.ok)return[];let i=((await n.json()).mappings||[]).filter(a=>a.figmaNodeId).map(a=>{let s=a;return{storyId:s.storyId,storyName:s.name||s.storyId,figmaNodeId:s.figmaNodeId}});return iZ(i),i}catch(e){return w.error("[useReviewAll] Failed to load mapped stories:",e),[]}}function iZ(e){try{if(typeof rp!="function")return;let t=rp(Xl);if(!t)return;let n=t.getAll?.()||{},r=new Set(e.map(a=>a.storyId)),o=Object.keys(n).filter(a=>n[a]?.[Xl]&&!r.has(a));o.length>0&&t.unset(o);let i=e.filter(a=>{let s=n[a.storyId]?.[Xl];return!(s?.value==="status-value:success"||s?.value==="status-value:warning"||s?.value==="status-value:error")}).map(a=>({value:"status-value:pending",typeId:Xl,storyId:a.storyId,title:"Mapped to Figma",description:"Ready for UI review \u2014 click Run to start"}));i.length>0&&t.set(i)}catch{}}function aZ(){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 sZ(e,t){let n=await Wx();if(n.length===0){e.emit(Ql,{total:0,passed:0,failed:0});return}let r=localStorage.getItem("uicopilot_session_token"),o=localStorage.getItem("uicopilot_selected_project_id");if(!r||!o)return;let i="claude-sonnet-4-6";try{let y=localStorage.getItem("uicopilot_selected_models");if(y){let I=JSON.parse(y);Array.isArray(I)&&I.length>0&&(i=I[0])}}catch{}let a=null;try{typeof rp=="function"&&(a=rp(Xl))}catch{}let s=aZ(),u=0,l=0,c=0,p=0,g=0,d=0;e.emit(Jl,{total:n.length,completed:0,currentStoryName:n[0]?.storyName||""});let f=n.map(y=>()=>cE(y,r,o,i,a,t));await Vu(f,s,(y,I)=>{if(I&&typeof I=="object"&&"score"in I){let S=I;S.score!==null&&S.score>=90?u++:S.score!==null&&S.score>=70?l++:c++,p+=S.costUsd||0,g+=S.inputTokens||0,d+=S.outputTokens||0}else c++;console.warn(`[reviewAll] Story ${y+1}/${n.length} done:`,n[y].storyName,I),e.emit(Jl,{total:n.length,completed:u+l+c,currentStoryName:n[y].storyName})},t),e.emit(Ql,{total:n.length,passed:u,failed:c,warnCount:l,costUsd:p,inputTokens:g,outputTokens:d})}var cZ=Jo.div({padding:"8px 12px",display:"flex",flexDirection:"column",gap:"6px"}),uZ=Jo.div({display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"}),dZ=Jo.span(({theme:e})=>({fontSize:"12px",fontWeight:500,color:e.color.defaultText})),gE=Jo.span(({theme:e})=>({fontSize:"11px",color:e.color.mediumdark})),fE=Jo.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}})),pZ=Jo.div(({theme:e})=>({width:"100%",height:"3px",backgroundColor:e.appBorderColor,borderRadius:"2px",overflow:"hidden"})),gZ=Jo.div(({theme:e,percent:t})=>({width:`${t}%`,height:"100%",backgroundColor:e.color.secondary,borderRadius:"2px",transition:"width 0.3s ease"})),mE=Jo.div(({theme:e})=>({display:"flex",alignItems:"center",gap:`${e.layoutMargin*.8}px`,fontSize:e.typography.size.s1,color:e.color.mediumdark})),us=Jo.span(e=>({display:"flex",alignItems:"center",gap:"3px","&::before":{content:'""',display:"inline-block",width:"7px",height:"7px",borderRadius:"50%",backgroundColor:e.dotColor}})),Gx="uireview/review-all-start",qx="uireview/review-all-cancel",Jl="uireview/review-all-progress",Ql="uireview/review-all-complete",hE=()=>{let[e,t]=op(!1),[n,r]=op(null),[o,i]=op(null),[a,s]=op(null);pE(()=>{let d=()=>{Wx().then(S=>{s(S.length)}).catch(()=>{})},f=setTimeout(d,3e3),y=null;try{y=ip.getChannel(),y.on("storyChanged",d),y.on("uireview/mappings-changed",d)}catch{}let I=setInterval(d,6e4);return()=>{clearTimeout(f),clearInterval(I),y&&(y.off("storyChanged",d),y.off("uireview/mappings-changed",d))}},[]),pE(()=>{let d;try{d=ip.getChannel()}catch{return}let f=I=>{r(I),t(!0)},y=I=>{t(!1),r(null),i({total:I.total,passed:I.passed,failed:I.failed,warned:I.warnCount||0,costUsd:I.costUsd||0})};return d.on(Jl,f),d.on(Ql,y),()=>{d.off(Jl,f),d.off(Ql,y)}},[]);let u=dE(()=>{try{ip.getChannel().emit(Gx),t(!0),i(null)}catch{}},[]),l=dE(()=>{try{ip.getChannel().emit(qx)}catch{}t(!1),r(null)},[]),c=n?Math.round(n.completed/n.total*100):0,p=lZ(),g=(()=>{try{return!!JSON.parse(localStorage.getItem("uicopilot_feature_flags")||"{}").showCosts}catch{return!1}})();return wn.createElement(cZ,null,wn.createElement(uZ,null,wn.createElement(dZ,null,"UI Review"),e?wn.createElement(fE,{running:!0,onClick:l},"Cancel"):wn.createElement(fE,{onClick:u,disabled:!a||a===0},"Run",a?` (${a})`:"")),!e&&o?wn.createElement(wn.Fragment,null,wn.createElement(mE,null,wn.createElement(us,{dotColor:p.color.positive},"Pass (",o.passed,")"),wn.createElement(us,{dotColor:p.color.warning},"Warn (",o.warned,")"),wn.createElement(us,{dotColor:p.color.negative},"Fail (",o.failed,")")),g&&o.costUsd>0&&wn.createElement(gE,null,"$",o.costUsd.toFixed(3)," \xB7 \u20AA",(o.costUsd*3.6).toFixed(3))):e?null:wn.createElement(mE,null,wn.createElement(us,{dotColor:p.color.positive},"Pass"),wn.createElement(us,{dotColor:p.color.warning},"Warn"),wn.createElement(us,{dotColor:p.color.negative},"Fail")),e&&n&&wn.createElement(wn.Fragment,null,wn.createElement(pZ,null,wn.createElement(gZ,{percent:c})),wn.createElement(gE,null,"Reviewing ",Math.min(n.completed+1,n.total),"/",n.total," \u2014 ",n.currentStoryName)))};import*as yE from"@sentry/react";var fZ="https://015e961f5f626bad5315430e02940616@o138219.ingest.us.sentry.io/4511134750539776",xE=!1;function mZ(){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 bE(){if(!xE){xE=!0;try{yE.init({dsn:fZ,environment:mZ(),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{}}}bE();var sp="uireview",yZ=`${sp}/panel`,bZ=`${sp}/tool`,wE=`${sp}/test-provider`,wZ=xZ.span(({theme:e})=>({marginLeft:6,padding:"0 5px",fontSize:9,fontWeight:e.typography.weight.bold,lineHeight:"14px",textTransform:"uppercase",letterSpacing:"0.04em",borderRadius:8,color:e.color.lightest,background:W,verticalAlign:"middle"})),vZ=()=>Fi.createElement(Fi.Fragment,null,"UI Parity",Fi.createElement(wZ,null,"beta"));ap.register(sp,()=>{if(f4(),g4(),console.log("[UI Review] Registering addon, checking for StatusStore API..."),typeof Kx=="function"){console.log("[UI Review] StatusStore API available, initializing badges");let e=Kx("uireview/badge");b4(e);let t=Kx("uireview/mapped");S4(t),console.log("[UI Review] Badge listener initialized")}else console.warn("[UI Review] experimental_getStatusStore not available \u2014 badges disabled");ap.add(bZ,{type:Yx.TOOL,title:"UI Parity",match:({viewMode:e})=>e==="story",render:()=>Fi.createElement(lE,null)}),uE(),ap.add(wE,{type:Yx.experimental_TEST_PROVIDER,id:wE,render:()=>Fi.createElement(hE,null)}),ap.add(yZ,{type:Yx.PANEL,title:vZ,match:({viewMode:e})=>e==="story",render:({active:e})=>Fi.createElement(hZ,{active:e||!1},Fi.createElement(Um,null,Fi.createElement(aE,null)))})});
|
|
254
254
|
/*! Bundled license information:
|
|
255
255
|
|