@iaforged/context-code 2.0.3 → 2.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/components/BypassPermissionsModeDialog.js +1 -1
- package/dist/src/components/Stats.js +1 -1
- package/dist/src/components/TeleportProgress.js +1 -1
- package/dist/src/components/WorkflowMultiselectDialog.js +1 -1
- package/dist/webapp/chunk-OJZNEHPP.js +1 -1
- package/dist/webapp/chunk-VAB2VXFI.js +1 -1
- package/dist/webapp/main-MTQLKGXD.js +1 -1
- package/dist/webapp/ngsw-worker.js +1 -1
- package/dist/webapp/ngsw.json +1 -1
- package/dist/webapp/polyfills-7R4CRVNH.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{c as s}from"react/compiler-runtime";import
|
|
1
|
+
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{c as s}from"react/compiler-runtime";import t from"react";import{logEvent as i}from"../services/analytics/index.js";import{Box as n,Link as r,Newline as a,Text as c}from"../ink.js";import{gracefulShutdownSync as m}from"../utils/gracefulShutdown.js";import{updateSettingsForSource as l}from"../utils/settings/settings.js";import{Select as d}from"./CustomSelect/index.js";import{Dialog as p}from"./design-system/Dialog.js";export function BypassPermissionsModeDialog(u){const f=s(7),{onAccept:_}=u;let g,h;f[0]===Symbol.for("react.memo_cache_sentinel")?(g=[],f[0]=g):g=f[0],t.useEffect(_temp,g),f[1]!==_?(h=function(e){e:switch(e){case"accept":i("tengu_bypass_permissions_mode_dialog_accept",{}),l("userSettings",{skipDangerousModePermissionPrompt:!0}),_();break e;case"decline":m(1)}},f[1]=_,f[2]=h):h=f[2];const j=h,b=_temp2;let y,x,C;return f[3]===Symbol.for("react.memo_cache_sentinel")?(y=o(n,{flexDirection:"column",gap:1,children:[o(c,{children:["En el modo de omisión de permisos (Bypass Permissions), Context Code no solicitará tu aprobación antes de ejecutar comandos potencialmente peligrosos.",e(a,{}),"Este modo solo debe utilizarse en un contenedor o máquina virtual (VM) aislada que tenga acceso restringido a Internet y pueda restaurarse fácilmente si sufre daños."]}),e(c,{children:"Al proceder, aceptas toda la responsabilidad por las acciones realizadas mientras se ejecuta en el modo de omisión de permisos."}),e(r,{url:"https://code.claude.com/docs/en/security"})]}),f[3]=y):y=f[3],f[4]===Symbol.for("react.memo_cache_sentinel")?(x=[{label:"No, salir",value:"decline"},{label:"Sí, acepto",value:"accept"}],f[4]=x):x=f[4],f[5]!==j?(C=o(p,{title:"ADVERTENCIA: Context Code se está ejecutando en modo de omisión de permisos",color:"error",onCancel:b,children:[y,e(d,{options:x,onChange:e=>j(e)})]}),f[5]=j,f[6]=C):C=f[6],C}function _temp2(){m(0)}function _temp(){i("tengu_bypass_permissions_mode_dialog_shown",{})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{feature as e}from"../recovery/bunBundleShim.js";import{jsx as t,jsxs as n,Fragment as o}from"react/jsx-runtime";import{c as r}from"react/compiler-runtime";import{plot as s}from"asciichart";import i from"chalk";import l from"figures";import{Suspense as a,use as c,useEffect as u,useMemo as d,useState as m}from"react";import p from"strip-ansi";import{useTerminalSize as g}from"../hooks/useTerminalSize.js";import{applyColor as f}from"../ink/colorize.js";import{stringWidth as k}from"../ink/stringWidth.js";import{Ansi as b,Box as T,Text as y,useInput as w}from"../ink.js";import{useKeybinding as x}from"../keybindings/useKeybinding.js";import{getGlobalConfig as S}from"../utils/config.js";import{formatDuration as v,formatNumber as D}from"../utils/format.js";import{generateHeatmap as M}from"../utils/heatmap.js";import{renderModelName as j}from"../utils/model/model.js";import{copyAnsiToClipboard as $}from"../utils/screenshotClipboard.js";import{aggregateClaudeCodeStatsForRange as A}from"../utils/stats.js";import{resolveThemeSetting as _}from"../utils/systemTheme.js";import{getTheme as C,themeColorToAnsi as O}from"../utils/theme.js";import{Pane as L}from"./design-system/Pane.js";import{Tab as F,Tabs as R,useTabHeaderFocus as B}from"./design-system/Tabs.js";import{Spinner as P}from"./Spinner.js";const E={"7d":"Last 7 days","30d":"Last 30 days",all:"All time"},H=["all","7d","30d"];export function Stats(e){const o=r(4),{onClose:s}=e;let i;o[0]===Symbol.for("react.memo_cache_sentinel")?(i=A("all").then(e=>e&&0!==e.totalSessions?{type:"success",data:e}:{type:"empty"}).catch(e=>({type:"error",message:e instanceof Error?e.message:"Failed to load stats"})),o[0]=i):i=o[0];const l=i;let c,u;return o[1]===Symbol.for("react.memo_cache_sentinel")?(c=n(T,{marginTop:1,children:[t(P,{}),t(y,{children:" Loading your Context Code stats…"})]}),o[1]=c):c=o[1],o[2]!==s?(u=t(a,{fallback:c,children:t(StatsContent,{allTimePromise:l,onClose:s})}),o[2]=s,o[3]=u):u=o[3],u}function StatsContent(o){const s=r(34),{allTimePromise:a,onClose:d}=o,g=c(a),[b,O]=m("all");let B;s[0]===Symbol.for("react.memo_cache_sentinel")?(B={},s[0]=B):B=s[0];const[E,I]=m(B),[U,W]=m(!1),[N,G]=m("Overview"),[K,Y]=m(null);let z,Q;s[1]!==b||s[2]!==E?(z=()=>{if("all"===b)return;if(E[b])return;let e=!1;return W(!0),A(b).then(t=>{e||(I(e=>({...e,[b]:t})),W(!1))}).catch(()=>{e||W(!1)}),()=>{e=!0}},Q=[b,E],s[1]=b,s[2]=E,s[3]=z,s[4]=Q):(z=s[3],Q=s[4]),u(z,Q);const q="all"===b?"success"===g.type?g.data:null:E[b]??("success"===g.type?g.data:null),J="success"===g.type?g.data:null;let V;s[5]!==d?(V=()=>{d("Stats dialog dismissed",{display:"system"})},s[5]=d,s[6]=V):V=s[6];const X=V;let Z,ee,te,ne,oe;if(s[7]===Symbol.for("react.memo_cache_sentinel")?(Z={context:"Confirmation"},s[7]=Z):Z=s[7],x("confirm:no",X,Z),s[8]!==N||s[9]!==b||s[10]!==q||s[11]!==d?(ee=(t,n)=>{!n.ctrl||"c"!==t&&"d"!==t||d("Stats dialog dismissed",{display:"system"}),n.tab&&G(_temp),"r"!==t||n.ctrl||n.meta||O(function(e){const t=H.indexOf(e);return H[(t+1)%H.length]}(b)),n.ctrl&&"s"===t&&q&&async function(t,n,o){o("copying…");const r=function(t,n){const o=[];"Overview"===n?o.push(...function(t){const n=[],o=C(_(S().theme)),h=e=>f(e,o.claude),r=18,s=40,l=18,row=(e,t,n,o)=>{const i=(e+":").padEnd(r),a=i.length+t.length,c=Math.max(2,s-a),u=(n+":").padEnd(l);return i+h(t)+" ".repeat(c)+u+h(o)};t.dailyActivity.length>0&&(n.push(M(t.dailyActivity,{terminalWidth:56})),n.push(""));const a=Object.entries(t.modelUsage).sort(([,e],[,t])=>t.inputTokens+t.outputTokens-(e.inputTokens+e.outputTokens)),c=a[0],u=a.reduce((e,[,t])=>e+t.inputTokens+t.outputTokens,0);c&&n.push(row("Favorite model",j(c[0]),"Total tokens",D(u)));n.push(""),n.push(row("Sessions",D(t.totalSessions),"Longest session",t.longestSession?v(t.longestSession.duration):"N/A"));const d=`${t.streaks.currentStreak} ${1===t.streaks.currentStreak?"day":"days"}`,m=`${t.streaks.longestStreak} ${1===t.streaks.longestStreak?"day":"days"}`;n.push(row("Current streak",d,"Longest streak",m));const p=`${t.activeDays}/${t.totalDays}`,g=null!==t.peakActivityHour?`${t.peakActivityHour}:00-${t.peakActivityHour+1}:00`:"N/A";n.push(row("Active days",p,"Peak hour",g)),!1;if(e("SHOT_STATS")&&t.shotDistribution){const e=t.shotDistribution,o=Object.values(e).reduce((e,t)=>e+t,0);if(o>0){const t=(Object.entries(e).reduce((e,[t,n])=>e+parseInt(t,10)*n,0)/o).toFixed(1),bucket=(t,n)=>Object.entries(e).filter(([e])=>{const o=parseInt(e,10);return o>=t&&(void 0===n||o<=n)}).reduce((e,[,t])=>e+t,0),pct=e=>Math.round(e/o*100),fmtBucket=(e,t)=>`${e} (${t}%)`,s=bucket(1,1),i=bucket(2,5),l=bucket(6,10),a=bucket(11);n.push(""),n.push("Shot distribution"),n.push(row("1-shot",fmtBucket(s,pct(s)),"2–5 shot",fmtBucket(i,pct(i)))),n.push(row("6–10 shot",fmtBucket(l,pct(l)),"11+ shot",fmtBucket(a,pct(a)))),n.push(`${"Avg/session:".padEnd(r)}${h(t)}`)}}n.push("");const k=generateFunFactoid(t,u);return n.push(h(k)),n.push(i.gray(`Stats from the last ${t.totalDays} days`)),n}(t)):o.push(...function(e){const t=[],n=Object.entries(e.modelUsage).sort(([,e],[,t])=>t.inputTokens+t.outputTokens-(e.inputTokens+e.outputTokens));if(0===n.length)return t.push(i.gray("No model usage data available")),t;const o=n[0],r=n.reduce((e,[,t])=>e+t.inputTokens+t.outputTokens,0),s=generateTokenChart(e.dailyModelTokens,n.map(([e])=>e),80);if(s){t.push(i.bold("Tokens per Day")),t.push(s.chart),t.push(i.gray(s.xAxisLabels));const e=s.legend.map(e=>`${e.coloredBullet} ${e.model}`).join(" · ");t.push(e),t.push("")}t.push(`${l.star} Favorite: ${i.magenta.bold(j(o?.[0]||""))} · ${l.circle} Total: ${i.magenta(D(r))} tokens`),t.push("");const a=n.slice(0,3);for(const[e,n]of a){const o=((n.inputTokens+n.outputTokens)/r*100).toFixed(1);t.push(`${l.bullet} ${i.bold(j(e))} ${i.gray(`(${o}%)`)}`),t.push(i.dim(` In: ${D(n.inputTokens)} · Out: ${D(n.outputTokens)}`))}return t}(t));for(;o.length>0&&""===p(o[o.length-1]).trim();)o.pop();if(o.length>0){const e=o[o.length-1],t=k(e),r="Overview"===n?70:80,s="/stats",l=Math.max(2,r-t-s.length);o[o.length-1]=e+" ".repeat(l)+i.gray(s)}return o.join("\n")}(t,n),s=await $(r);o(s.success?"copied!":"copy failed"),setTimeout(o,2e3,null)}(q,N,Y)},s[8]=N,s[9]=b,s[10]=q,s[11]=d,s[12]=ee):ee=s[12],w(ee),"error"===g.type){let e;return s[13]!==g.message?(e=t(T,{marginTop:1,children:n(y,{color:"error",children:["Error al cargar estadísticas: ",g.message]})}),s[13]=g.message,s[14]=e):e=s[14],e}if("empty"===g.type){let e;return s[15]===Symbol.for("react.memo_cache_sentinel")?(e=t(T,{marginTop:1,children:t(y,{color:"warning",children:"No stats available yet. Start using Context Code!"})}),s[15]=e):e=s[15],e}if(!q||!J){let e;return s[16]===Symbol.for("react.memo_cache_sentinel")?(e=n(T,{marginTop:1,children:[t(P,{}),t(y,{children:" Loading stats…"})]}),s[16]=e):e=s[16],e}s[17]!==J||s[18]!==b||s[19]!==q||s[20]!==U?(te=t(F,{title:"Overview",children:t(OverviewTab,{stats:q,allTimeStats:J,dateRange:b,isLoading:U})}),s[17]=J,s[18]=b,s[19]=q,s[20]=U,s[21]=te):te=s[21],s[22]!==b||s[23]!==q||s[24]!==U?(ne=t(F,{title:"Models",children:t(ModelsTab,{stats:q,dateRange:b,isLoading:U})}),s[22]=b,s[23]=q,s[24]=U,s[25]=ne):ne=s[25],s[26]!==te||s[27]!==ne?(oe=t(T,{flexDirection:"row",gap:1,marginBottom:1,children:n(R,{title:"",color:"claude",defaultTab:"Overview",children:[te,ne]})}),s[26]=te,s[27]=ne,s[28]=oe):oe=s[28];const re=K?` · ${K}`:"";let se,ie;return s[29]!==re?(se=t(T,{paddingLeft:2,children:n(y,{dimColor:!0,children:["Esc para cancelar · r para recorrer fechas · ctrl+s para copiar",re]})}),s[29]=re,s[30]=se):se=s[30],s[31]!==se||s[32]!==oe?(ie=n(L,{color:"claude",children:[oe,se]}),s[31]=se,s[32]=oe,s[33]=ie):ie=s[33],ie}function _temp(e){return"Overview"===e?"Models":"Overview"}function DateRangeSelector(e){const o=r(9),{dateRange:s,isLoading:i}=e;let l,a,c,u;return o[0]!==s?(l=H.map((e,o)=>n(y,{children:[o>0&&t(y,{dimColor:!0,children:" · "}),t(y,e===s?{bold:!0,color:"claude",children:E[e]}:{dimColor:!0,children:E[e]})]},e)),o[0]=s,o[1]=l):l=o[1],o[2]!==l?(a=t(T,{children:l}),o[2]=l,o[3]=a):a=o[3],o[4]!==i?(c=i&&t(P,{}),o[4]=i,o[5]=c):c=o[5],o[6]!==a||o[7]!==c?(u=n(T,{marginBottom:1,gap:1,children:[a,c]}),o[6]=a,o[7]=c,o[8]=u):u=o[8],u}function OverviewTab({stats:r,allTimeStats:s,dateRange:i,isLoading:l}){const{columns:a}=g(),c=Object.entries(r.modelUsage).sort(([,e],[,t])=>t.inputTokens+t.outputTokens-(e.inputTokens+e.outputTokens)),u=c[0],m=c.reduce((e,[,t])=>e+t.inputTokens+t.outputTokens,0),p=d(()=>generateFunFactoid(r,m),[r,m]),f="7d"===i?7:"30d"===i?30:r.totalDays;let k=null;if(e("SHOT_STATS")&&r.shotDistribution){const e=r.shotDistribution,t=Object.values(e).reduce((e,t)=>e+t,0);if(t>0){const n=Object.entries(e).reduce((e,[t,n])=>e+parseInt(t,10)*n,0),bucket=(t,n)=>Object.entries(e).filter(([e])=>{const o=parseInt(e,10);return o>=t&&(void 0===n||o<=n)}).reduce((e,[,t])=>e+t,0),pct=e=>Math.round(e/t*100),o=bucket(1,1),r=bucket(2,5),s=bucket(6,10),i=bucket(11);k={avgShots:(n/t).toFixed(1),buckets:[{label:"1-shot",count:o,pct:pct(o)},{label:"2–5 shot",count:r,pct:pct(r)},{label:"6–10 shot",count:s,pct:pct(s)},{label:"11+ shot",count:i,pct:pct(i)}]}}}return n(T,{flexDirection:"column",marginTop:1,children:[s.dailyActivity.length>0&&t(T,{flexDirection:"column",marginBottom:1,children:t(b,{children:M(s.dailyActivity,{terminalWidth:a})})}),t(DateRangeSelector,{dateRange:i,isLoading:l}),n(T,{flexDirection:"row",gap:4,marginBottom:1,children:[t(T,{flexDirection:"column",width:28,children:u&&n(y,{wrap:"truncate",children:["Favorite model:"," ",t(y,{color:"claude",bold:!0,children:j(u[0])})]})}),t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Total tokens:"," ",t(y,{color:"claude",children:D(m)})]})})]}),n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Sessions:"," ",t(y,{color:"claude",children:D(r.totalSessions)})]})}),t(T,{flexDirection:"column",width:28,children:r.longestSession&&n(y,{wrap:"truncate",children:["Longest session:"," ",t(y,{color:"claude",children:v(r.longestSession.duration)})]})})]}),n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Active days: ",t(y,{color:"claude",children:r.activeDays}),n(y,{color:"subtle",children:["/",f]})]})}),t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Longest streak:"," ",t(y,{color:"claude",bold:!0,children:r.streaks.longestStreak})," ",1===r.streaks.longestStreak?"day":"days"]})})]}),n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:28,children:r.peakActivityDay&&n(y,{wrap:"truncate",children:["Most active day:"," ",t(y,{color:"claude",children:(w=r.peakActivityDay,new Date(w).toLocaleDateString("en-US",{month:"short",day:"numeric"}))})]})}),t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Current streak:"," ",t(y,{color:"claude",bold:!0,children:s.streaks.currentStreak})," ",1===s.streaks.currentStreak?"day":"days"]})})]}),!1,k&&n(o,{children:[t(T,{marginTop:1,children:t(y,{children:"Shot distribution"})}),n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:[k.buckets[0].label,":"," ",t(y,{color:"claude",children:k.buckets[0].count}),n(y,{color:"subtle",children:[" (",k.buckets[0].pct,"%)"]})]})}),t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:[k.buckets[1].label,":"," ",t(y,{color:"claude",children:k.buckets[1].count}),n(y,{color:"subtle",children:[" (",k.buckets[1].pct,"%)"]})]})})]}),n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:[k.buckets[2].label,":"," ",t(y,{color:"claude",children:k.buckets[2].count}),n(y,{color:"subtle",children:[" (",k.buckets[2].pct,"%)"]})]})}),t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:[k.buckets[3].label,":"," ",t(y,{color:"claude",children:k.buckets[3].count}),n(y,{color:"subtle",children:[" (",k.buckets[3].pct,"%)"]})]})})]}),t(T,{flexDirection:"row",gap:4,children:t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Avg/session:"," ",t(y,{color:"claude",children:k.avgShots})]})})})]}),p&&t(T,{marginTop:1,children:t(y,{color:"suggestion",children:p})})]});var w}const I=[{name:"The Little Prince",tokens:22e3},{name:"The Old Man and the Sea",tokens:35e3},{name:"A Christmas Carol",tokens:37e3},{name:"Animal Farm",tokens:39e3},{name:"Fahrenheit 451",tokens:6e4},{name:"The Great Gatsby",tokens:62e3},{name:"Slaughterhouse-Five",tokens:64e3},{name:"Brave New World",tokens:83e3},{name:"The Catcher in the Rye",tokens:95e3},{name:"Harry Potter and the Philosopher's Stone",tokens:103e3},{name:"The Hobbit",tokens:123e3},{name:"1984",tokens:123e3},{name:"To Kill a Mockingbird",tokens:13e4},{name:"Pride and Prejudice",tokens:156e3},{name:"Dune",tokens:244e3},{name:"Moby-Dick",tokens:268e3},{name:"Crime and Punishment",tokens:274e3},{name:"A Game of Thrones",tokens:381e3},{name:"Anna Karenina",tokens:468e3},{name:"Don Quixote",tokens:52e4},{name:"The Lord of the Rings",tokens:576e3},{name:"The Count of Monte Cristo",tokens:603e3},{name:"Les Misérables",tokens:689e3},{name:"War and Peace",tokens:73e4}],U=[{name:"a TED talk",minutes:18},{name:"an episode of The Office",minutes:22},{name:"listening to Abbey Road",minutes:47},{name:"a yoga class",minutes:60},{name:"a World Cup soccer match",minutes:90},{name:"a half marathon (average time)",minutes:120},{name:"the movie Inception",minutes:148},{name:"watching Titanic",minutes:195},{name:"a transatlantic flight",minutes:420},{name:"a full night of sleep",minutes:480}];function generateFunFactoid(e,t){const n=[];if(t>0){const e=I.filter(e=>t>=e.tokens);for(const o of e){const e=t/o.tokens;e>=2?n.push(`You've used ~${Math.floor(e)}x more tokens than ${o.name}`):n.push(`You've used the same number of tokens as ${o.name}`)}}if(e.longestSession){const t=e.longestSession.duration/6e4;for(const e of U){const o=t/e.minutes;o>=2&&n.push(`Your longest session is ~${Math.floor(o)}x longer than ${e.name}`)}}if(0===n.length)return"";return n[Math.floor(Math.random()*n.length)]}function ModelsTab(e){const o=r(15),{stats:s,dateRange:i,isLoading:a}=e,{headerFocused:c,focusHeader:u}=B(),[d,p]=m(0),{columns:f}=g(),k=Object.entries(s.modelUsage).sort(_temp7),x=!c;let S;if(o[0]!==x?(S={isActive:x},o[0]=x,o[1]=S):S=o[1],w((e,t)=>{t.downArrow&&d<k.length-4&&p(e=>Math.min(e+2,k.length-4)),t.upArrow&&(d>0?p(_temp8):u())},S),0===k.length){let e;return o[2]===Symbol.for("react.memo_cache_sentinel")?(e=t(T,{children:t(y,{color:"subtle",children:"No model usage data available"})}),o[2]=e):e=o[2],e}const v=k.reduce(_temp9,0),D=generateTokenChart(s.dailyModelTokens,k.map(_temp0),f),M=k.slice(d,d+4),j=Math.ceil(M.length/2),$=M.slice(0,j),A=M.slice(j),_=d>0,C=d<k.length-4,O=k.length>4;let L;o[3]!==i||o[4]!==a?(L=t(DateRangeSelector,{dateRange:i,isLoading:a}),o[3]=i,o[4]=a,o[5]=L):L=o[5];const F=T,R=A.map(e=>{const[n,o]=e;return t(ModelEntry,{model:n,usage:o,totalTokens:v},n)});let P,E;return o[6]!==F||o[7]!==R?(P=t(F,{flexDirection:"column",width:36,children:R}),o[6]=F,o[7]=R,o[8]=P):P=o[8],o[9]!==C||o[10]!==_||o[11]!==k||o[12]!==d||o[13]!==O?(E=O&&t(T,{marginTop:1,children:n(y,{color:"subtle",children:[_?l.arrowUp:" "," ",C?l.arrowDown:" "," ",d+1,"-",Math.min(d+4,k.length)," of"," ",k.length," models (↑↓ to scroll)"]})}),o[9]=C,o[10]=_,o[11]=k,o[12]=d,o[13]=O,o[14]=E):E=o[14],n(T,{flexDirection:"column",marginTop:1,children:[D&&n(T,{flexDirection:"column",marginBottom:1,children:[t(y,{bold:!0,children:"Tokens per Day"}),t(b,{children:D.chart}),t(y,{color:"subtle",children:D.xAxisLabels}),t(T,{children:D.legend.map(_temp1)})]}),L,n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:36,children:$.map(e=>{const[n,o]=e;return t(ModelEntry,{model:n,usage:o,totalTokens:v},n)})}),P]}),E]})}function _temp1(e,o){return n(y,{children:[o>0?" · ":"",t(b,{children:e.coloredBullet})," ",e.model]},e.model)}function _temp0(e){const[t]=e;return t}function _temp9(e,t){const[,n]=t;return e+n.inputTokens+n.outputTokens}function _temp8(e){return Math.max(e-2,0)}function _temp7(e,t){const[,n]=e,[,o]=t;return o.inputTokens+o.outputTokens-(n.inputTokens+n.outputTokens)}function ModelEntry(e){const o=r(21),{model:s,usage:i,totalTokens:a}=e,c=(i.inputTokens+i.outputTokens)/a*100;let u;o[0]!==c?(u=c.toFixed(1),o[0]=c,o[1]=u):u=o[1];const d=u;let m,p,g,f,k,b,w,x;return o[2]!==s?(m=j(s),o[2]=s,o[3]=m):m=o[3],o[4]!==m?(p=t(y,{bold:!0,children:m}),o[4]=m,o[5]=p):p=o[5],o[6]!==d?(g=n(y,{color:"subtle",children:["(",d,"%)"]}),o[6]=d,o[7]=g):g=o[7],o[8]!==p||o[9]!==g?(f=n(y,{children:[l.bullet," ",p," ",g]}),o[8]=p,o[9]=g,o[10]=f):f=o[10],o[11]!==i.inputTokens?(k=D(i.inputTokens),o[11]=i.inputTokens,o[12]=k):k=o[12],o[13]!==i.outputTokens?(b=D(i.outputTokens),o[13]=i.outputTokens,o[14]=b):b=o[14],o[15]!==k||o[16]!==b?(w=n(y,{color:"subtle",children:[" ","In: ",k," · Out:"," ",b]}),o[15]=k,o[16]=b,o[17]=w):w=o[17],o[18]!==f||o[19]!==w?(x=n(T,{flexDirection:"column",children:[f,w]}),o[18]=f,o[19]=w,o[20]=x):x=o[20],x}function generateTokenChart(e,t,n){if(e.length<2||0===t.length)return null;const o=n-7,r=Math.min(52,Math.max(20,o));let i;if(e.length>=r)i=e.slice(-r);else{const t=Math.floor(r/e.length);i=[];for(const n of e)for(let e=0;e<t;e++)i.push(n)}const a=C(_(S().theme)),c=[O(a.suggestion),O(a.success),O(a.warning)],u=[],d=[],m=t.slice(0,3);for(let e=0;e<m.length;e++){const t=m[e],n=i.map(e=>e.tokensByModel[t]||0);if(n.some(e=>e>0)){u.push(n);const o=[a.suggestion,a.success,a.warning];d.push({model:j(t),coloredBullet:f(l.bullet,o[e%o.length])})}}if(0===u.length)return null;return{chart:s(u,{height:8,colors:c.slice(0,u.length),format:e=>{let t;return t=e>=1e6?(e/1e6).toFixed(1)+"M":e>=1e3?(e/1e3).toFixed(0)+"k":e.toFixed(0),t.padStart(6)}}),legend:d,xAxisLabels:function(e,t,n){if(0===e.length)return"";const o=Math.min(4,Math.max(2,Math.floor(e.length/8))),r=e.length-6,s=Math.floor(r/(o-1))||1,i=[];for(let t=0;t<o;t++){const n=Math.min(t*s,e.length-1),o=new Date(e[n].date).toLocaleDateString("en-US",{month:"short",day:"numeric"});i.push({pos:n,label:o})}let l=" ".repeat(n),a=0;for(const{pos:e,label:t}of i){const n=Math.max(1,e-a);l+=" ".repeat(n)+t,a=e+t.length}return l}(i,i.length,7)}}
|
|
1
|
+
import{feature as e}from"../recovery/bunBundleShim.js";import{jsx as t,jsxs as n,Fragment as o}from"react/jsx-runtime";import{c as r}from"react/compiler-runtime";import{plot as s}from"asciichart";import i from"chalk";import a from"figures";import{Suspense as l,use as c,useEffect as u,useMemo as d,useState as m}from"react";import p from"strip-ansi";import{useTerminalSize as g}from"../hooks/useTerminalSize.js";import{applyColor as f}from"../ink/colorize.js";import{stringWidth as k}from"../ink/stringWidth.js";import{Ansi as b,Box as T,Text as y,useInput as w}from"../ink.js";import{useKeybinding as S}from"../keybindings/useKeybinding.js";import{getGlobalConfig as x}from"../utils/config.js";import{formatDuration as D,formatNumber as v}from"../utils/format.js";import{generateHeatmap as M}from"../utils/heatmap.js";import{renderModelName as j}from"../utils/model/model.js";import{copyAnsiToClipboard as $}from"../utils/screenshotClipboard.js";import{aggregateClaudeCodeStatsForRange as C}from"../utils/stats.js";import{resolveThemeSetting as _}from"../utils/systemTheme.js";import{getTheme as A,themeColorToAnsi as O}from"../utils/theme.js";import{Pane as F}from"./design-system/Pane.js";import{Tab as L,Tabs as R,useTabHeaderFocus as P}from"./design-system/Tabs.js";import{Spinner as B}from"./Spinner.js";const E={"7d":"Últimos 7 días","30d":"Últimos 30 días",all:"Todo el tiempo"},H=["all","7d","30d"];export function Stats(e){const o=r(4),{onClose:s}=e;let i;o[0]===Symbol.for("react.memo_cache_sentinel")?(i=C("all").then(e=>e&&0!==e.totalSessions?{type:"success",data:e}:{type:"empty"}).catch(e=>({type:"error",message:e instanceof Error?e.message:"Failed to load stats"})),o[0]=i):i=o[0];const a=i;let c,u;return o[1]===Symbol.for("react.memo_cache_sentinel")?(c=n(T,{marginTop:1,children:[t(B,{}),t(y,{children:" Cargando tus estadísticas de Context Code…"})]}),o[1]=c):c=o[1],o[2]!==s?(u=t(l,{fallback:c,children:t(StatsContent,{allTimePromise:a,onClose:s})}),o[2]=s,o[3]=u):u=o[3],u}function StatsContent(o){const s=r(34),{allTimePromise:l,onClose:d}=o,g=c(l),[b,O]=m("all");let P;s[0]===Symbol.for("react.memo_cache_sentinel")?(P={},s[0]=P):P=s[0];const[E,I]=m(P),[U,W]=m(!1),[N,z]=m("Overview"),[q,G]=m(null);let K,Q;s[1]!==b||s[2]!==E?(K=()=>{if("all"===b)return;if(E[b])return;let e=!1;return W(!0),C(b).then(t=>{e||(I(e=>({...e,[b]:t})),W(!1))}).catch(()=>{e||W(!1)}),()=>{e=!0}},Q=[b,E],s[1]=b,s[2]=E,s[3]=K,s[4]=Q):(K=s[3],Q=s[4]),u(K,Q);const J="all"===b?"success"===g.type?g.data:null:E[b]??("success"===g.type?g.data:null),V="success"===g.type?g.data:null;let X;s[5]!==d?(X=()=>{d("Stats dialog dismissed",{display:"system"})},s[5]=d,s[6]=X):X=s[6];const Y=X;let Z,ee,te,ne,oe;if(s[7]===Symbol.for("react.memo_cache_sentinel")?(Z={context:"Confirmation"},s[7]=Z):Z=s[7],S("confirm:no",Y,Z),s[8]!==N||s[9]!==b||s[10]!==J||s[11]!==d?(ee=(t,n)=>{!n.ctrl||"c"!==t&&"d"!==t||d("Stats dialog dismissed",{display:"system"}),n.tab&&z(_temp),"r"!==t||n.ctrl||n.meta||O(function(e){const t=H.indexOf(e);return H[(t+1)%H.length]}(b)),n.ctrl&&"s"===t&&J&&async function(t,n,o){o("copying…");const r=function(t,n){const o=[];"Overview"===n?o.push(...function(t){const n=[],o=A(_(x().theme)),h=e=>f(e,o.claude),r=18,s=40,a=18,row=(e,t,n,o)=>{const i=(e+":").padEnd(r),l=i.length+t.length,c=Math.max(2,s-l),u=(n+":").padEnd(a);return i+h(t)+" ".repeat(c)+u+h(o)};t.dailyActivity.length>0&&(n.push(M(t.dailyActivity,{terminalWidth:56})),n.push(""));const l=Object.entries(t.modelUsage).sort(([,e],[,t])=>t.inputTokens+t.outputTokens-(e.inputTokens+e.outputTokens)),c=l[0],u=l.reduce((e,[,t])=>e+t.inputTokens+t.outputTokens,0);c&&n.push(row("Favorite model",j(c[0]),"Total tokens",v(u)));n.push(""),n.push(row("Sessions",v(t.totalSessions),"Longest session",t.longestSession?D(t.longestSession.duration):"N/A"));const d=`${t.streaks.currentStreak} ${1===t.streaks.currentStreak?"day":"days"}`,m=`${t.streaks.longestStreak} ${1===t.streaks.longestStreak?"day":"days"}`;n.push(row("Current streak",d,"Longest streak",m));const p=`${t.activeDays}/${t.totalDays}`,g=null!==t.peakActivityHour?`${t.peakActivityHour}:00-${t.peakActivityHour+1}:00`:"N/A";n.push(row("Active days",p,"Peak hour",g)),!1;if(e("SHOT_STATS")&&t.shotDistribution){const e=t.shotDistribution,o=Object.values(e).reduce((e,t)=>e+t,0);if(o>0){const t=(Object.entries(e).reduce((e,[t,n])=>e+parseInt(t,10)*n,0)/o).toFixed(1),bucket=(t,n)=>Object.entries(e).filter(([e])=>{const o=parseInt(e,10);return o>=t&&(void 0===n||o<=n)}).reduce((e,[,t])=>e+t,0),pct=e=>Math.round(e/o*100),fmtBucket=(e,t)=>`${e} (${t}%)`,s=bucket(1,1),i=bucket(2,5),a=bucket(6,10),l=bucket(11);n.push(""),n.push("Shot distribution"),n.push(row("1-shot",fmtBucket(s,pct(s)),"2–5 shot",fmtBucket(i,pct(i)))),n.push(row("6–10 shot",fmtBucket(a,pct(a)),"11+ shot",fmtBucket(l,pct(l)))),n.push(`${"Avg/session:".padEnd(r)}${h(t)}`)}}n.push("");const k=generateFunFactoid(t,u);return n.push(h(k)),n.push(i.gray(`Stats from the last ${t.totalDays} days`)),n}(t)):o.push(...function(e){const t=[],n=Object.entries(e.modelUsage).sort(([,e],[,t])=>t.inputTokens+t.outputTokens-(e.inputTokens+e.outputTokens));if(0===n.length)return t.push(i.gray("No model usage data available")),t;const o=n[0],r=n.reduce((e,[,t])=>e+t.inputTokens+t.outputTokens,0),s=generateTokenChart(e.dailyModelTokens,n.map(([e])=>e),80);if(s){t.push(i.bold("Tokens per Day")),t.push(s.chart),t.push(i.gray(s.xAxisLabels));const e=s.legend.map(e=>`${e.coloredBullet} ${e.model}`).join(" · ");t.push(e),t.push("")}t.push(`${a.star} Favorite: ${i.magenta.bold(j(o?.[0]||""))} · ${a.circle} Total: ${i.magenta(v(r))} tokens`),t.push("");const l=n.slice(0,3);for(const[e,n]of l){const o=((n.inputTokens+n.outputTokens)/r*100).toFixed(1);t.push(`${a.bullet} ${i.bold(j(e))} ${i.gray(`(${o}%)`)}`),t.push(i.dim(` In: ${v(n.inputTokens)} · Out: ${v(n.outputTokens)}`))}return t}(t));for(;o.length>0&&""===p(o[o.length-1]).trim();)o.pop();if(o.length>0){const e=o[o.length-1],t=k(e),r="Overview"===n?70:80,s="/stats",a=Math.max(2,r-t-s.length);o[o.length-1]=e+" ".repeat(a)+i.gray(s)}return o.join("\n")}(t,n),s=await $(r);o(s.success?"copied!":"copy failed"),setTimeout(o,2e3,null)}(J,N,G)},s[8]=N,s[9]=b,s[10]=J,s[11]=d,s[12]=ee):ee=s[12],w(ee),"error"===g.type){let e;return s[13]!==g.message?(e=t(T,{marginTop:1,children:n(y,{color:"error",children:["Error al cargar estadísticas: ",g.message]})}),s[13]=g.message,s[14]=e):e=s[14],e}if("empty"===g.type){let e;return s[15]===Symbol.for("react.memo_cache_sentinel")?(e=t(T,{marginTop:1,children:t(y,{color:"warning",children:"Aún no hay estadísticas disponibles. ¡Comienza a usar Context Code!"})}),s[15]=e):e=s[15],e}if(!J||!V){let e;return s[16]===Symbol.for("react.memo_cache_sentinel")?(e=n(T,{marginTop:1,children:[t(B,{}),t(y,{children:" Cargando estadísticas…"})]}),s[16]=e):e=s[16],e}s[17]!==V||s[18]!==b||s[19]!==J||s[20]!==U?(te=t(L,{title:"Resumen",children:t(OverviewTab,{stats:J,allTimeStats:V,dateRange:b,isLoading:U})}),s[17]=V,s[18]=b,s[19]=J,s[20]=U,s[21]=te):te=s[21],s[22]!==b||s[23]!==J||s[24]!==U?(ne=t(L,{title:"Modelos",children:t(ModelsTab,{stats:J,dateRange:b,isLoading:U})}),s[22]=b,s[23]=J,s[24]=U,s[25]=ne):ne=s[25],s[26]!==te||s[27]!==ne?(oe=t(T,{flexDirection:"row",gap:1,marginBottom:1,children:n(R,{title:"",color:"claude",defaultTab:"Resumen",children:[te,ne]})}),s[26]=te,s[27]=ne,s[28]=oe):oe=s[28];const re=q?` · ${"copying…"===q?"copiando…":"copied!"===q?"¡copiado!":"copy failed"===q?"copia fallida":q}`:"";let se,ie;return s[29]!==re?(se=t(T,{paddingLeft:2,children:n(y,{dimColor:!0,children:["Esc para cancelar · r para recorrer fechas · ctrl+s para copiar",re]})}),s[29]=re,s[30]=se):se=s[30],s[31]!==se||s[32]!==oe?(ie=n(F,{color:"claude",children:[oe,se]}),s[31]=se,s[32]=oe,s[33]=ie):ie=s[33],ie}function _temp(e){return"Overview"===e?"Models":"Overview"}function DateRangeSelector(e){const o=r(9),{dateRange:s,isLoading:i}=e;let a,l,c,u;return o[0]!==s?(a=H.map((e,o)=>n(y,{children:[o>0&&t(y,{dimColor:!0,children:" · "}),t(y,e===s?{bold:!0,color:"claude",children:E[e]}:{dimColor:!0,children:E[e]})]},e)),o[0]=s,o[1]=a):a=o[1],o[2]!==a?(l=t(T,{children:a}),o[2]=a,o[3]=l):l=o[3],o[4]!==i?(c=i&&t(B,{}),o[4]=i,o[5]=c):c=o[5],o[6]!==l||o[7]!==c?(u=n(T,{marginBottom:1,gap:1,children:[l,c]}),o[6]=l,o[7]=c,o[8]=u):u=o[8],u}function OverviewTab({stats:r,allTimeStats:s,dateRange:i,isLoading:a}){const{columns:l}=g(),c=Object.entries(r.modelUsage).sort(([,e],[,t])=>t.inputTokens+t.outputTokens-(e.inputTokens+e.outputTokens)),u=c[0],m=c.reduce((e,[,t])=>e+t.inputTokens+t.outputTokens,0),p=d(()=>generateFunFactoid(r,m),[r,m]),f="7d"===i?7:"30d"===i?30:r.totalDays;let k=null;if(e("SHOT_STATS")&&r.shotDistribution){const e=r.shotDistribution,t=Object.values(e).reduce((e,t)=>e+t,0);if(t>0){const n=Object.entries(e).reduce((e,[t,n])=>e+parseInt(t,10)*n,0),bucket=(t,n)=>Object.entries(e).filter(([e])=>{const o=parseInt(e,10);return o>=t&&(void 0===n||o<=n)}).reduce((e,[,t])=>e+t,0),pct=e=>Math.round(e/t*100),o=bucket(1,1),r=bucket(2,5),s=bucket(6,10),i=bucket(11);k={avgShots:(n/t).toFixed(1),buckets:[{label:"1-shot",count:o,pct:pct(o)},{label:"2–5 shot",count:r,pct:pct(r)},{label:"6–10 shot",count:s,pct:pct(s)},{label:"11+ shot",count:i,pct:pct(i)}]}}}return n(T,{flexDirection:"column",marginTop:1,children:[s.dailyActivity.length>0&&t(T,{flexDirection:"column",marginBottom:1,children:t(b,{children:M(s.dailyActivity,{terminalWidth:l})})}),t(DateRangeSelector,{dateRange:i,isLoading:a}),n(T,{flexDirection:"row",gap:4,marginBottom:1,children:[t(T,{flexDirection:"column",width:28,children:u&&n(y,{wrap:"truncate",children:["Modelo favorito:"," ",t(y,{color:"claude",bold:!0,children:j(u[0])})]})}),t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Tokens totales:"," ",t(y,{color:"claude",children:v(m)})]})})]}),n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Sesiones:"," ",t(y,{color:"claude",children:v(r.totalSessions)})]})}),t(T,{flexDirection:"column",width:28,children:r.longestSession&&n(y,{wrap:"truncate",children:["Sesión más larga:"," ",t(y,{color:"claude",children:D(r.longestSession.duration)})]})})]}),n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Días activos: ",t(y,{color:"claude",children:r.activeDays}),n(y,{color:"subtle",children:["/",f]})]})}),t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Racha más larga:"," ",t(y,{color:"claude",bold:!0,children:r.streaks.longestStreak})," ",1===r.streaks.longestStreak?"día":"días"]})})]}),n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:28,children:r.peakActivityDay&&n(y,{wrap:"truncate",children:["Día más activo:"," ",t(y,{color:"claude",children:(w=r.peakActivityDay,new Date(w).toLocaleDateString("en-US",{month:"short",day:"numeric"}))})]})}),t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Racha actual:"," ",t(y,{color:"claude",bold:!0,children:s.streaks.currentStreak})," ",1===s.streaks.currentStreak?"día":"días"]})})]}),!1,k&&n(o,{children:[t(T,{marginTop:1,children:t(y,{children:"Distribución de turnos (shots)"})}),n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:[k.buckets[0].label,":"," ",t(y,{color:"claude",children:k.buckets[0].count}),n(y,{color:"subtle",children:[" (",k.buckets[0].pct,"%)"]})]})}),t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:[k.buckets[1].label,":"," ",t(y,{color:"claude",children:k.buckets[1].count}),n(y,{color:"subtle",children:[" (",k.buckets[1].pct,"%)"]})]})})]}),n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:[k.buckets[2].label,":"," ",t(y,{color:"claude",children:k.buckets[2].count}),n(y,{color:"subtle",children:[" (",k.buckets[2].pct,"%)"]})]})}),t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:[k.buckets[3].label,":"," ",t(y,{color:"claude",children:k.buckets[3].count}),n(y,{color:"subtle",children:[" (",k.buckets[3].pct,"%)"]})]})})]}),t(T,{flexDirection:"row",gap:4,children:t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Promedio/sesión:"," ",t(y,{color:"claude",children:k.avgShots})]})})})]}),p&&t(T,{marginTop:1,children:t(y,{color:"suggestion",children:p})})]});var w}const I=[{name:"The Little Prince",tokens:22e3},{name:"The Old Man and the Sea",tokens:35e3},{name:"A Christmas Carol",tokens:37e3},{name:"Animal Farm",tokens:39e3},{name:"Fahrenheit 451",tokens:6e4},{name:"The Great Gatsby",tokens:62e3},{name:"Slaughterhouse-Five",tokens:64e3},{name:"Brave New World",tokens:83e3},{name:"The Catcher in the Rye",tokens:95e3},{name:"Harry Potter and the Philosopher's Stone",tokens:103e3},{name:"The Hobbit",tokens:123e3},{name:"1984",tokens:123e3},{name:"To Kill a Mockingbird",tokens:13e4},{name:"Pride and Prejudice",tokens:156e3},{name:"Dune",tokens:244e3},{name:"Moby-Dick",tokens:268e3},{name:"Crime and Punishment",tokens:274e3},{name:"A Game of Thrones",tokens:381e3},{name:"Anna Karenina",tokens:468e3},{name:"Don Quixote",tokens:52e4},{name:"The Lord of the Rings",tokens:576e3},{name:"The Count of Monte Cristo",tokens:603e3},{name:"Les Misérables",tokens:689e3},{name:"War and Peace",tokens:73e4}],U=[{name:"a TED talk",minutes:18},{name:"an episode of The Office",minutes:22},{name:"listening to Abbey Road",minutes:47},{name:"a yoga class",minutes:60},{name:"a World Cup soccer match",minutes:90},{name:"a half marathon (average time)",minutes:120},{name:"the movie Inception",minutes:148},{name:"watching Titanic",minutes:195},{name:"a transatlantic flight",minutes:420},{name:"a full night of sleep",minutes:480}];function generateFunFactoid(e,t){const n=[];if(t>0){const e=I.filter(e=>t>=e.tokens);for(const o of e){const e=t/o.tokens;e>=2?n.push(`Has usado ~${Math.floor(e)} veces más tokens que en ${o.name}`):n.push(`Has usado el mismo número de tokens que en ${o.name}`)}}if(e.longestSession){const t=e.longestSession.duration/6e4;for(const e of U){const o=t/e.minutes;o>=2&&n.push(`Tu sesión más larga es ~${Math.floor(o)} veces más larga que ${e.name}`)}}if(0===n.length)return"";return n[Math.floor(Math.random()*n.length)]}function ModelsTab(e){const o=r(15),{stats:s,dateRange:i,isLoading:l}=e,{headerFocused:c,focusHeader:u}=P(),[d,p]=m(0),{columns:f}=g(),k=Object.entries(s.modelUsage).sort(_temp7),S=!c;let x;if(o[0]!==S?(x={isActive:S},o[0]=S,o[1]=x):x=o[1],w((e,t)=>{t.downArrow&&d<k.length-4&&p(e=>Math.min(e+2,k.length-4)),t.upArrow&&(d>0?p(_temp8):u())},x),0===k.length){let e;return o[2]===Symbol.for("react.memo_cache_sentinel")?(e=t(T,{children:t(y,{color:"subtle",children:"No model usage data available"})}),o[2]=e):e=o[2],e}const D=k.reduce(_temp9,0),v=generateTokenChart(s.dailyModelTokens,k.map(_temp0),f),M=k.slice(d,d+4),j=Math.ceil(M.length/2),$=M.slice(0,j),C=M.slice(j),_=d>0,A=d<k.length-4,O=k.length>4;let F;o[3]!==i||o[4]!==l?(F=t(DateRangeSelector,{dateRange:i,isLoading:l}),o[3]=i,o[4]=l,o[5]=F):F=o[5];const L=T,R=C.map(e=>{const[n,o]=e;return t(ModelEntry,{model:n,usage:o,totalTokens:D},n)});let B,E;return o[6]!==L||o[7]!==R?(B=t(L,{flexDirection:"column",width:36,children:R}),o[6]=L,o[7]=R,o[8]=B):B=o[8],o[9]!==A||o[10]!==_||o[11]!==k||o[12]!==d||o[13]!==O?(E=O&&t(T,{marginTop:1,children:n(y,{color:"subtle",children:[_?a.arrowUp:" "," ",A?a.arrowDown:" "," ",d+1,"-",Math.min(d+4,k.length)," de"," ",k.length," modelos (↑↓ para desplazar)"]})}),o[9]=A,o[10]=_,o[11]=k,o[12]=d,o[13]=O,o[14]=E):E=o[14],n(T,{flexDirection:"column",marginTop:1,children:[v&&n(T,{flexDirection:"column",marginBottom:1,children:[t(y,{bold:!0,children:"Tokens por día"}),t(b,{children:v.chart}),t(y,{color:"subtle",children:v.xAxisLabels}),t(T,{children:v.legend.map(_temp1)})]}),F,n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:36,children:$.map(e=>{const[n,o]=e;return t(ModelEntry,{model:n,usage:o,totalTokens:D},n)})}),B]}),E]})}function _temp1(e,o){return n(y,{children:[o>0?" · ":"",t(b,{children:e.coloredBullet})," ",e.model]},e.model)}function _temp0(e){const[t]=e;return t}function _temp9(e,t){const[,n]=t;return e+n.inputTokens+n.outputTokens}function _temp8(e){return Math.max(e-2,0)}function _temp7(e,t){const[,n]=e,[,o]=t;return o.inputTokens+o.outputTokens-(n.inputTokens+n.outputTokens)}function ModelEntry(e){const o=r(21),{model:s,usage:i,totalTokens:l}=e,c=(i.inputTokens+i.outputTokens)/l*100;let u;o[0]!==c?(u=c.toFixed(1),o[0]=c,o[1]=u):u=o[1];const d=u;let m,p,g,f,k,b,w,S;return o[2]!==s?(m=j(s),o[2]=s,o[3]=m):m=o[3],o[4]!==m?(p=t(y,{bold:!0,children:m}),o[4]=m,o[5]=p):p=o[5],o[6]!==d?(g=n(y,{color:"subtle",children:["(",d,"%)"]}),o[6]=d,o[7]=g):g=o[7],o[8]!==p||o[9]!==g?(f=n(y,{children:[a.bullet," ",p," ",g]}),o[8]=p,o[9]=g,o[10]=f):f=o[10],o[11]!==i.inputTokens?(k=v(i.inputTokens),o[11]=i.inputTokens,o[12]=k):k=o[12],o[13]!==i.outputTokens?(b=v(i.outputTokens),o[13]=i.outputTokens,o[14]=b):b=o[14],o[15]!==k||o[16]!==b?(w=n(y,{color:"subtle",children:[" ","In: ",k," · Out:"," ",b]}),o[15]=k,o[16]=b,o[17]=w):w=o[17],o[18]!==f||o[19]!==w?(S=n(T,{flexDirection:"column",children:[f,w]}),o[18]=f,o[19]=w,o[20]=S):S=o[20],S}function generateTokenChart(e,t,n){if(e.length<2||0===t.length)return null;const o=n-7,r=Math.min(52,Math.max(20,o));let i;if(e.length>=r)i=e.slice(-r);else{const t=Math.floor(r/e.length);i=[];for(const n of e)for(let e=0;e<t;e++)i.push(n)}const l=A(_(x().theme)),c=[O(l.suggestion),O(l.success),O(l.warning)],u=[],d=[],m=t.slice(0,3);for(let e=0;e<m.length;e++){const t=m[e],n=i.map(e=>e.tokensByModel[t]||0);if(n.some(e=>e>0)){u.push(n);const o=[l.suggestion,l.success,l.warning];d.push({model:j(t),coloredBullet:f(a.bullet,o[e%o.length])})}}if(0===u.length)return null;return{chart:s(u,{height:8,colors:c.slice(0,u.length),format:e=>{let t;return t=e>=1e6?(e/1e6).toFixed(1)+"M":e>=1e3?(e/1e3).toFixed(0)+"k":e.toFixed(0),t.padStart(6)}}),legend:d,xAxisLabels:function(e,t,n){if(0===e.length)return"";const o=Math.min(4,Math.max(2,Math.floor(e.length/8))),r=e.length-6,s=Math.floor(r/(o-1))||1,i=[];for(let t=0;t<o;t++){const n=Math.min(t*s,e.length-1),o=new Date(e[n].date).toLocaleDateString("en-US",{month:"short",day:"numeric"});i.push({pos:n,label:o})}let a=" ".repeat(n),l=0;for(const{pos:e,label:t}of i){const n=Math.max(1,e-l);a+=" ".repeat(n)+t,l=e+t.length}return a}(i,i.length,7)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as r}from"react/jsx-runtime";import{c as
|
|
1
|
+
import{jsxs as e,jsx as r}from"react/jsx-runtime";import{c as n}from"react/compiler-runtime";import o from"figures";import{useState as t}from"react";import{Box as i,Text as l,useAnimationFrame as a}from"../ink.js";import{AppStateProvider as c}from"../state/AppState.js";import{checkOutTeleportedSessionBranch as s,processMessagesForTeleportResume as d,teleportResumeCodeSession as m}from"../utils/teleport.js";const h=["◐","◓","◑","◒"],p=[{key:"validating",label:"Validando sesión"},{key:"fetching_logs",label:"Obteniendo registros de la sesión"},{key:"fetching_branch",label:"Obteniendo información de la rama"},{key:"checking_out",label:"Cambiando a la rama"}];export function TeleportProgress(t){const c=n(16),{currentStep:s,sessionId:d}=t,[m,f]=a(100),g=Math.floor(f/100)%h.length;let u;c[0]!==s?(u=e=>e.key===s,c[0]=s,c[1]=u):u=c[1];const b=p.findIndex(u),k=h[g];let x,y,j,w,C;return c[2]!==k?(x=r(i,{marginBottom:1,children:e(l,{bold:!0,color:"claude",children:[k," Teletransportando sesión…"]})}),c[2]=k,c[3]=x):x=c[3],c[4]!==d?(y=d&&r(i,{marginBottom:1,children:r(l,{dimColor:!0,children:d})}),c[4]=d,c[5]=y):y=c[5],c[6]!==b||c[7]!==g?(j=p.map((n,t)=>{const a=t===b,c=t>b;let s,d;return t<b?(s=o.tick,d="green"):a?(s=h[g],d="claude"):(s=o.circle,d=void 0),e(i,{flexDirection:"row",children:[r(i,{width:2,children:r(l,{color:d,dimColor:c,children:s})}),r(l,{dimColor:c,bold:a,children:n.label})]},n.key)}),c[6]=b,c[7]=g,c[8]=j):j=c[8],c[9]!==j?(w=r(i,{flexDirection:"column",marginLeft:2,children:j}),c[9]=j,c[10]=w):w=c[10],c[11]!==m||c[12]!==x||c[13]!==y||c[14]!==w?(C=e(i,{ref:m,flexDirection:"column",paddingX:1,paddingY:1,children:[x,y,w]}),c[11]=m,c[12]=x,c[13]=y,c[14]=w,c[15]=C):C=c[15],C}export async function teleportWithProgress(e,n){let setStep=()=>{};e.render(r(c,{children:r(function(){const[e,o]=t("validating");return setStep=o,r(TeleportProgress,{currentStep:e,sessionId:n})},{})}));const o=await m(n,setStep);setStep("checking_out");const{branchName:i,branchError:l}=await s(o.branch);return{messages:d(o.log,l),branchName:i}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as
|
|
1
|
+
import{jsxs as e,jsx as o}from"react/jsx-runtime";import{c as t}from"react/compiler-runtime";import{useState as n}from"react";import{Box as r,Link as i,Text as a}from"../ink.js";import{ConfigurableShortcutHint as c}from"./ConfigurableShortcutHint.js";import{SelectMulti as l}from"./CustomSelect/SelectMulti.js";import{Byline as s}from"./design-system/Byline.js";import{Dialog as m}from"./design-system/Dialog.js";import{KeyboardShortcutHint as u}from"./design-system/KeyboardShortcutHint.js";const d=[{value:"claude",label:"@Context Code - Etiqueta a @contextcode en issues y comentarios de PR"},{value:"claude-review",label:"Revisión de Context Code - Revisión automática de código en nuevos PRs"}];function renderInputGuide(t){return t.pending?e(a,{children:["Presiona ",t.keyName," de nuevo para salir"]}):e(s,{children:[o(u,{shortcut:"↑↓",action:"navegar"}),o(u,{shortcut:"Space",action:"alternar"}),o(u,{shortcut:"Enter",action:"confirmar"}),o(c,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"cancelar"})]})}export function WorkflowMultiselectDialog(c){const s=t(14),{onSubmit:u,defaultSelections:p}=c,[f,h]=n(!1);let b;s[0]!==u?(b=e=>{0!==e.length?(h(!1),u(e)):h(!0)},s[0]=u,s[1]=b):b=s[1];const j=b;let g;s[2]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{h(!1)},s[2]=g):g=s[2];const C=g;let S;s[3]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{h(!0)},s[3]=S):S=s[3];const v=S;let x,y,_,k,G;return s[4]===Symbol.for("react.memo_cache_sentinel")?(x=o(r,{children:e(a,{dimColor:!0,children:["Más ejemplos de flujos de trabajo (clasificación de issues, correcciones de CI, etc.) en:"," ",o(i,{url:"https://github.com/anthropics/claude-code-action/blob/main/examples/",children:"https://github.com/anthropics/claude-code-action/blob/main/examples/"})]})}),s[4]=x):x=s[4],s[5]===Symbol.for("react.memo_cache_sentinel")?(y=d.map(_temp),s[5]=y):y=s[5],s[6]!==p||s[7]!==j?(_=o(l,{options:y,defaultValue:p,onSubmit:j,onChange:C,onCancel:v,hideIndexes:!0}),s[6]=p,s[7]=j,s[8]=_):_=s[8],s[9]!==f?(k=f&&o(r,{children:o(a,{color:"error",children:"Debes seleccionar al menos un flujo de trabajo para continuar"})}),s[9]=f,s[10]=k):k=s[10],s[11]!==_||s[12]!==k?(G=e(m,{title:"Selecciona los flujos de GitHub a instalar",subtitle:"Crearemos un archivo de flujo de trabajo en tu repositorio por cada uno que selecciones.",onCancel:v,inputGuide:renderInputGuide,children:[x,_,k]}),s[11]=_,s[12]=k,s[13]=G):G=s[13],G}function _temp(e){return{label:e.label,value:e.value}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,D as s,E as i,H as a,I as o,K as l,L as h,M as u,O as d,U as c,a as _,b as p,ca as g,d as y,e as m,f as v,g as V,n as f,oa as C,p as A,q as b,qa as w,ra as D,sa as S,ta as O,u as k,va as P,z as x}from"./chunk-VAB2VXFI.js";var T=(()=>{class n{_renderer;_elementRef;onChange=e=>{};onTouched=()=>{};constructor(e,s){this._renderer=e,this._elementRef=s}setProperty(e,s){this._renderer.setProperty(this._elementRef.nativeElement,e,s)}registerOnTouched(e){this.onTouched=e}registerOnChange(e){this.onChange=e}setDisabledState(e){this.setProperty("disabled",e)}static ɵfac=function(e){return new(e||n)(o(a),o(s))};static ɵdir=h({type:n})}return n})(),M=(()=>{class n extends T{static ɵfac=(()=>{let e;return function(s){return(e||(e=x(n)))(s||n)}})();static ɵdir=h({type:n,features:[u]})}return n})(),F=new b(""),R={provide:F,useExisting:f(()=>N),multi:!0};var U=new b(""),N=(()=>{class n extends T{_compositionMode;_composing=!1;constructor(e,s,i){super(e,s),this._compositionMode=i,null==this._compositionMode&&(this._compositionMode=!function(){let e=P()?P().getUserAgent():"";return/android (\d+)/.test(e.toLowerCase())}())}writeValue(e){let s=e??"";this.setProperty("value",s)}_handleInput(e){(!this._compositionMode||this._compositionMode&&!this._composing)&&this.onChange(e)}_compositionStart(){this._composing=!0}_compositionEnd(e){this._composing=!1,this._compositionMode&&this.onChange(e)}static ɵfac=function(e){return new(e||n)(o(a),o(s),o(U,8))};static ɵdir=h({type:n,selectors:[["input","formControlName","",3,"type","checkbox"],["textarea","formControlName",""],["input","formControl","",3,"type","checkbox"],["textarea","formControl",""],["input","ngModel","",3,"type","checkbox"],["textarea","ngModel",""],["","ngDefaultControl",""]],hostBindings:function(e,s){1&e&&g("input",function(e){return s._handleInput(e.target.value)})("blur",function(){return s.onTouched()})("compositionstart",function(){return s._compositionStart()})("compositionend",function(e){return s._compositionEnd(e.target.value)})},standalone:!1,features:[C([R]),u]})}return n})(),j=new b(""),H=new b("");function ue(e){return null!=e}function de(e){return d(e)?m(e):e}function ce(e){let s={};return e.forEach(e=>{s=null!=e?_(_({},s),e):s}),0===Object.keys(s).length?null:s}function he(e,s){return s.map(s=>s(e))}function fe(e){return e.map(e=>function(e){return!e.validate}(e)?e:s=>e.validate(s))}function ge(e){return null!=e?function(e){if(!e)return null;let s=e.filter(ue);return 0==s.length?null:function(e){return ce(he(e,s))}}(fe(e)):null}function pe(e){return null!=e?function(e){if(!e)return null;let s=e.filter(ue);return 0==s.length?null:function(e){let i=he(e,s).map(de);return V(i).pipe(v(ce))}}(fe(e)):null}function Q(e,s){return null===e?[s]:Array.isArray(e)?[...e,s]:[e,s]}function G(e){return e?Array.isArray(e)?e:[e]:[]}function E(e,s){return Array.isArray(e)?e.includes(s):e===s}function ee(e,s){let i=G(s);return G(e).forEach(e=>{E(i,e)||i.push(e)}),i}function te(e,s){return G(s).filter(s=>!E(e,s))}var B=class{get value(){return this.control?this.control.value:null}get valid(){return this.control?this.control.valid:null}get invalid(){return this.control?this.control.invalid:null}get pending(){return this.control?this.control.pending:null}get disabled(){return this.control?this.control.disabled:null}get enabled(){return this.control?this.control.enabled:null}get errors(){return this.control?this.control.errors:null}get pristine(){return this.control?this.control.pristine:null}get dirty(){return this.control?this.control.dirty:null}get touched(){return this.control?this.control.touched:null}get status(){return this.control?this.control.status:null}get untouched(){return this.control?this.control.untouched:null}get statusChanges(){return this.control?this.control.statusChanges:null}get valueChanges(){return this.control?this.control.valueChanges:null}get path(){return null}_composedValidatorFn;_composedAsyncValidatorFn;_rawValidators=[];_rawAsyncValidators=[];_setValidators(e){this._rawValidators=e||[],this._composedValidatorFn=ge(this._rawValidators)}_setAsyncValidators(e){this._rawAsyncValidators=e||[],this._composedAsyncValidatorFn=pe(this._rawAsyncValidators)}get validator(){return this._composedValidatorFn||null}get asyncValidator(){return this._composedAsyncValidatorFn||null}_onDestroyCallbacks=[];_registerOnDestroy(e){this._onDestroyCallbacks.push(e)}_invokeOnDestroyCallbacks(){this._onDestroyCallbacks.forEach(e=>e()),this._onDestroyCallbacks=[]}reset(e=void 0){this.control&&this.control.reset(e)}hasError(e,s){return!!this.control&&this.control.hasError(e,s)}getError(e,s){return this.control?this.control.getError(e,s):null}},L=class extends B{name;get formDirective(){return null}get path(){return null}},q=class extends B{_parent=null;name=null;valueAccessor=null},$=class{_cd;constructor(e){this._cd=e}get isTouched(){return this._cd?.control?._touched?.(),!!this._cd?.control?.touched}get isUntouched(){return!!this._cd?.control?.untouched}get isPristine(){return this._cd?.control?._pristine?.(),!!this._cd?.control?.pristine}get isDirty(){return!!this._cd?.control?.dirty}get isValid(){return this._cd?.control?._status?.(),!!this._cd?.control?.valid}get isInvalid(){return!!this._cd?.control?.invalid}get isPending(){return!!this._cd?.control?.pending}get isSubmitted(){return this._cd?._submitted?.(),!!this._cd?.submitted}},K=(p(_({},{"[class.ng-untouched]":"isUntouched","[class.ng-touched]":"isTouched","[class.ng-pristine]":"isPristine","[class.ng-dirty]":"isDirty","[class.ng-valid]":"isValid","[class.ng-invalid]":"isInvalid","[class.ng-pending]":"isPending"}),{"[class.ng-submitted]":"isSubmitted"}),(()=>{class n extends ${constructor(e){super(e)}static ɵfac=function(e){return new(e||n)(o(q,2))};static ɵdir=h({type:n,selectors:[["","formControlName",""],["","ngModel",""],["","formControl",""]],hostVars:14,hostBindings:function(e,s){2&e&&c("ng-untouched",s.isUntouched)("ng-touched",s.isTouched)("ng-pristine",s.isPristine)("ng-dirty",s.isDirty)("ng-valid",s.isValid)("ng-invalid",s.isInvalid)("ng-pending",s.isPending)},standalone:!1,features:[u]})}return n})()),X="VALID",z="INVALID",J="PENDING",W="DISABLED",Y=class{},Z=class extends Y{value;source;constructor(e,s){super(),this.value=e,this.source=s}},tt=class extends Y{pristine;source;constructor(e,s){super(),this.pristine=e,this.source=s}},et=class extends Y{touched;source;constructor(e,s){super(),this.touched=e,this.source=s}},st=class extends Y{status;source;constructor(e,s){super(),this.status=e,this.source=s}};function I(e){return null!=e&&!Array.isArray(e)&&"object"==typeof e}var nt=class{_pendingDirty=!1;_hasOwnPendingAsyncValidator=null;_pendingTouched=!1;_onCollectionChange=()=>{};_updateOn;_parent=null;_asyncValidationSubscription;_composedValidatorFn;_composedAsyncValidatorFn;_rawValidators;_rawAsyncValidators;value;constructor(e,s){this._assignValidators(e),this._assignAsyncValidators(s)}get validator(){return this._composedValidatorFn}set validator(e){this._rawValidators=this._composedValidatorFn=e}get asyncValidator(){return this._composedAsyncValidatorFn}set asyncValidator(e){this._rawAsyncValidators=this._composedAsyncValidatorFn=e}get parent(){return this._parent}get status(){return S(this.statusReactive)}set status(e){S(()=>this.statusReactive.set(e))}_status=O(()=>this.statusReactive());statusReactive=i(void 0);get valid(){return this.status===X}get invalid(){return this.status===z}get pending(){return this.status==J}get disabled(){return this.status===W}get enabled(){return this.status!==W}errors;get pristine(){return S(this.pristineReactive)}set pristine(e){S(()=>this.pristineReactive.set(e))}_pristine=O(()=>this.pristineReactive());pristineReactive=i(!0);get dirty(){return!this.pristine}get touched(){return S(this.touchedReactive)}set touched(e){S(()=>this.touchedReactive.set(e))}_touched=O(()=>this.touchedReactive());touchedReactive=i(!1);get untouched(){return!this.touched}_events=new y;events=this._events.asObservable();valueChanges;statusChanges;get updateOn(){return this._updateOn?this._updateOn:this.parent?this.parent.updateOn:"change"}setValidators(e){this._assignValidators(e)}setAsyncValidators(e){this._assignAsyncValidators(e)}addValidators(e){this.setValidators(ee(e,this._rawValidators))}addAsyncValidators(e){this.setAsyncValidators(ee(e,this._rawAsyncValidators))}removeValidators(e){this.setValidators(te(e,this._rawValidators))}removeAsyncValidators(e){this.setAsyncValidators(te(e,this._rawAsyncValidators))}hasValidator(e){return E(this._rawValidators,e)}hasAsyncValidator(e){return E(this._rawAsyncValidators,e)}clearValidators(){this.validator=null}clearAsyncValidators(){this.asyncValidator=null}markAsTouched(e={}){let s=!1===this.touched;this.touched=!0;let i=e.sourceControl??this;this._parent&&!e.onlySelf&&this._parent.markAsTouched(p(_({},e),{sourceControl:i})),s&&!1!==e.emitEvent&&this._events.next(new et(!0,i))}markAllAsTouched(e={}){this.markAsTouched({onlySelf:!0,emitEvent:e.emitEvent,sourceControl:this}),this._forEachChild(s=>s.markAllAsTouched(e))}markAsUntouched(e={}){let s=!0===this.touched;this.touched=!1,this._pendingTouched=!1;let i=e.sourceControl??this;this._forEachChild(s=>{s.markAsUntouched({onlySelf:!0,emitEvent:e.emitEvent,sourceControl:i})}),this._parent&&!e.onlySelf&&this._parent._updateTouched(e,i),s&&!1!==e.emitEvent&&this._events.next(new et(!1,i))}markAsDirty(e={}){let s=!0===this.pristine;this.pristine=!1;let i=e.sourceControl??this;this._parent&&!e.onlySelf&&this._parent.markAsDirty(p(_({},e),{sourceControl:i})),s&&!1!==e.emitEvent&&this._events.next(new tt(!1,i))}markAsPristine(e={}){let s=!1===this.pristine;this.pristine=!0,this._pendingDirty=!1;let i=e.sourceControl??this;this._forEachChild(s=>{s.markAsPristine({onlySelf:!0,emitEvent:e.emitEvent})}),this._parent&&!e.onlySelf&&this._parent._updatePristine(e,i),s&&!1!==e.emitEvent&&this._events.next(new tt(!0,i))}markAsPending(e={}){this.status=J;let s=e.sourceControl??this;!1!==e.emitEvent&&(this._events.next(new st(this.status,s)),this.statusChanges.emit(this.status)),this._parent&&!e.onlySelf&&this._parent.markAsPending(p(_({},e),{sourceControl:s}))}disable(e={}){let s=this._parentMarkedDirty(e.onlySelf);this.status=W,this.errors=null,this._forEachChild(s=>{s.disable(p(_({},e),{onlySelf:!0}))}),this._updateValue();let i=e.sourceControl??this;!1!==e.emitEvent&&(this._events.next(new Z(this.value,i)),this._events.next(new st(this.status,i)),this.valueChanges.emit(this.value),this.statusChanges.emit(this.status)),this._updateAncestors(p(_({},e),{skipPristineCheck:s}),this),this._onDisabledChange.forEach(e=>e(!0))}enable(e={}){let s=this._parentMarkedDirty(e.onlySelf);this.status=X,this._forEachChild(s=>{s.enable(p(_({},e),{onlySelf:!0}))}),this.updateValueAndValidity({onlySelf:!0,emitEvent:e.emitEvent}),this._updateAncestors(p(_({},e),{skipPristineCheck:s}),this),this._onDisabledChange.forEach(e=>e(!1))}_updateAncestors(e,s){this._parent&&!e.onlySelf&&(this._parent.updateValueAndValidity(e),e.skipPristineCheck||this._parent._updatePristine({},s),this._parent._updateTouched({},s))}setParent(e){this._parent=e}getRawValue(){return this.value}updateValueAndValidity(e={}){if(this._setInitialStatus(),this._updateValue(),this.enabled){let s=this._cancelExistingSubscription();this.errors=this._runValidator(),this.status=this._calculateStatus(),(this.status===X||this.status===J)&&this._runAsyncValidator(s,e.emitEvent)}let s=e.sourceControl??this;!1!==e.emitEvent&&(this._events.next(new Z(this.value,s)),this._events.next(new st(this.status,s)),this.valueChanges.emit(this.value),this.statusChanges.emit(this.status)),this._parent&&!e.onlySelf&&this._parent.updateValueAndValidity(p(_({},e),{sourceControl:s}))}_updateTreeValidity(e={emitEvent:!0}){this._forEachChild(s=>s._updateTreeValidity(e)),this.updateValueAndValidity({onlySelf:!0,emitEvent:e.emitEvent})}_setInitialStatus(){this.status=this._allControlsDisabled()?W:X}_runValidator(){return this.validator?this.validator(this):null}_runAsyncValidator(e,s){if(this.asyncValidator){this.status=J,this._hasOwnPendingAsyncValidator={emitEvent:!1!==s};let i=de(this.asyncValidator(this));this._asyncValidationSubscription=i.subscribe(i=>{this._hasOwnPendingAsyncValidator=null,this.setErrors(i,{emitEvent:s,shouldHaveEmitted:e})})}}_cancelExistingSubscription(){if(this._asyncValidationSubscription){this._asyncValidationSubscription.unsubscribe();let e=this._hasOwnPendingAsyncValidator?.emitEvent??!1;return this._hasOwnPendingAsyncValidator=null,e}return!1}setErrors(e,s={}){this.errors=e,this._updateControlsErrors(!1!==s.emitEvent,this,s.shouldHaveEmitted)}get(e){let s=e;return null==s||(Array.isArray(s)||(s=s.split(".")),0===s.length)?null:s.reduce((e,s)=>e&&e._find(s),this)}getError(e,s){let i=s?this.get(s):this;return i&&i.errors?i.errors[e]:null}hasError(e,s){return!!this.getError(e,s)}get root(){let e=this;for(;e._parent;)e=e._parent;return e}_updateControlsErrors(e,s,i){this.status=this._calculateStatus(),e&&this.statusChanges.emit(this.status),(e||i)&&this._events.next(new st(this.status,s)),this._parent&&this._parent._updateControlsErrors(e,s,i)}_initObservables(){this.valueChanges=new e,this.statusChanges=new e}_calculateStatus(){return this._allControlsDisabled()?W:this.errors?z:this._hasOwnPendingAsyncValidator||this._anyControlsHaveStatus(J)?J:this._anyControlsHaveStatus(z)?z:X}_anyControlsHaveStatus(e){return this._anyControls(s=>s.status===e)}_anyControlsDirty(){return this._anyControls(e=>e.dirty)}_anyControlsTouched(){return this._anyControls(e=>e.touched)}_updatePristine(e,s){let i=!this._anyControlsDirty(),a=this.pristine!==i;this.pristine=i,this._parent&&!e.onlySelf&&this._parent._updatePristine(e,s),a&&this._events.next(new tt(this.pristine,s))}_updateTouched(e={},s){this.touched=this._anyControlsTouched(),this._events.next(new et(this.touched,s)),this._parent&&!e.onlySelf&&this._parent._updateTouched(e,s)}_onDisabledChange=[];_registerOnCollectionChange(e){this._onCollectionChange=e}_setUpdateStrategy(e){I(e)&&null!=e.updateOn&&(this._updateOn=e.updateOn)}_parentMarkedDirty(e){let s=this._parent&&this._parent.dirty;return!e&&!!s&&!this._parent._anyControlsDirty()}_find(e){return null}_assignValidators(e){var s;this._rawValidators=Array.isArray(e)?e.slice():e,this._composedValidatorFn=(s=this._rawValidators,Array.isArray(s)?ge(s):s||null)}_assignAsyncValidators(e){var s;this._rawAsyncValidators=Array.isArray(e)?e.slice():e,this._composedAsyncValidatorFn=(s=this._rawAsyncValidators,Array.isArray(s)?pe(s):s||null)}},it=new b("",{providedIn:"root",factory:()=>rt}),rt="always";function Re(e,s,i=rt){(function(e,s){let i=function(e){return e._rawValidators}(e);null!==s.validator?e.setValidators(Q(i,s.validator)):"function"==typeof i&&e.setValidators([i]);let a=function(e){return e._rawAsyncValidators}(e);null!==s.asyncValidator?e.setAsyncValidators(Q(a,s.asyncValidator)):"function"==typeof a&&e.setAsyncValidators([a]);let r=()=>e.updateValueAndValidity();ne(s._rawValidators,r),ne(s._rawAsyncValidators,r)})(e,s),s.valueAccessor.writeValue(e.value),(e.disabled||"always"===i)&&s.valueAccessor.setDisabledState?.(e.disabled),function(e,s){s.valueAccessor.registerOnChange(i=>{e._pendingValue=i,e._pendingChange=!0,e._pendingDirty=!0,"change"===e.updateOn&&_e(e,s)})}(e,s),function(e,s){let t=(e,i)=>{s.valueAccessor.writeValue(e),i&&s.viewToModelUpdate(e)};e.registerOnChange(t),s._registerOnDestroy(()=>{e._unregisterOnChange(t)})}(e,s),function(e,s){s.valueAccessor.registerOnTouched(()=>{e._pendingTouched=!0,"blur"===e.updateOn&&e._pendingChange&&_e(e,s),"submit"!==e.updateOn&&e.markAsTouched()})}(e,s),function(e,s){if(s.valueAccessor.setDisabledState){let t=e=>{s.valueAccessor.setDisabledState(e)};e.registerOnDisabledChange(t),s._registerOnDestroy(()=>{e._unregisterOnDisabledChange(t)})}}(e,s)}function ne(e,s){e.forEach(e=>{e.registerOnValidatorChange&&e.registerOnValidatorChange(s)})}function _e(e,s){e._pendingDirty&&e.markAsDirty(),e.setValue(e._pendingValue,{emitModelToViewChange:!1}),s.viewToModelUpdate(e._pendingValue),e._pendingChange=!1}function $e(e,s){if(!s)return null;let i,a,o;return Array.isArray(s),s.forEach(e=>{e.constructor===N?i=e:function(e){return Object.getPrototypeOf(e.constructor)===M}(e)?a=e:o=e}),o||a||i||null}function ie(e,s){let i=e.indexOf(s);i>-1&&e.splice(i,1)}function re(e){return"object"==typeof e&&null!==e&&2===Object.keys(e).length&&"value"in e&&"disabled"in e}var at=class extends nt{defaultValue=null;_onChange=[];_pendingValue;_pendingChange=!1;constructor(e=null,s,i){var a;super((I(a=s)?a.validators:a)||null,function(e,s){return(I(s)?s.asyncValidators:e)||null}(i,s)),this._applyFormState(e),this._setUpdateStrategy(s),this._initObservables(),this.updateValueAndValidity({onlySelf:!0,emitEvent:!!this.asyncValidator}),I(s)&&(s.nonNullable||s.initialValueIsDefault)&&(re(e)?this.defaultValue=e.value:this.defaultValue=e)}setValue(e,s={}){this.value=this._pendingValue=e,this._onChange.length&&!1!==s.emitModelToViewChange&&this._onChange.forEach(e=>e(this.value,!1!==s.emitViewToModelChange)),this.updateValueAndValidity(s)}patchValue(e,s={}){this.setValue(e,s)}reset(e=this.defaultValue,s={}){this._applyFormState(e),this.markAsPristine(s),this.markAsUntouched(s),this.setValue(this.value,s),this._pendingChange=!1}_updateValue(){}_anyControls(e){return!1}_allControlsDisabled(){return this.disabled}registerOnChange(e){this._onChange.push(e)}_unregisterOnChange(e){ie(this._onChange,e)}registerOnDisabledChange(e){this._onDisabledChange.push(e)}_unregisterOnDisabledChange(e){ie(this._onDisabledChange,e)}_forEachChild(e){}_syncPendingControls(){return!("submit"!==this.updateOn||(this._pendingDirty&&this.markAsDirty(),this._pendingTouched&&this.markAsTouched(),!this._pendingChange))&&(this.setValue(this._pendingValue,{onlySelf:!0,emitModelToViewChange:!1}),!0)}_applyFormState(e){re(e)?(this.value=this._pendingValue=e.value,e.disabled?this.disable({onlySelf:!0,emitEvent:!1}):this.enable({onlySelf:!0,emitEvent:!1})):this.value=this._pendingValue=e}},ot={provide:q,useExisting:f(()=>ht)},lt=Promise.resolve(),ht=(()=>{class n extends q{_changeDetectorRef;callSetDisabledState;control=new at;static ngAcceptInputType_isDisabled;_registered=!1;viewModel;name="";isDisabled;model;options;update=new e;constructor(e,s,i,a,o,l){super(),this._changeDetectorRef=o,this.callSetDisabledState=l,this._parent=e,this._setValidators(s),this._setAsyncValidators(i),this.valueAccessor=$e(0,a)}ngOnChanges(e){if(this._checkForErrors(),!this._registered||"name"in e){if(this._registered&&(this._checkName(),this.formDirective)){let s=e.name.previousValue;this.formDirective.removeControl({name:s,path:this._getPath(s)})}this._setUpControl()}"isDisabled"in e&&this._updateDisabled(e),function(e,s){if(!e.hasOwnProperty("model"))return!1;let i=e.model;return!!i.isFirstChange()||!Object.is(s,i.currentValue)}(e,this.viewModel)&&(this._updateValue(this.model),this.viewModel=this.model)}ngOnDestroy(){this.formDirective&&this.formDirective.removeControl(this)}get path(){return this._getPath(this.name)}get formDirective(){return this._parent?this._parent.formDirective:null}viewToModelUpdate(e){this.viewModel=e,this.update.emit(e)}_setUpControl(){this._setUpdateStrategy(),this._isStandalone()?this._setUpStandalone():this.formDirective.addControl(this),this._registered=!0}_setUpdateStrategy(){this.options&&null!=this.options.updateOn&&(this.control._updateOn=this.options.updateOn)}_isStandalone(){return!this._parent||!(!this.options||!this.options.standalone)}_setUpStandalone(){Re(this.control,this,this.callSetDisabledState),this.control.updateValueAndValidity({emitEvent:!1})}_checkForErrors(){this._checkName()}_checkName(){this.options&&this.options.name&&(this.name=this.options.name),!this._isStandalone()&&this.name}_updateValue(e){lt.then(()=>{this.control.setValue(e,{emitViewToModelChange:!1}),this._changeDetectorRef?.markForCheck()})}_updateDisabled(e){let s=e.isDisabled.currentValue,i=0!==s&&D(s);lt.then(()=>{i&&!this.control.disabled?this.control.disable():!i&&this.control.disabled&&this.control.enable(),this._changeDetectorRef?.markForCheck()})}_getPath(e){return this._parent?function(e,s){return[...s.path,e]}(e,this._parent):[e]}static ɵfac=function(e){return new(e||n)(o(L,9),o(j,10),o(H,10),o(F,10),o(w,8),o(it,8))};static ɵdir=h({type:n,selectors:[["","ngModel","",3,"formControlName","",3,"formControl",""]],inputs:{name:"name",isDisabled:[0,"disabled","isDisabled"],model:[0,"ngModel","model"],options:[0,"ngModelOptions","options"]},outputs:{update:"ngModelChange"},exportAs:["ngModel"],standalone:!1,features:[C([ot]),u,k]})}return n})(),ut=(()=>{class n{static ɵfac=function(e){return new(e||n)};static ɵmod=l({type:n});static ɵinj=A({})}return n})(),dt=(()=>{class n{static withConfig(e){return{ngModule:n,providers:[{provide:it,useValue:e.callSetDisabledState??rt}]}}static ɵfac=function(e){return new(e||n)};static ɵmod=l({type:n});static ɵinj=A({imports:[ut]})}return n})();export{N as a,K as b,ht as c,dt as d};
|
|
1
|
+
import{B as e,D as s,E as i,H as a,I as o,K as l,L as h,M as u,O as d,U as c,a as _,b as p,ca as g,d as y,e as m,f as v,g as V,n as f,oa as C,p as A,q as b,qa as w,ra as D,sa as S,ta as O,u as k,va as P,z as x}from"./chunk-VAB2VXFI.js";var T=(()=>{class n{_renderer;_elementRef;onChange=e=>{};onTouched=()=>{};constructor(e,s){this._renderer=e,this._elementRef=s}setProperty(e,s){this._renderer.setProperty(this._elementRef.nativeElement,e,s)}registerOnTouched(e){this.onTouched=e}registerOnChange(e){this.onChange=e}setDisabledState(e){this.setProperty("disabled",e)}static ɵfac=function(e){return new(e||n)(o(a),o(s))};static ɵdir=h({type:n})}return n})(),M=(()=>{class n extends T{static ɵfac=(()=>{let e;return function(s){return(e||(e=x(n)))(s||n)}})();static ɵdir=h({type:n,features:[u]})}return n})(),F=new b(""),R={provide:F,useExisting:f(()=>N),multi:!0},U=new b(""),N=(()=>{class n extends T{_compositionMode;_composing=!1;constructor(e,s,i){super(e,s),this._compositionMode=i,null==this._compositionMode&&(this._compositionMode=!function(){let e=P()?P().getUserAgent():"";return/android (\d+)/.test(e.toLowerCase())}())}writeValue(e){let s=e??"";this.setProperty("value",s)}_handleInput(e){(!this._compositionMode||this._compositionMode&&!this._composing)&&this.onChange(e)}_compositionStart(){this._composing=!0}_compositionEnd(e){this._composing=!1,this._compositionMode&&this.onChange(e)}static ɵfac=function(e){return new(e||n)(o(a),o(s),o(U,8))};static ɵdir=h({type:n,selectors:[["input","formControlName","",3,"type","checkbox"],["textarea","formControlName",""],["input","formControl","",3,"type","checkbox"],["textarea","formControl",""],["input","ngModel","",3,"type","checkbox"],["textarea","ngModel",""],["","ngDefaultControl",""]],hostBindings:function(e,s){1&e&&g("input",function(e){return s._handleInput(e.target.value)})("blur",function(){return s.onTouched()})("compositionstart",function(){return s._compositionStart()})("compositionend",function(e){return s._compositionEnd(e.target.value)})},standalone:!1,features:[C([R]),u]})}return n})(),j=new b(""),H=new b("");function ue(e){return null!=e}function de(e){return d(e)?m(e):e}function ce(e){let s={};return e.forEach(e=>{s=null!=e?_(_({},s),e):s}),0===Object.keys(s).length?null:s}function he(e,s){return s.map(s=>s(e))}function fe(e){return e.map(e=>function(e){return!e.validate}(e)?e:s=>e.validate(s))}function ge(e){return null!=e?function(e){if(!e)return null;let s=e.filter(ue);return 0==s.length?null:function(e){return ce(he(e,s))}}(fe(e)):null}function pe(e){return null!=e?function(e){if(!e)return null;let s=e.filter(ue);return 0==s.length?null:function(e){let i=he(e,s).map(de);return V(i).pipe(v(ce))}}(fe(e)):null}function Q(e,s){return null===e?[s]:Array.isArray(e)?[...e,s]:[e,s]}function G(e){return e?Array.isArray(e)?e:[e]:[]}function E(e,s){return Array.isArray(e)?e.includes(s):e===s}function ee(e,s){let i=G(s);return G(e).forEach(e=>{E(i,e)||i.push(e)}),i}function te(e,s){return G(s).filter(s=>!E(e,s))}var B=class{get value(){return this.control?this.control.value:null}get valid(){return this.control?this.control.valid:null}get invalid(){return this.control?this.control.invalid:null}get pending(){return this.control?this.control.pending:null}get disabled(){return this.control?this.control.disabled:null}get enabled(){return this.control?this.control.enabled:null}get errors(){return this.control?this.control.errors:null}get pristine(){return this.control?this.control.pristine:null}get dirty(){return this.control?this.control.dirty:null}get touched(){return this.control?this.control.touched:null}get status(){return this.control?this.control.status:null}get untouched(){return this.control?this.control.untouched:null}get statusChanges(){return this.control?this.control.statusChanges:null}get valueChanges(){return this.control?this.control.valueChanges:null}get path(){return null}_composedValidatorFn;_composedAsyncValidatorFn;_rawValidators=[];_rawAsyncValidators=[];_setValidators(e){this._rawValidators=e||[],this._composedValidatorFn=ge(this._rawValidators)}_setAsyncValidators(e){this._rawAsyncValidators=e||[],this._composedAsyncValidatorFn=pe(this._rawAsyncValidators)}get validator(){return this._composedValidatorFn||null}get asyncValidator(){return this._composedAsyncValidatorFn||null}_onDestroyCallbacks=[];_registerOnDestroy(e){this._onDestroyCallbacks.push(e)}_invokeOnDestroyCallbacks(){this._onDestroyCallbacks.forEach(e=>e()),this._onDestroyCallbacks=[]}reset(e=void 0){this.control&&this.control.reset(e)}hasError(e,s){return!!this.control&&this.control.hasError(e,s)}getError(e,s){return this.control?this.control.getError(e,s):null}},L=class extends B{name;get formDirective(){return null}get path(){return null}},q=class extends B{_parent=null;name=null;valueAccessor=null},z=class{_cd;constructor(e){this._cd=e}get isTouched(){return this._cd?.control?._touched?.(),!!this._cd?.control?.touched}get isUntouched(){return!!this._cd?.control?.untouched}get isPristine(){return this._cd?.control?._pristine?.(),!!this._cd?.control?.pristine}get isDirty(){return!!this._cd?.control?.dirty}get isValid(){return this._cd?.control?._status?.(),!!this._cd?.control?.valid}get isInvalid(){return!!this._cd?.control?.invalid}get isPending(){return!!this._cd?.control?.pending}get isSubmitted(){return this._cd?._submitted?.(),!!this._cd?.submitted}},K=(p(_({},{"[class.ng-untouched]":"isUntouched","[class.ng-touched]":"isTouched","[class.ng-pristine]":"isPristine","[class.ng-dirty]":"isDirty","[class.ng-valid]":"isValid","[class.ng-invalid]":"isInvalid","[class.ng-pending]":"isPending"}),{"[class.ng-submitted]":"isSubmitted"}),(()=>{class n extends z{constructor(e){super(e)}static ɵfac=function(e){return new(e||n)(o(q,2))};static ɵdir=h({type:n,selectors:[["","formControlName",""],["","ngModel",""],["","formControl",""]],hostVars:14,hostBindings:function(e,s){2&e&&c("ng-untouched",s.isUntouched)("ng-touched",s.isTouched)("ng-pristine",s.isPristine)("ng-dirty",s.isDirty)("ng-valid",s.isValid)("ng-invalid",s.isInvalid)("ng-pending",s.isPending)},standalone:!1,features:[u]})}return n})()),X="VALID",J="INVALID",W="PENDING",Y="DISABLED",Z=class{},$=class extends Z{value;source;constructor(e,s){super(),this.value=e,this.source=s}},tt=class extends Z{pristine;source;constructor(e,s){super(),this.pristine=e,this.source=s}},et=class extends Z{touched;source;constructor(e,s){super(),this.touched=e,this.source=s}},st=class extends Z{status;source;constructor(e,s){super(),this.status=e,this.source=s}};function I(e){return null!=e&&!Array.isArray(e)&&"object"==typeof e}var nt=class{_pendingDirty=!1;_hasOwnPendingAsyncValidator=null;_pendingTouched=!1;_onCollectionChange=()=>{};_updateOn;_parent=null;_asyncValidationSubscription;_composedValidatorFn;_composedAsyncValidatorFn;_rawValidators;_rawAsyncValidators;value;constructor(e,s){this._assignValidators(e),this._assignAsyncValidators(s)}get validator(){return this._composedValidatorFn}set validator(e){this._rawValidators=this._composedValidatorFn=e}get asyncValidator(){return this._composedAsyncValidatorFn}set asyncValidator(e){this._rawAsyncValidators=this._composedAsyncValidatorFn=e}get parent(){return this._parent}get status(){return S(this.statusReactive)}set status(e){S(()=>this.statusReactive.set(e))}_status=O(()=>this.statusReactive());statusReactive=i(void 0);get valid(){return this.status===X}get invalid(){return this.status===J}get pending(){return this.status==W}get disabled(){return this.status===Y}get enabled(){return this.status!==Y}errors;get pristine(){return S(this.pristineReactive)}set pristine(e){S(()=>this.pristineReactive.set(e))}_pristine=O(()=>this.pristineReactive());pristineReactive=i(!0);get dirty(){return!this.pristine}get touched(){return S(this.touchedReactive)}set touched(e){S(()=>this.touchedReactive.set(e))}_touched=O(()=>this.touchedReactive());touchedReactive=i(!1);get untouched(){return!this.touched}_events=new y;events=this._events.asObservable();valueChanges;statusChanges;get updateOn(){return this._updateOn?this._updateOn:this.parent?this.parent.updateOn:"change"}setValidators(e){this._assignValidators(e)}setAsyncValidators(e){this._assignAsyncValidators(e)}addValidators(e){this.setValidators(ee(e,this._rawValidators))}addAsyncValidators(e){this.setAsyncValidators(ee(e,this._rawAsyncValidators))}removeValidators(e){this.setValidators(te(e,this._rawValidators))}removeAsyncValidators(e){this.setAsyncValidators(te(e,this._rawAsyncValidators))}hasValidator(e){return E(this._rawValidators,e)}hasAsyncValidator(e){return E(this._rawAsyncValidators,e)}clearValidators(){this.validator=null}clearAsyncValidators(){this.asyncValidator=null}markAsTouched(e={}){let s=!1===this.touched;this.touched=!0;let i=e.sourceControl??this;this._parent&&!e.onlySelf&&this._parent.markAsTouched(p(_({},e),{sourceControl:i})),s&&!1!==e.emitEvent&&this._events.next(new et(!0,i))}markAllAsTouched(e={}){this.markAsTouched({onlySelf:!0,emitEvent:e.emitEvent,sourceControl:this}),this._forEachChild(s=>s.markAllAsTouched(e))}markAsUntouched(e={}){let s=!0===this.touched;this.touched=!1,this._pendingTouched=!1;let i=e.sourceControl??this;this._forEachChild(s=>{s.markAsUntouched({onlySelf:!0,emitEvent:e.emitEvent,sourceControl:i})}),this._parent&&!e.onlySelf&&this._parent._updateTouched(e,i),s&&!1!==e.emitEvent&&this._events.next(new et(!1,i))}markAsDirty(e={}){let s=!0===this.pristine;this.pristine=!1;let i=e.sourceControl??this;this._parent&&!e.onlySelf&&this._parent.markAsDirty(p(_({},e),{sourceControl:i})),s&&!1!==e.emitEvent&&this._events.next(new tt(!1,i))}markAsPristine(e={}){let s=!1===this.pristine;this.pristine=!0,this._pendingDirty=!1;let i=e.sourceControl??this;this._forEachChild(s=>{s.markAsPristine({onlySelf:!0,emitEvent:e.emitEvent})}),this._parent&&!e.onlySelf&&this._parent._updatePristine(e,i),s&&!1!==e.emitEvent&&this._events.next(new tt(!0,i))}markAsPending(e={}){this.status=W;let s=e.sourceControl??this;!1!==e.emitEvent&&(this._events.next(new st(this.status,s)),this.statusChanges.emit(this.status)),this._parent&&!e.onlySelf&&this._parent.markAsPending(p(_({},e),{sourceControl:s}))}disable(e={}){let s=this._parentMarkedDirty(e.onlySelf);this.status=Y,this.errors=null,this._forEachChild(s=>{s.disable(p(_({},e),{onlySelf:!0}))}),this._updateValue();let i=e.sourceControl??this;!1!==e.emitEvent&&(this._events.next(new $(this.value,i)),this._events.next(new st(this.status,i)),this.valueChanges.emit(this.value),this.statusChanges.emit(this.status)),this._updateAncestors(p(_({},e),{skipPristineCheck:s}),this),this._onDisabledChange.forEach(e=>e(!0))}enable(e={}){let s=this._parentMarkedDirty(e.onlySelf);this.status=X,this._forEachChild(s=>{s.enable(p(_({},e),{onlySelf:!0}))}),this.updateValueAndValidity({onlySelf:!0,emitEvent:e.emitEvent}),this._updateAncestors(p(_({},e),{skipPristineCheck:s}),this),this._onDisabledChange.forEach(e=>e(!1))}_updateAncestors(e,s){this._parent&&!e.onlySelf&&(this._parent.updateValueAndValidity(e),e.skipPristineCheck||this._parent._updatePristine({},s),this._parent._updateTouched({},s))}setParent(e){this._parent=e}getRawValue(){return this.value}updateValueAndValidity(e={}){if(this._setInitialStatus(),this._updateValue(),this.enabled){let s=this._cancelExistingSubscription();this.errors=this._runValidator(),this.status=this._calculateStatus(),(this.status===X||this.status===W)&&this._runAsyncValidator(s,e.emitEvent)}let s=e.sourceControl??this;!1!==e.emitEvent&&(this._events.next(new $(this.value,s)),this._events.next(new st(this.status,s)),this.valueChanges.emit(this.value),this.statusChanges.emit(this.status)),this._parent&&!e.onlySelf&&this._parent.updateValueAndValidity(p(_({},e),{sourceControl:s}))}_updateTreeValidity(e={emitEvent:!0}){this._forEachChild(s=>s._updateTreeValidity(e)),this.updateValueAndValidity({onlySelf:!0,emitEvent:e.emitEvent})}_setInitialStatus(){this.status=this._allControlsDisabled()?Y:X}_runValidator(){return this.validator?this.validator(this):null}_runAsyncValidator(e,s){if(this.asyncValidator){this.status=W,this._hasOwnPendingAsyncValidator={emitEvent:!1!==s};let i=de(this.asyncValidator(this));this._asyncValidationSubscription=i.subscribe(i=>{this._hasOwnPendingAsyncValidator=null,this.setErrors(i,{emitEvent:s,shouldHaveEmitted:e})})}}_cancelExistingSubscription(){if(this._asyncValidationSubscription){this._asyncValidationSubscription.unsubscribe();let e=this._hasOwnPendingAsyncValidator?.emitEvent??!1;return this._hasOwnPendingAsyncValidator=null,e}return!1}setErrors(e,s={}){this.errors=e,this._updateControlsErrors(!1!==s.emitEvent,this,s.shouldHaveEmitted)}get(e){let s=e;return null==s||(Array.isArray(s)||(s=s.split(".")),0===s.length)?null:s.reduce((e,s)=>e&&e._find(s),this)}getError(e,s){let i=s?this.get(s):this;return i&&i.errors?i.errors[e]:null}hasError(e,s){return!!this.getError(e,s)}get root(){let e=this;for(;e._parent;)e=e._parent;return e}_updateControlsErrors(e,s,i){this.status=this._calculateStatus(),e&&this.statusChanges.emit(this.status),(e||i)&&this._events.next(new st(this.status,s)),this._parent&&this._parent._updateControlsErrors(e,s,i)}_initObservables(){this.valueChanges=new e,this.statusChanges=new e}_calculateStatus(){return this._allControlsDisabled()?Y:this.errors?J:this._hasOwnPendingAsyncValidator||this._anyControlsHaveStatus(W)?W:this._anyControlsHaveStatus(J)?J:X}_anyControlsHaveStatus(e){return this._anyControls(s=>s.status===e)}_anyControlsDirty(){return this._anyControls(e=>e.dirty)}_anyControlsTouched(){return this._anyControls(e=>e.touched)}_updatePristine(e,s){let i=!this._anyControlsDirty(),a=this.pristine!==i;this.pristine=i,this._parent&&!e.onlySelf&&this._parent._updatePristine(e,s),a&&this._events.next(new tt(this.pristine,s))}_updateTouched(e={},s){this.touched=this._anyControlsTouched(),this._events.next(new et(this.touched,s)),this._parent&&!e.onlySelf&&this._parent._updateTouched(e,s)}_onDisabledChange=[];_registerOnCollectionChange(e){this._onCollectionChange=e}_setUpdateStrategy(e){I(e)&&null!=e.updateOn&&(this._updateOn=e.updateOn)}_parentMarkedDirty(e){let s=this._parent&&this._parent.dirty;return!e&&!!s&&!this._parent._anyControlsDirty()}_find(e){return null}_assignValidators(e){var s;this._rawValidators=Array.isArray(e)?e.slice():e,this._composedValidatorFn=(s=this._rawValidators,Array.isArray(s)?ge(s):s||null)}_assignAsyncValidators(e){var s;this._rawAsyncValidators=Array.isArray(e)?e.slice():e,this._composedAsyncValidatorFn=(s=this._rawAsyncValidators,Array.isArray(s)?pe(s):s||null)}},it=new b("",{providedIn:"root",factory:()=>rt}),rt="always";function ne(e,s){e.forEach(e=>{e.registerOnValidatorChange&&e.registerOnValidatorChange(s)})}function _e(e,s){e._pendingDirty&&e.markAsDirty(),e.setValue(e._pendingValue,{emitModelToViewChange:!1}),s.viewToModelUpdate(e._pendingValue),e._pendingChange=!1}function ie(e,s){let i=e.indexOf(s);i>-1&&e.splice(i,1)}function re(e){return"object"==typeof e&&null!==e&&2===Object.keys(e).length&&"value"in e&&"disabled"in e}var at=class extends nt{defaultValue=null;_onChange=[];_pendingValue;_pendingChange=!1;constructor(e=null,s,i){var a;super((I(a=s)?a.validators:a)||null,function(e,s){return(I(s)?s.asyncValidators:e)||null}(i,s)),this._applyFormState(e),this._setUpdateStrategy(s),this._initObservables(),this.updateValueAndValidity({onlySelf:!0,emitEvent:!!this.asyncValidator}),I(s)&&(s.nonNullable||s.initialValueIsDefault)&&(re(e)?this.defaultValue=e.value:this.defaultValue=e)}setValue(e,s={}){this.value=this._pendingValue=e,this._onChange.length&&!1!==s.emitModelToViewChange&&this._onChange.forEach(e=>e(this.value,!1!==s.emitViewToModelChange)),this.updateValueAndValidity(s)}patchValue(e,s={}){this.setValue(e,s)}reset(e=this.defaultValue,s={}){this._applyFormState(e),this.markAsPristine(s),this.markAsUntouched(s),this.setValue(this.value,s),this._pendingChange=!1}_updateValue(){}_anyControls(e){return!1}_allControlsDisabled(){return this.disabled}registerOnChange(e){this._onChange.push(e)}_unregisterOnChange(e){ie(this._onChange,e)}registerOnDisabledChange(e){this._onDisabledChange.push(e)}_unregisterOnDisabledChange(e){ie(this._onDisabledChange,e)}_forEachChild(e){}_syncPendingControls(){return!("submit"!==this.updateOn||(this._pendingDirty&&this.markAsDirty(),this._pendingTouched&&this.markAsTouched(),!this._pendingChange)||(this.setValue(this._pendingValue,{onlySelf:!0,emitModelToViewChange:!1}),0))}_applyFormState(e){re(e)?(this.value=this._pendingValue=e.value,e.disabled?this.disable({onlySelf:!0,emitEvent:!1}):this.enable({onlySelf:!0,emitEvent:!1})):this.value=this._pendingValue=e}},ot={provide:q,useExisting:f(()=>ht)},lt=Promise.resolve(),ht=(()=>{class n extends q{_changeDetectorRef;callSetDisabledState;control=new at;static ngAcceptInputType_isDisabled;_registered=!1;viewModel;name="";isDisabled;model;options;update=new e;constructor(e,s,i,a,o,l){super(),this._changeDetectorRef=o,this.callSetDisabledState=l,this._parent=e,this._setValidators(s),this._setAsyncValidators(i),this.valueAccessor=function(e,s){if(!s)return null;let i,a,o;return Array.isArray(s),s.forEach(e=>{e.constructor===N?i=e:function(e){return Object.getPrototypeOf(e.constructor)===M}(e)?a=e:o=e}),o||a||i||null}(0,a)}ngOnChanges(e){if(this._checkForErrors(),!this._registered||"name"in e){if(this._registered&&(this._checkName(),this.formDirective)){let s=e.name.previousValue;this.formDirective.removeControl({name:s,path:this._getPath(s)})}this._setUpControl()}"isDisabled"in e&&this._updateDisabled(e),function(e,s){if(!e.hasOwnProperty("model"))return!1;let i=e.model;return!!i.isFirstChange()||!Object.is(s,i.currentValue)}(e,this.viewModel)&&(this._updateValue(this.model),this.viewModel=this.model)}ngOnDestroy(){this.formDirective&&this.formDirective.removeControl(this)}get path(){return this._getPath(this.name)}get formDirective(){return this._parent?this._parent.formDirective:null}viewToModelUpdate(e){this.viewModel=e,this.update.emit(e)}_setUpControl(){this._setUpdateStrategy(),this._isStandalone()?this._setUpStandalone():this.formDirective.addControl(this),this._registered=!0}_setUpdateStrategy(){this.options&&null!=this.options.updateOn&&(this.control._updateOn=this.options.updateOn)}_isStandalone(){return!this._parent||!(!this.options||!this.options.standalone)}_setUpStandalone(){(function(e,s,i=rt){(function(e,s){let i=function(e){return e._rawValidators}(e);null!==s.validator?e.setValidators(Q(i,s.validator)):"function"==typeof i&&e.setValidators([i]);let a=function(e){return e._rawAsyncValidators}(e);null!==s.asyncValidator?e.setAsyncValidators(Q(a,s.asyncValidator)):"function"==typeof a&&e.setAsyncValidators([a]);let r=()=>e.updateValueAndValidity();ne(s._rawValidators,r),ne(s._rawAsyncValidators,r)})(e,s),s.valueAccessor.writeValue(e.value),(e.disabled||"always"===i)&&s.valueAccessor.setDisabledState?.(e.disabled),function(e,s){s.valueAccessor.registerOnChange(i=>{e._pendingValue=i,e._pendingChange=!0,e._pendingDirty=!0,"change"===e.updateOn&&_e(e,s)})}(e,s),function(e,s){let t=(e,i)=>{s.valueAccessor.writeValue(e),i&&s.viewToModelUpdate(e)};e.registerOnChange(t),s._registerOnDestroy(()=>{e._unregisterOnChange(t)})}(e,s),function(e,s){s.valueAccessor.registerOnTouched(()=>{e._pendingTouched=!0,"blur"===e.updateOn&&e._pendingChange&&_e(e,s),"submit"!==e.updateOn&&e.markAsTouched()})}(e,s),function(e,s){if(s.valueAccessor.setDisabledState){let t=e=>{s.valueAccessor.setDisabledState(e)};e.registerOnDisabledChange(t),s._registerOnDestroy(()=>{e._unregisterOnDisabledChange(t)})}}(e,s)})(this.control,this,this.callSetDisabledState),this.control.updateValueAndValidity({emitEvent:!1})}_checkForErrors(){this._checkName()}_checkName(){this.options&&this.options.name&&(this.name=this.options.name),!this._isStandalone()&&this.name}_updateValue(e){lt.then(()=>{this.control.setValue(e,{emitViewToModelChange:!1}),this._changeDetectorRef?.markForCheck()})}_updateDisabled(e){let s=e.isDisabled.currentValue,i=0!==s&&D(s);lt.then(()=>{i&&!this.control.disabled?this.control.disable():!i&&this.control.disabled&&this.control.enable(),this._changeDetectorRef?.markForCheck()})}_getPath(e){return this._parent?function(e,s){return[...s.path,e]}(e,this._parent):[e]}static ɵfac=function(e){return new(e||n)(o(L,9),o(j,10),o(H,10),o(F,10),o(w,8),o(it,8))};static ɵdir=h({type:n,selectors:[["","ngModel","",3,"formControlName","",3,"formControl",""]],inputs:{name:"name",isDisabled:[0,"disabled","isDisabled"],model:[0,"ngModel","model"],options:[0,"ngModelOptions","options"]},outputs:{update:"ngModelChange"},exportAs:["ngModel"],standalone:!1,features:[C([ot]),u,k]})}return n})(),ut=(()=>{class n{static ɵfac=function(e){return new(e||n)};static ɵmod=l({type:n});static ɵinj=A({})}return n})(),dt=(()=>{class n{static withConfig(e){return{ngModule:n,providers:[{provide:it,useValue:e.callSetDisabledState??rt}]}}static ɵfac=function(e){return new(e||n)};static ɵmod=l({type:n});static ɵinj=A({imports:[ut]})}return n})();export{N as a,K as b,ht as c,dt as d};
|