pivotkit-element 0.5.0 → 0.6.0

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +34 -2
  2. package/README.md +1 -0
  3. package/dist/chunks/{chunk-SB3L4HHW.js → chunk-7V4PAOK7.js} +1 -1
  4. package/dist/chunks/chunk-CHSIHYYE.js +2 -0
  5. package/dist/chunks/chunk-CXSW4YRL.js +13 -0
  6. package/dist/chunks/chunk-HFUBAP3D.js +1 -0
  7. package/dist/chunks/chunk-KO3EKDH5.js +1 -0
  8. package/dist/chunks/chunk-NXZQI5LC.js +6 -0
  9. package/dist/chunks/{chunk-XETFD6GR.js → chunk-OHKPNELV.js} +1 -1
  10. package/dist/chunks/chunk-R6GXMVRO.js +1 -0
  11. package/dist/chunks/chunk-YMLEL3SK.js +8 -0
  12. package/dist/chunks/export-O6XO33DV.js +1 -0
  13. package/dist/chunks/import-ui-SZTWEYHK.js +1 -0
  14. package/dist/chunks/{link-45LOEA7H.js → link-7K6I4SJS.js} +1 -1
  15. package/dist/chunks/menu-texts-de-CRJ5OIVT.js +1 -0
  16. package/dist/chunks/menus-F36OYGXV.js +2 -0
  17. package/dist/chunks/{report-run-BZBFOMPF-4M6ACMUF.js → report-run-BZBFOMPF-T26ENZEM.js} +7 -7
  18. package/dist/element.js +1 -1
  19. package/dist/import-worker.js +1 -1
  20. package/dist/index.js +1 -1
  21. package/package.json +4 -4
  22. package/types/element.d.ts +23 -2
  23. package/types/jsx.d.ts +1 -1
  24. package/dist/chunks/chunk-4PHDW2LB.js +0 -1
  25. package/dist/chunks/chunk-65O4Z5GI.js +0 -1
  26. package/dist/chunks/chunk-CCL5TDLA.js +0 -6
  27. package/dist/chunks/chunk-PJA6QZ4Y.js +0 -2
  28. package/dist/chunks/chunk-QOKB5RDG.js +0 -6
  29. package/dist/chunks/chunk-YUY4D5MF.js +0 -8
  30. package/dist/chunks/export-YHS47KGK.js +0 -1
  31. package/dist/chunks/import-ui-7XVUBL2H.js +0 -1
  32. package/dist/chunks/menu-texts-de-74DWTJDI.js +0 -1
  33. package/dist/chunks/menus-XBN5D32E.js +0 -2
@@ -1 +0,0 @@
1
- import{a as se,c as ne,g as Q,h as Pe,i as ze,j as Me}from"./chunk-XETFD6GR.js";import{$ as Re,A as we,B as Ae,D as $e,E as Oe,F as X,G as Ee,J as Le,N as W,R as Te,S as q,V as Ie,W as K,X as Ce,Y as ve,Z as _e,_ as ke,a as ie,aa as Ne,ba as Fe,da as z,e as H,ea as Z,f as ae,g as le,i as ce,j as P,l as Y,m as fe,p as me,q as pe,s as ue,t as de,u as he,v as ge,w as be,x as ye,y as Se,z as xe}from"./chunk-4PHDW2LB.js";import{b as E,c as re,i as V,m as v,w as U}from"./chunk-XR4CMFGN.js";import{a as L,b as ee}from"./chunk-5QXN3X2Q.js";function Ze(e,t,o){o=v(o,"fieldItems"),E(ne(e),"fieldItems(data, field): data must come from encode()");let r=V(o),{view:n}=z(o.view??{},e,{limits:o.limits}),s=U(n.formatting.locale,o.locale),i={...P,...o.labels||{}};if(typeof t!="string")return null;let a=n.derived.find(h=>h.name.toLowerCase()===t.trim().toLowerCase()),c=a?ce(e,a):e.column(t.trim());if(!c)return null;let d=new Float64Array(c.dict.length+1);for(let h=0;h<c.codes.length;h++)d[c.codes[h]+1]++;let p=fe(c,s,e.cache),m=Ee(n,c.name,c,a?e.column(a.field)??c:c,s,()=>$e(o.now,e.timeZone)),l=h=>!m||m[h+1]===1,f=[];for(let h=0;h<c.dict.length;h++)d[h+1]>0&&f.push(h);f.sort((h,u)=>p[h]-p[u]);let y=f.map(h=>({value:c.dict[h],label:Y(c,c.dict[h],s,i),count:d[h+1],kept:l(h)}));return d[0]>0&&y.push({value:null,label:Y(c,null,s,i),count:d[0],kept:l(-1)}),{field:c.name,type:c.type,items:y.slice(0,r.items),truncated:y.length>r.items}}function De(e,t){t=v(t,"toSeries"),E(Q(e),"toSeries(result): result must come from computePivot()");let o=V(t),r=e.view,n={...P,...t.labels||{}},s=t.separator??" / ",i=(u,g,S)=>Pe(u,g,S,!1,!1).filter(b=>b.kind!=="grand"),a=i(e.rowRoot,r.rows.length,r.collapsed.rows),c=i(e.colRoot,r.cols.length,r.collapsed.cols);a.length===0&&(a=[{node:e.rowRoot,kind:"leaf"}]);let d=a.length;t.maxCategories!==void 0&&(E(Number.isInteger(t.maxCategories)&&t.maxCategories>0,"toSeries: maxCategories must be a positive whole number"),a=a.slice(0,t.maxCategories)),c.length===0&&(c=[{node:e.colRoot,kind:"leaf"}]);let p=(u,g)=>{let S=[];for(let b=g;b&&b.parent;b=b.parent)S.unshift(e.label(u,b,n));return S},m=(u,g)=>{let S=p(u,g);return S.length?S.join(s):n.grandTotal},l=r.values.filter((u,g)=>e.valueTypes[g]!=="text").length;re("cells",a.length*Math.max(1,c.length*l),o.cells,"chart data points");let f=r.values.map(u=>Me(u,n)),y=u=>typeof u=="number"&&Number.isFinite(u)?u:null,h=[];for(let{node:u}of c)r.values.forEach((g,S)=>{if(e.valueTypes[S]==="text")return;let b=u.parent?m("cols",u):"",F=b&&r.values.length>1?`${b}${s}${f[S]}`:b||f[S];h.push({name:F,valueIndex:S,colPath:u.path,format:ze(e,S),data:a.map(({node:T})=>y(e.display(T,u,S)))})});return{categories:a.map(({node:u})=>m("rows",u)),categoryLevels:a.map(({node:u})=>p("rows",u)),categoryCount:d,categoryPaths:a.map(({node:u})=>u.path),series:h,totals:r.values.map((u,g)=>a.map(({node:S})=>y(e.display(S,e.colRoot,g))))}}var Qe=e=>e+16,et=e=>({top:Math.max(24,e+10),bottom:Math.max(32,e+18),right:160});function tt(e,t,o,r){let n=et(r.fontSize),s=e==="bottom"||e==="right"||e==="off"?e:t?"top":"off";return s==="off"?{legend:null,room:{top:0,bottom:0,right:0}}:s==="right"?{legend:{type:"scroll",orient:"vertical",right:0,top:o+8,bottom:8,textStyle:r},room:{top:0,bottom:0,right:n.right}}:s==="bottom"?{legend:{type:"scroll",bottom:0,textStyle:r},room:{top:0,bottom:n.bottom,right:0}}:{legend:{type:"scroll",top:o,textStyle:r},room:{top:n.top,bottom:0,right:0}}}var je=e=>e+12;function ot(e,t,o,{separator:r,axisLine:n,theme:s}){let i=e.categoryLevels??[];if(o.groupLabels==="off"||t<2||!i.some(f=>f.length>=2))return null;let a=i.map(f=>f[0]??""),c=i.map((f,y)=>f.length>1?f.slice(1).join(r):e.categories[y]),d=a.map((f,y)=>y===0||f!==a[y-1]),p=new Set,m=0,l=a.length;for(let f=1;f<=a.length;f++)(f===a.length||d[f])&&(p.add(Math.floor((m+f-1)/2)),l=Math.min(l,f-m),m=f);return{leaves:c,axis:{type:"category",data:a,position:o.horizontal?"left":"bottom",offset:je(s.textSize??L.textSize),axisLine:{show:!1},axisTick:{show:!0,inside:!0,length:je(s.textSize??L.textSize),interval:f=>f>0&&d[f]===!0,lineStyle:n.lineStyle},axisLabel:{color:s.textColor,fontSize:s.textSize??L.textSize,fontWeight:s.strongWeight??L.strongWeight,interval:f=>p.has(f)},axisPointer:{show:!1},splitLine:{show:!1},groups:!0,groupsAuto:o.groupLabels!=="on",groupSize:l}}}function M(e,t){let o=Array.isArray(e.derived)?e.derived:[],r=n=>{let s=String(n).toLowerCase(),i=o.find(a=>a&&typeof a.name=="string"&&a.name.toLowerCase()===s);return i&&!H.includes(i.by)?!1:t.column(i?i.field:n)?.type==="date"};return(Array.isArray(e.rows)?e.rows:[]).some(r)?"line":"bar"}function rt(e,t){t=v(t,"toEChartsOption"),E(Q(e),"toEChartsOption(result): result must come from computePivot()");let o=t.theme??{},r={...e.view.chart,...t.chart||{}};r.type==="auto"&&(r.type=M(e.view,e.encoded));let n=U(e.view.formatting.locale,t.locale??e.locale),s=t.series??De(e,t);E(s&&Array.isArray(s.series)&&Array.isArray(s.categories),"toEChartsOption: series must come from toSeries()");let i=s.series[0],a=W(i?i.format:"number",n),c=W(i&&/^percent/.test(i.format)?i.format:"compact",n),d={color:o.textColor,fontFamily:o.fontFamily,fontSize:o.textSize??L.textSize},p={color:d.color,fontSize:d.fontSize},m={lineStyle:{color:o.axisColor}},l={backgroundColor:o.backgroundColor??"transparent",textStyle:d,...o.colors&&o.colors.length?{color:o.colors}:{}},f=w=>typeof w=="number"?a(w):"",y=typeof r.title=="string"&&r.title.trim()?{title:{text:r.title.trim(),left:"center",top:0,textStyle:{...d,fontSize:o.titleSize??L.titleSize,fontWeight:o.strongWeight??L.strongWeight}}}:{},h=y.title?Qe(o.titleSize??L.titleSize):0,{legend:u,room:g}=tt(r.legend,K.includes(r.type)||s.series.length>1,h,d),S=u?{legend:u}:{},b=r.valueLabels==="off"||r.valueLabels==="value"||r.valueLabels==="percent"||r.valueLabels==="both"?r.valueLabels:"auto";if(K.includes(r.type)){let w=i?i.valueIndex:0,I=s.categories.map((A,Ke)=>({name:A,value:s.totals[w]?s.totals[w][Ke]:null})).filter(A=>typeof A.value=="number"&&A.value>0),_=A=>W("percent100:1",n)(A.percent),C=r.labelPosition==="inside",$={value:A=>a(A.value),percent:_,both:A=>`${a(A.value)} (${_(A)})`},J=b==="off"?{show:!1}:C?{position:"inside",formatter:$[b==="auto"?"percent":b]}:b==="auto"?{}:{formatter:A=>`${A.name}: ${$[b](A)}`},k=r.type==="donut"?o.donutRadius??L.donutRadius:o.pieRadius??L.pieRadius;return{...l,...y,tooltip:{trigger:"item",valueFormatter:f},...S,series:[{type:"pie",name:i?i.name:"",radius:[...k],top:h+g.top,...g.bottom?{bottom:g.bottom}:{},...g.right?{right:g.right}:{},data:I,...C?{minShowLabelAngle:12,labelLine:{show:!1}}:{},label:{...C?{}:{color:o.textColor},...J}}]}}if(r.type==="heatmap"){let w=s.series.filter($=>$.valueIndex===(i?i.valueIndex:0)),I=[],_=1/0,C=-1/0;return w.forEach(($,J)=>{$.data.forEach((k,A)=>{k!==null&&(I.push([J,A,k]),_=Math.min(_,k),C=Math.max(C,k))})}),{...l,...y,tooltip:{trigger:"item",valueFormatter:f},grid:{top:16+h,bottom:64},xAxis:{type:"category",data:w.map($=>$.name),axisLine:m,axisLabel:{...p,interval:0},splitArea:{show:!1}},yAxis:{type:"category",data:s.categories,axisLine:m,axisLabel:{...p},splitArea:{show:!1}},visualMap:{min:I.length?_:0,max:I.length?C:1,calculable:!0,orient:"horizontal",left:"center",bottom:0,textStyle:d,formatter:$=>typeof $=="number"?a($):String($),...o.heatmapColors?{inRange:{color:o.heatmapColors}}:{}},series:[{type:"heatmap",name:i?i.name:"",data:I,label:{show:b==="auto"?I.length<=200:b!=="off",formatter:$=>a($.value[2])}}]}}let F=r.type==="line"||r.type==="area"?"line":"bar",T=ot(s,e.view.rows.length,r,{separator:t.separator??" / ",axisLine:m,theme:o}),D={type:"category",data:T?T.leaves:s.categories,axisLine:m,axisLabel:{...p}},oe={type:"value",axisLine:m,axisLabel:{...p,formatter:w=>c(w)},splitLine:{lineStyle:{color:o.gridColor}}},Ye=b!=="auto"&&b!=="off",Xe=F==="line"?"top":r.stacked?"inside":r.horizontal?"right":"top",qe=Ye?{label:{show:!0,position:Xe,color:o.textColor,formatter:w=>typeof w.value=="number"?a(w.value):""}}:{};return{...l,...y,...S,tooltip:{trigger:"axis",valueFormatter:f},grid:{top:16+h+g.top,...g.bottom?{bottom:g.bottom+8}:{},...g.right?{right:g.right+8}:{}},xAxis:r.horizontal?oe:T?[D,T.axis]:D,yAxis:r.horizontal?T?[{...D,inverse:!0},{...T.axis,inverse:!0}]:{...D,inverse:!0}:oe,series:s.series.map(w=>({type:F,name:w.name,data:w.data,...r.stacked?{stack:"total"}:{},...r.type==="area"?{areaStyle:{}}:{},...F==="line"?{connectNulls:!1,smooth:!!r.smooth}:{},...qe}))}}function st(e,t){if(e.chart.type!=="auto")return{auto:!1,swap:!1,chart:{type:e.chart.type,stacked:!!e.chart.stacked,horizontal:!!e.chart.horizontal}};let o=M(e,t),r=o==="bar"&&e.cols.length>0&&M({...e,rows:e.cols},t)==="line";return{auto:!0,swap:r,chart:{type:o==="line"||r?"line":"bar",stacked:!1,horizontal:!1}}}var Ve=Object.freeze({percentOfRowTotal:"percentOfColumnTotal",percentOfColumnTotal:"percentOfRowTotal",percentOfParentRow:"percentOfParentColumn",percentOfParentColumn:"percentOfParentRow"});function nt(e){let t=JSON.parse(JSON.stringify(e));[t.rows,t.cols]=[t.cols,t.rows],t.collapsed={rows:t.collapsed.cols,cols:t.collapsed.rows};for(let o of t.values)o.showAs&&o.showAs.axis&&(o.showAs={...o.showAs,axis:o.showAs.axis==="rows"?"cols":"rows"}),o.showAs&&Object.hasOwn(Ve,o.showAs.type)&&(o.showAs={...o.showAs,type:Ve[o.showAs.type]});return t}var Ue=8;function it(e){let t=f=>e.getPropertyValue(f).trim(),o=[];for(let f=1;f<=Ue;f++){let y=t(`--pk-chart-${f}`);y&&o.push(y)}let r={colors:o,textColor:t("--pk-muted")||void 0,axisColor:t("--pk-border")||void 0,gridColor:t("--pk-grid")||t("--pk-border")||void 0,fontFamily:t("font-family")||void 0,backgroundColor:"transparent"},n=Number(t("--pk-weight-strong"));n>=1&&n<=1e3&&(r.strongWeight=n);let s=ee(t("--pk-chart-title-size"));s!==null&&s>=1&&(r.titleSize=s);let i=ee(t("--pk-chart-text-size"));i!==null&&i>=1&&(r.textSize=i);let a=t("--pk-heat-low"),c=t("--pk-heat-high");a&&c&&(r.heatmapColors=[a,c]);let[d,p,m,l]=["--pk-scale-low","--pk-scale-mid","--pk-scale-high","--pk-chart-1"].map(t);return d&&m&&(r.colorScale=p?[d,p,m]:[d,m]),l&&(r.dataBar=l),r}var at=Object.freeze({aggregators:ie,commonAggregators:Object.freeze(["sum","count","average","min","max"]),columnTypes:se,deriveUnits:le,timelineUnits:H,cyclicUnits:ae,filterTypes:X,filterFields:Object.freeze(Object.fromEntries(X.map(e=>[e,Oe[e].fields]))),filterBlanks:Ae,textOps:be,textOn:ye,matchCases:me,matchWhitespace:pe,compareOps:Se,comparePrecisions:xe,topTies:we,relativeUnits:ue,relativeDirections:de,relativeMaxCount:he,relativeAnchors:ge,formats:Le,showAs:q,showAsAlongAxis:Object.freeze(q.filter(e=>Te[e].alongAxis)),chartTypes:Ie,chartValueLabels:_e,chartLegends:Re,chartAxisLabels:Ne,chartGroupLabels:Fe,chartLabelPositions:ke,displayModes:Ce,conditionalTypes:ve});var te=Object.freeze({items:20,text:80});function ct(e,t){if(e==null)return null;if(t==="date"&&typeof e=="number"){let r=new Date(e).toISOString();return r.endsWith("T00:00:00.000Z")?r.slice(0,10):r.slice(0,16)}let o=String(e);return o.length>te.text?`${o.slice(0,te.text-1)}\u2026`:o}var B=e=>e?e.field?`${e.agg} of ${e.field}`:`${e.agg} of rows`:"the first value",ft=e=>{let t=e.slice(0,10).map(o=>typeof o=="string"?JSON.stringify(ct(o,"string")):String(o));return e.length>10?`${t.join(", ")} and ${e.length-10} more`:t.join(", ")},mt=Object.freeze({exclude:"blanks dropped",include:"blanks kept",only:"only blanks"}),He=Object.freeze({"=":"is",">":"is greater than",">=":"is at least","<":"is less than","<=":"is at most",between:"is between"});function pt(e){let t=e.not?"not ":"",o=e.blanks?` (${mt[e.blanks]})`:"",r=(n,s)=>`${JSON.stringify(n)} and ${JSON.stringify(s)}`;switch(e.type){case"in":return`${e.field} is ${t}one of ${ft(e.items??[])||"(no items)"}${o}`;case"blank":return`${e.field} is ${t}blank`;case"text":return`${e.field}${e.on==="label"?" (as shown)":""} ${t?"does not ":""}${e.op==="equals"?t?"equal":"equals":e.op==="contains"?t?"contain":"contains":e.op==="beginsWith"?t?"begin with":"begins with":t?"end with":"ends with"} ${JSON.stringify(e.value)}${e.match?`, case ${e.match.case}, whitespace ${e.match.whitespace}`:""}${o}`;case"compare":return`${e.field} ${t?"is not":"is"} ${He[e.op].replace(/^is /,"")} ${e.op==="between"?r(e.value,e.value2):JSON.stringify(e.value)}${e.precision&&e.precision!=="day"?` (by ${e.precision})`:""}${o}`;case"relative":{let n=e.direction==="this"?`this ${e.unit}`:`${e.direction} ${e.count} ${e.unit}${e.count===1?"":"s"}`,s=[e.calendar===!1?"rolling":null,e.includeCurrent===!1?"current excluded":null,e.anchor&&e.anchor!=="today"?`from ${e.anchor}`:null].filter(Boolean);return`${e.field} ${t?"is not":"is"} in the ${n}${s.length?` (${s.join(", ")})`:""}${o}`}case"top":return`${e.bottom?"bottom":"top"} ${e.count} ${e.field} by ${B(e.by)}${e.ties==="all"?", ties kept":""}`;case"value":return`${e.field} where ${B(e.by)} ${t?"is not":"is"} ${He[e.op].replace(/^is /,"")} ${e.op==="between"?r(e.value,e.value2):JSON.stringify(e.value)}`;default:return`${e.field}: ${e.type}`}}function ut(e,t,o){o=v(o,"describeView");let{valid:r,errors:n,warnings:s}=Z(e,t,o),i=z(e,t,o).view,a=i.values.map(l=>({field:l.field,agg:l.agg,label:l.label,showAs:l.showAs?.type??null,text:l.label??B(l)})),c=i.filters.map(l=>({...l,text:pt(l)})),d=i.derived.map(l=>({...l,text:`${l.name}: ${l.field} by ${l.by}${l.by==="bin"?` of ${l.size}`:""}`})),p=i.sort.map(l=>({...l,text:`${l.field} ${l.by==="value"?`by ${B(l.value)}`:l.by==="custom"?"in a custom order":"by label"}, ${l.order==="desc"?"descending":"ascending"}`})),m=[a.length?a.map(l=>l.text).join(", "):"count of rows",i.rows.length?`by ${i.rows.join(" > ")}`:null,i.cols.length?`across ${i.cols.join(" > ")}`:null,c.length?`where ${c.map(l=>l.text).join("; and ")}`:null,i.display==="chart"?`as a ${i.chart.type==="auto"?"chart":`${i.chart.type} chart`}`:null];return{valid:r,errors:n,warnings:s,rows:{fields:i.rows,text:i.rows.join(" > ")},cols:{fields:i.cols,text:i.cols.join(" > ")},values:a,filters:c,derived:d,sort:p,display:{mode:i.display,chart:i.display==="chart"?i.chart.type:null},text:`${r?"":`(invalid: ${n.length} error${n.length===1?"":"s"}, the parts they name are left out) `}${m.filter(Boolean).join(" ")}`}}var O=Object.freeze({fields:1e3,label:120,description:1e3,order:1e3,href:2e3,depth:32,steps:2e4}),R=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),x=(e,t)=>R(e)&&Object.hasOwn(e,t)?e[t]:void 0,G=(e,...t)=>Object.fromEntries(Object.entries(e).filter(([o])=>!t.includes(o)));function We(e,t){if(typeof e!="string")return;let o=e.slice(0,t*4).replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029]+/g," ").replace(/[\u200b-\u200f\u202a-\u202e\u2060-\u2064\u2066-\u2069\ufeff]/g,"").replace(/\s+/g," ").trim();if(o)return o.length>t?`${o.slice(0,t-1).trimEnd()}\u2026`:o}function dt(e){if(!(typeof e!="string"||e.length>O.href))try{let t=new URL(e.trim());return t.protocol==="https:"&&!t.username&&!t.password?t.href:void 0}catch{return}}function Je(e,t){if(typeof t!="string"||!t.startsWith("#"))return;let o=t.slice(1).split("/").slice(1).map(n=>n.replace(/~1/g,"/").replace(/~0/g,"~")),r=e;for(let n of o)if(r=Array.isArray(r)&&/^\d+$/.test(n)?r[Number(n)]:x(r,n),r===void 0)return;return r}var Be=Symbol("resolving");function j(e,t,o,r=o){let n=`${r}:${t}`;!e.said.has(n)&&e.issues.length<100&&(e.said.add(n),e.issues.push({path:t,message:o}))}function N(e,t,o,r=0){if(!R(t))return;if(r>O.depth){j(e,o,`nested deeper than ${O.depth} levels; not read`,"depth");return}if(e.steps<=0){j(e,"",`stopped after ${O.steps} schema objects; the rest is not read`,"steps");return}e.steps-=1;let n=t,s=x(n,"$ref");if(typeof s=="string"){let a=e.refs.get(s);if(a===Be){j(e,o,`$ref ${s.slice(0,200)} refers to itself; not read`);return}if(!e.refs.has(s)){let c=Je(e.root,s);c===void 0&&j(e,o,s.startsWith("#")?`$ref ${s.slice(0,200)} is not in the document`:`$ref ${s.slice(0,200)} is not local; not fetched`),e.refs.set(s,Be),a=N(e,c,s.slice(0,200),r+1),e.refs.set(s,a)}if(!a)return;n={...a,...G(n,"$ref")}}let i=x(n,"allOf");if(Array.isArray(i)){let a=i.slice(0,O.fields).map((p,m)=>N(e,p,`${o}.allOf[${m}]`,r+1)).filter(Boolean),c={};for(let p of[...a,n]){let m=x(p,"properties");if(R(m))for(let l of Object.keys(m))Object.defineProperty(c,l,{value:m[l],enumerable:!0,writable:!0,configurable:!0})}n={...a.reduce((p,m)=>({...p,...G(m,"properties")}),{}),...G(n,"allOf"),properties:c}}for(let a of["anyOf","oneOf"]){let c=x(n,a);if(Array.isArray(c)){let d=c.slice(0,O.fields).map((p,m)=>N(e,p,`${o}.${a}[${m}]`,r+1)).filter(p=>p&&x(p,"type")!=="null");d.length===1&&(n={...d[0],...G(n,a)})}}return n}function Ge(e){let t=x(e,"type"),o=Array.isArray(t)?t.filter(r=>r!=="null"):[t];return o.length===1&&typeof o[0]=="string"?o[0]:void 0}function ht(e,t,o="fieldDefaultsFromSchema"){return E(typeof t=="string"&&t.trim()!=="",`${o}: an OpenAPI document needs options.schema, the name of a schema or a local $ref`),t.startsWith("#")?Je(e,t):x(x(x(e,"components"),"schemas"),t)??x(x(e,"definitions"),t)}function gt(e,t={}){E(R(e),"fieldDefaultsFromSchema: the schema must be an object"),E(R(t),"fieldDefaultsFromSchema: options must be an object");let o=e,r=x(o,"openapi")!==void 0||x(o,"swagger")!==void 0,n={root:o,steps:O.steps,refs:new Map,issues:[],said:new Set},s=N(n,r||t.schema!==void 0?ht(o,t.schema):o,"");E(s,`fieldDefaultsFromSchema: no schema ${JSON.stringify(String(t.schema??"")).slice(0,80)} in the document`),Ge(s)==="array"&&(s=N(n,x(s,"items"),"items"));let i=x(s,"properties");E(R(i),"fieldDefaultsFromSchema: the schema of a row must have properties");let a={},c=Object.keys(i);c.length>O.fields&&j(n,"properties",`${c.length} fields, more than ${O.fields}: the first ${O.fields} are read`);for(let d of c.slice(0,O.fields)){let p=N(n,i[d],`properties.${d.slice(0,200)}`);if(!p)continue;let m={},l=We(x(p,"title"),O.label);l&&(m.label=l);let f=We(x(p,"description"),O.description);f&&(m.description=f);let y=dt(x(x(p,"externalDocs"),"url"));y&&(m.href=y);let h=Ge(p),u=x(p,"format");h==="integer"||h==="number"?m.type="number":h==="string"&&(u==="date"||u==="date-time")&&(m.type="date");let g=x(p,"enum");if(Array.isArray(g)){let S=g.slice(0,O.order).filter(b=>b===null||["string","number","boolean"].includes(typeof b));S.length>0&&(m.order=S)}Object.keys(m).length>0&&Object.defineProperty(a,d,{value:m,enumerable:!0,writable:!0,configurable:!0})}return{defaults:a,issues:n.issues}}export{Ze as a,De as b,rt as c,st as d,nt as e,it as f,at as g,ut as h,We as i,gt as j};