pivotkit-element 0.2.0 → 0.4.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.
@@ -0,0 +1 @@
1
+ import{A as Wn,B as at,C as be,D as kt,Da as ao,E as zt,I as Gn,J as Ht,L as Wt,M as Gt,N as vt,O as Re,P as Qn,Qa as ro,R as Yn,S as Xn,W as fe,X as Qt,Y as Yt,Z as ze,a as Pt,b as qn,c as Un,d as Vt,g as ot,h as _e,ha as rt,i as Jn,ia as Xt,j as Kn,ja as Zt,k as we,l as Ae,la as en,m as jt,ma as Zn,n as qt,na as eo,o as _n,p as Ut,q as Jt,qa as to,r as zn,ra as no,s as Kt,sa as oo,w as Hn,y as Ee,z as _t}from"./chunk-IBQE3N74.js";import{B as Ke,C as nt,D as Dn,E as Mn,F as Bn,G as Bt,I as Pn,J as L,K as W,L as Vn,M as jn,a as Oe,d as ie,e as Cn,f as Je,h as Tn,i as Ln,j as X,n as ht,q as Dt,r as On,s as gt,t as $e,u as Pe,y as H,z as Mt}from"./chunk-WNTTPBZ5.js";import{B as Me,D as Be,V as $n,X as Rn,ba as Fn,e as In,m as Q}from"./chunk-WXBFHMFX.js";import{a as An}from"./chunk-O2TTHYGT.js";import"./chunk-MB64GADT.js";import{c as Le}from"./chunk-DCANE7XH.js";var lo={aboutSetting:"About {setting}",settingInfo:{grandTotalRow:"A last row with the total of every column.",grandTotalColumn:"A last column with the total of every row.",rowSubtotals:"With two or more fields in Rows: a total row under each group of the outer field.",colSubtotals:"With two or more fields in Columns: a total column after each group of the outer field.",along:"The direction the calculation walks: Rows goes down the rows of each column, Columns across the columns of each row. A running total adds up along it, a difference compares with the item before it.",showAs:"Shows each value as a share, a difference, a running total or a rank instead of the number itself. For percentages, a tip above the result says what 100% is.",exportXlsx:"Every number with all its decimals, formats kept, ready to calculate with.",exportCsv:"Percentages and calculations as the table shows them, as plain text.",copyTable:"The table as it is shown, headers and totals included: tab-separated, pastes into Excel or Google Sheets as columns.",copyDataJson:"The table's numbers with their labels as JSON, for a program. Not the view itself: that is Views \u2192 Copy view as JSON.",drillCopy:"The rows as the panel shows them, with a header row: tab-separated, pastes into Excel or Google Sheets as columns.",drillJson:"The rows as JSON objects, with the data's field names and raw values, for a program.",groupLabels:"With two or more fields in Rows: the outer field's items written once under the axis, below their categories.",labelPosition:"Outside: each slice's name and number next to it. Inside: the number on the slice, the names in the legend; outside when a donut's ring is too thin for it.",sharedView:"Only admins can change shared views.",valuesFilter:"Values are not filtered here: filter a field on Rows or Columns through its menu, or move a field to Filters."},back:"Back",backTo:"Back to the menu of {name}",levelTitle:"{name} \u203A {topic}",searchMenu:"Search in the menu of {name}",searchMenuShort:"Search in this menu (key /)",searchResults:"Results",searchNothing:"Nothing found. Try another word, or clear the search.",sortByValue:"Sort by value",sortOldestShort:"Oldest",sortNewestShort:"Newest",filterTopic:"Filter",filterAll:"All",groupTopic:"Group",groupNoneShort:"None",off:"Off",moveToTitle:"Move to",topOwn:"Top N\u2026",binsOff:"Remove ranges",valueConditionTitle:"Condition on a value",nameHint:"Applies with Enter or when you leave the field; Escape gives the name back.",showAsKeywords:"percent % share",nameKeywords:"rename label title",filterKeywords:"values pick choose rule rules condition range dates",formatDecimals:{one:"Number, {count} decimal",other:"Number, {count} decimals"},listAnd:" and ",summaryAll:"All {total} {noun} shown",summarySome:"{shown} of {total} {noun} shown",summaryNone:"Nothing shown",summaryOk:"Every item is picked, no rules.",summaryKept:"Every item is picked; the rules keep them all.",summaryQuickOnly:"Every item is picked; {quick}.",summaryPicks:"{count} left out by your picks",summaryQuick:"{count} outside {quick}",summaryRules:{one:"{items} left out by the rule",other:"{items} left out by the rules"},summaryTotals:{one:"{items} left out by the rule on the total",other:"{items} left out by the rules on the totals"},summaryRows:"{rows} of {total} rows",summaryData:"data {range}",yearsAll:"{years} combined",yearsOne:"{year} only",emptyPicks:"Nothing is picked.",emptyRules:"No {noun} meets {rules}.",emptyTotal:"No {noun} has a total {rule} \u2013 {spread}.",totalSpread:"the totals go from {low} ({lowItem}) to {high} ({highItem})",totalWords:"{measure} that {op} {number}",totalWordsTwo:"{measure} that {op} {from} and {to}",resetFilter:"Reset filter",nouns:{item:{one:"item",other:"items"},value:{one:"value",other:"values"},date:{one:"date",other:"dates"},year:{one:"year",other:"years"},quarter:{one:"quarter",other:"quarters"},month:{one:"month",other:"months"},week:{one:"week",other:"weeks"},day:{one:"day",other:"days"},weekday:{one:"weekday",other:"weekdays"},hour:{one:"hour",other:"hours"},range:{one:"range",other:"ranges"}},quickTitle:"Quick choices",quickCount:{year:"Number of years",month:"Number of months",day:"Number of days"},quickLast:{year:{one:"Last {count} year",other:"Last {count} years"},month:{one:"Last {count} month",other:"Last {count} months"},day:{one:"Last {count} day",other:"Last {count} days"}},quickRows:"{rows} rows",quickHidden:{one:"{choices} is not offered: the data end {latest}.",other:"{choices} are not offered: the data end {latest}."},anchorLabel:"Counted back from",anchorToday:"today ({date})",anchorLatest:"the latest record ({date})",quickLine:"Quick choice: {text}",changeAbove:"change it above",yearsCombined:"Years combined",yearsCombinedHint:"one {noun} over the years ticked",yearsCombinedOne:"The table shows {year} only.",pickItems:"Pick items",picksState:"{picked} of {total} picked",picksAll:"all {total} picked",clear:"Clear",clearPicks:"Clear picks",rulesState:{one:"{count} rule",other:"{count} rules"},rulesNoneState:"No rules",removeAll:"Remove",removeRules:"Remove the rules",tailOut:{one:"Left out by the rules ({count}) \u2013 its tick applies again once they go",other:"Left out by the rules ({count}) \u2013 their ticks apply again once they go"},rulesKeep:"Keep the {noun} for which all of these are true:",rulesNone:"Keep the {noun} for which all of these are true. Add one below.",ruleKeeps:"Keeps {kept} of {total} {noun}",ruleKeepsNone:"Keeps 0 of {total} {noun} \u2013 {spread}.",ruleIncomplete:"Applies once it is complete.",explainRule:"Explain this rule",ruleInfo:{number:"Compares the value itself, not its total. Example: \u201Cis between 20 and 25\u201D keeps the values from 20 to 25.",date:"Compares each date by its calendar day. Example: \u201Cis before Mar 1, 2022\u201D keeps every day up to Feb 28, 2022.",group:"Compares each {noun} by its place on the time line. Example: \u201Cis from 2022\u201D keeps 2022 and every later one.",cyclic:"Compares each {noun} by its place in the year, over all the years combined. Example: \u201Cis from Jun\u201D keeps Jun to Dec.",total:"The total is the {noun}\u2019s Grand Total \u2013 the {measure} over {scope}, as the Grand Total row shows it \u2013 not a single cell. Example: \u201Cis greater than 20\u201D keeps the {nouns} whose total is above 20.",name:"Compares the name of each {noun} as the table writes it. Example: \u201Ccontains ar\u201D keeps Mar and March."},scopeItems:"all {count} {field} items",scopeDates:"the dates {range}",scopeRows:"every row",pickerSearch:"Search items",pickerMatch:"{count} of {total} match",pickerNone:"No match",rulesTitle:"Rules",ruleAnd:"and",addRule:"Add a rule",addRuleItem:"Compare {field}",addRuleTotal:"Compare its total",addRuleName:"Rule on the name",removeRule:"Remove this rule",rulesFull:"At most {max} rules per field.",ruleName:"The name",ruleValue:"Value",ruleDate:"Date",dateOps:{"=":"is","!=":"is not",">":"is after",">=":"is from","<":"is before","<=":"is up to",between:"is between",notBetween:"is not between"},lastOp:{one:"is in the last",other:"is in the last"},ruleUnits:{year:{one:"year",other:"years"},month:{one:"month",other:"months"},day:{one:"day",other:"days"}},ruleWhose:"{field} items whose total",blanksOut:"Blank items are not kept.",ruleUnit:"Unit",moveLeft:"Move left",moveRight:"Move right",remove:"Remove field",chartAutoNow:"Now: {type}",sharedViews:"Shared views",myViews:"My views",noViews:"No saved views yet.",noViewsStore:"None yet. Saved views stay in this browser only.",publishView:"Publish {name} as a shared view",publishConfirm:"Publish \u201C{name}\u201D as a shared view? Everyone who uses this report sees it.",publishAction:"Publish",storeNote:"Kept in this browser only: not on other devices, and gone when the site's data is cleared.",storeFull:"this browser keeps at most {max} views",storeTooLarge:"the views would take more than {max} characters",storeRefused:"this browser did not keep it (storage blocked or full)",storeChanged:"the views were changed in another tab; open the menu again",toastSaved:"View \u201C{name}\u201D saved",toastDeleted:"View \u201C{name}\u201D deleted",toastPublished:"View \u201C{name}\u201D published",toastSaveFailed:"The view could not be saved: {message}",toastDeleteFailed:"The view could not be deleted: {message}",toastPublishFailed:"The view could not be published: {message}",toastSaveRejected:"The server could not save the view.",toastDeleteRejected:"The server could not delete the view.",toastPublishRejected:"The server could not publish the view.",deleteView:"Delete {name}",deleteConfirm:"Delete \u201C{name}\u201D?",deleteAction:"Delete",saveView:"Save current view",viewName:"Name of the view",thisView:"This view",saveNamed:"Save \u201C{name}\u201D",saveAs:"Save as\u2026",saveSharedLocked:"Shared view: you cannot change it. Use Save as.",saveNotInViews:"Not saved yet. Use Save as.",replaceConfirm:"\u201C{name}\u201D exists. Replace it?",replaceAction:"Replace",replaceSharedConfirm:"Replace the shared view \u201C{name}\u201D for everyone?",save:"Save",cancel:"Cancel",expandAll:"Expand all",collapseAll:"Collapse all",aggregation:"Summarize by",moreStatistics:"More statistics",showAsNone:"The value itself",moreCalculations:"More calculations",showAsNames:{percentOfGrandTotal:"% of grand total",percentOfRowTotal:"% of row total",percentOfColumnTotal:"% of column total",percentOfParentRow:"% of parent row",percentOfParentColumn:"% of parent column",differenceFromPrevious:"Difference from previous",percentDifferenceFromPrevious:"% difference from previous",runningTotal:"Running total",percentRunningTotal:"% running total",rankAscending:"Rank, smallest first",rankDescending:"Rank, largest first"},along:"Along",format:"Number format",formatAuto:"Automatic",formats:{number:"Number","number:0":"Number, no decimals","number:2":"Number, 2 decimals",integer:"Whole number",currency:"Currency",percent:"Percent",compact:"Compact (1.2K)",bytes:"Bytes (KB, MB)","duration:h":"Duration from hours","duration:s":"Duration from seconds"},conditional:"Highlight",conditionalNone:"None",colorScale:"Colour scale",dataBar:"Data bars",rename:"Name",sortOldest:"Oldest first",sortNewest:"Newest first",groupNone:"No grouping (every date and time)",groupTimeline:"Along the time line",groupCyclic:"Same period every year",unitHints:{year:"2025",yearQuarter:"Q1 2025",yearMonth:"Jan 2025",yearWeek:"2025-W03",day:"Jan 15, 2025",quarter:"Q1 of every year",month:"Jan of every year",week:"W03 of every year",weekday:"Mon to Sun",hour:"00:00 to 23:00",bin:""},bins:"Number ranges",binsState:"Ranges of {size} from {start}",binSize:"Range size",binStart:"Starting at",binStartFar:"Ranges from {start} cannot hold this field's values ({min} to {max}): every row would be blank. Pick a start closer to them.",apply:"Apply",topN:"Top items",topCount:"Count",bottom:"Bottom",topBy:"by",searchValues:"Search values",selectAll:"Select all",selectNone:"Select none",onlyThis:"Only",valuesShown:"{shown} of {total} values; search to find more",conditionNumber:"Condition on the label",conditionNone:"No condition",conditionValue:"Text",selected:"{count} selected",exportDownload:"Download",exportCopy:"Copy",exportXlsx:"Excel workbook (.xlsx)",exportCsv:"CSV file (.csv)",exportPng:"Chart image (.png)",exportPngNeedsChart:"Switch to Chart first.",exportNeedsField:"Add a field first.",copyTable:"Copy table",copyDataJson:"Copy data as JSON",toastTableCopied:"Table copied: tab-separated, pastes into Excel or Google Sheets as columns",toastDataCopied:"Data copied as JSON",toastCopyBlocked:"This page does not allow copying. Download a file instead.",drillTitle:"Rows behind this value",drillCount:{one:"{count} row",other:"{count} rows"},drillShown:"Showing the first {shown} of {count} rows",drillCopy:"Copy",drillJson:"Copy as JSON",drillCsv:"Download CSV",drillXlsx:"Download Excel",drillPart:"{shown} of {count} rows",drillCopied:"Copied {rows}: tab-separated, pastes into Excel or Google Sheets as columns",drillCopiedJson:"Copied {rows} as JSON",drillExported:"Exported {file} ({rows})",drillExportNote:"Holds the first {shown} of {count} rows, as shown here.",showTips:"Show tips",showSettingInfo:"Show explanations",resetTips:"Show dismissed tips again",sectionChanged:", changed",help:"Help",shortcutsTitle:"Keyboard shortcuts",keys:{Mod:"Ctrl",Shift:"Shift","Arrow keys":"Arrow keys",Enter:"Enter",Space:"Space",Escape:"Escape",F10:"F10"},shortcuts:{undo:"Undo",redo:"Redo",move:"Move between values in the table",open:"Open the rows behind a value; sort by a header; open a menu",drag:"Pick up a field or chip, and drop it",close:"Close a menu, a panel or a tip",fields:"In the field list: up and down between fields, left and right to a field's grip, its \u201Ci\u201D and its menu",fieldMenu:"Open the menu of the field in focus"},valueLabels:"Value labels",valueLabelNames:{auto:"Automatic",off:"Off",value:"Value",percent:"Percent",both:"Value and percent"},legend:"Legend",legendNames:{auto:"Automatic",bottom:"Bottom",right:"Right",off:"Off"},chartTitle:"Title",chartTitleNone:"No title",smoothLines:"Smooth lines",labelPosition:"Labels",labelPositionNames:{outside:"Outside",inside:"Inside"},axisLabels:"Axis labels",axisLabelNames:{auto:"Automatic",all:"All (slanted)",nth:"Every n-th"},groupLabels:"Group labels under the axis",groupLabelNames:{auto:"Automatic",on:"On",off:"Off"},defaultName:"Use the default name",shareThisView:"Share this view",copyLink:"Copy link",copyJson:"Copy view as JSON",downloadView:"Download view (.pivotkit.json)",sharePrivacy:"A view holds the names of fields and, in its filters, the values chosen there: share it only where those may be seen.",loadView:"Open view file\u2026",loadViewHint:"Paste a view file, a view as JSON or a link, or choose a .pivotkit.json file.",loadViewText:"View as JSON or link",chooseFile:"Choose file\u2026",load:"Load",loadCheckTitle:"This view may not fit this data",loadAnyway:"Load anyway",switchAndLoad:"Switch to \u201C{source}\u201D and load",switchStartsFresh:"Switching shows the other data with this view; Undo starts there.",numberInvalid:"Enter a number, such as {example}.",countInvalid:"Enter a whole number of 1 or more.",countMax:"Enter a whole number up to {max}.",sizeInvalid:"Enter a number above 0, such as {example}.",valueFilterBy:"Value",valueFilterOp:"Condition",valueFilterNumber:"Number",valueFilterTo:"and",valueOps:{"=":"is","!=":"is not",">":"is greater than",">=":"is at least","<":"is less than","<=":"is at most",between:"is between",notBetween:"is not between"},moreFormats:"More formats",totals:"Totals",grandTotalRow:"Grand total row",grandTotalColumn:"Grand total column",rowSubtotals:"Row subtotals",colSubtotals:"Column subtotals",needsRowField:"Needs a field in Rows.",needsColField:"Needs a field in Columns.",needsRowFields:"Needs two or more fields in Rows.",needsColFields:"Needs two or more fields in Columns.",expandNothing:"Nothing is collapsed.",collapseNeedsRows:"Needs two or more fields in Rows.",collapseAllDone:"Every group is collapsed already.",groupsCollapsed:{one:"{count} group collapsed",other:"{count} groups collapsed"},groupsExpanded:{one:"{count} group expanded",other:"{count} groups expanded"},chartDisplay:"Display",toastExported:"Exported {file}",toastLinkCopied:"Link copied",toastJsonCopied:"View copied as JSON",toastCopyFailed:"This page does not allow copying. Use \u201CDownload view\u201D instead.",toastLinkTooLong:"This view is too large for a link. Use \u201CDownload view\u201D instead."},tn=new Map([["en",lo]]);function Zo(e,t){tn.set(e,t)}var ea=e=>tn.has(e),so=new WeakMap;function io(e){let t=tn.get(e.lang)??lo,n=so.get(e);if(n&&n.base===t)return n.out;let o={...e,...jn(t,e[Vn])};return so.set(e,{base:t,out:o}),o}var $=Le(Oe(),1);var m=Le(Oe(),1);var V=Le(Oe(),1);var b=Le(Oe(),1),Ge=Le(Oe(),1);var oe=Le(Oe(),1),k=Le(Oe(),1);var Fe=Object.freeze({count:500,text:5e6});function ta(e){try{return JSON.stringify(e)?.length??0}catch{return-1}}function co(e){let t={templates:[],issues:[]},n=(a,l)=>t.issues.push({path:a,message:l}),o=e;if(typeof e=="string"){if(e.length>Fe.text)return n("",`longer than ${Fe.text} characters; not read`),t;try{o=JSON.parse(e)}catch{return n("","not valid JSON"),t}}if(!Array.isArray(o))return n("","not a list of templates"),t;o.length>Fe.count&&n("",`${o.length} templates, more than ${Fe.count}: the first ${Fe.count} are read`);let r=typeof e=="string"?-1/0:0;for(let a=0;a<Math.min(o.length,Fe.count);a++){let l=o[a];if(r!==-1/0){let h=ta(l);if(h<0){n(`[${a}]`,"not JSON; left out");continue}if(r+=h,r>Fe.text){n(`[${a}]`,`the templates are longer than ${Fe.text} characters as JSON; this one and the rest are left out`);break}}let s=Bn(l);if(s.failed||!s.view){n(`[${a}]`,`${s.issues.at(-1)?.message??"no view"}; left out`);continue}let i=s.view===l,d=Mt(i?Object.hasOwn(s.view,"name")?s.view.name:void 0:s.name,Ke.name);if(!d){n(`[${a}]`,"no name; left out");continue}let u={...s.view};i&&delete u.name;let c={name:d,view:u},p=Mt(s.description,Ke.description);p&&(c.description=p),s.source&&Object.keys(s.source).length>0&&(c.source=s.source),t.templates.push(c),s.issues.forEach(h=>n(`[${a}]${h.path?`.${h.path}`:""}`,h.message))}return t}var P=Le(Oe(),1);var Z=Le(Oe(),1),na=new Set(["count","countUnique","listUnique"]),yt=e=>na.has(e)?"count":"field";function rn(e,t,n,o={}){let r=at(e);if(!r.values[t])return e;let a=e.values[t],l={...r.values[t],...n};if(n.agg&&n.agg!==a.agg){l.showAs=n.showAs??null;let s=o.defaults??{},i=typeof s.format=="string"&&Me(s.format)?s.format:null,d=a.format&&a.format!==i?a.format:null;n.format!==void 0?l.format=n.format:d?l.format=yt(a.agg)===yt(n.agg)?d:null:l.format=i&&yt(typeof s.agg=="string"?s.agg:"sum")===yt(n.agg)?i:null}return r.values[t]=l,r}function oa(e,t,n){if(!n)return null;for(let o of[n.min,n.max]){let r=Math.floor((o-t)/e),a=t+r*e,l=e*1e-9;if(!Number.isSafeInteger(r)||a+e===a||a>o+l||o>=a+e+l)return"far"}return null}function st(e,t,n,o){let r=at(e),a=r.filters.findIndex(i=>be(i.field,t)),l=r.filters.filter(i=>!(be(i.field,t)&&n.includes(i.type))),s=a===-1?l.length:Math.min(a,l.length);return l.splice(s,0,...o),r.filters=l,!zt(r,t)&&kt(e).some(i=>be(i,t))&&!l.some(i=>be(i.field,t))&&r.filters.splice(s,0,{field:t,type:"exclude",items:[]}),r}function No(e,t,n,o){let r=at(e),a=n?JSON.stringify(n):null,l=a===null?-1:r.filters.findIndex(s=>be(s.field,t)&&JSON.stringify(s)===a);if(l===-1){if(!o)return r;let s=r.filters.map(i=>be(i.field,t)).lastIndexOf(!0);return r.filters.splice(s+1,0,o),r}return o?r.filters[l]=o:(r.filters.splice(l,1),!zt(r,t)&&kt(e).some(s=>be(s,t))&&!r.filters.some(s=>be(s.field,t))&&r.filters.splice(l,0,{field:t,type:"exclude",items:[]})),r}function sn(e,t,n,o){let r=new Set(n.map(l=>JSON.stringify(l))),a=o.filter(l=>!r.has(JSON.stringify(l)));return st(e,t,["include","exclude"],a.length?[{field:t,type:"exclude",items:a}]:[])}function uo(e,t,n){return st(e,t,["label"],n&&n.value!==""?[{field:t,type:"label",op:n.op,value:n.value}]:[])}function xo(e,t,n,o){let r=n?{field:t,type:"top",count:n.count,bottom:!!n.bottom,...n.by?{by:n.by}:{}}:null;return o?No(e,t,o,r):st(e,t,["top"],r?[r]:[])}var St=Object.freeze(["relative","compare","value","label"]),mo=10,We=(e,t,n,o)=>No(e,t,n,o),aa=Object.freeze(["year","yearQuarter"]);function So(e,t,n){let o=vt(t,n),r=e.column(Re(t,n))?.type??"string",a=r==="date",l=o?o.by==="day"?"date":"group":r==="number"||r==="date"?r:null,s=a&&!!o&&H.cyclicUnits.includes(o.by),i=a&&!s;return{item:l,dates:a,cyclic:s,quick:i,months:i&&!aa.includes(o?.by),days:i&&l==="date",unit:o?.by??null}}function Co(e,t,{labels:n,locale:o,timeZone:r,date:a,labelOf:l,span:s}){return t.type==="value"?Kn(e,t,n,o):zn(t,n,o,{timeZone:r,date:a,labelOf:l,span:s})}function ra(e,t,n,o=[]){let r=fe(e,t,["relative"]),a=fe(e,t,["compare"]);if(n.cyclic){let d=a.filter(To),u=d.length?sa(d,o):null;return u?{id:"yearsCombined",years:u,filters:d}:{id:"all",filters:[]}}let l={year:!0,month:n.months,day:n.days},s=r.find(d=>l[d.unit]);return s?{id:s.unit==="year"?s.count===1?"thisYear":"years":`${s.unit}s`,count:s.count,anchor:s.anchor??"today",filters:[s]}:{id:"all",filters:[]}}function sa(e,t){let n=new Set(t);for(let o of e){let[r,a]=Jt(o.value,o.value2).map(Number);n=new Set([...n].filter(l=>(r<=l&&l<=a)==(o.op==="between")))}return n.size?[...n].sort((o,r)=>o-r):null}var To=e=>e.type==="compare"&&(e.op==="between"||e.op==="notBetween")&&Jt(e.value,e.value2)!==null;function la(e,t,n){if(!t.length||t.length===n.length)return[];let o=(l,s)=>`${String(l).padStart(4,"0")}-${s?"12-31":"01-01"}`,r=(l,s,i)=>({field:e,type:"compare",op:l,value:o(s,!1),value2:o(i,!0)}),a=[r("between",t[0],t[t.length-1])];for(let l=1;l<t.length;l++)n.some(s=>t[l-1]<s&&s<t[l])&&a.push(r("notBetween",t[l-1]+1,t[l]-1));return a}function ia(e,t,n,o){let r=fe(e,t,["compare"]).filter(To).reduce((a,l)=>We(a,t,l,null),e);return la(t,n,o).reduce((a,l)=>We(a,t,null,l),r)}function Lo(e,t,n){return st(e,t,["relative"],n?[{field:t,type:"relative",unit:n.unit,count:n.count,...n.anchor==="latest"?{anchor:"latest"}:{}}]:[])}function ca(e,t,n){let o=at(e);for(let r of o.filters)be(r.field,t)&&r.type==="relative"&&(delete r.anchor,n==="latest"&&(r.anchor="latest"));return o}var ua=(e,t)=>st(e,t,["include","exclude",...St],[]);function nn(e,t,n,o,r){let a=Rn(e,{...t,rows:[n],cols:[],values:[{...o.field?{field:o.field}:{},agg:o.agg}],filters:r,sort:[]}),l=new Map;if(!a.values.length)return{totals:l,rows:a.rows.length};for(let s of a.rowRoot.children){let i=a.value(s,a.colRoot,0);l.set(JSON.stringify(s.key),typeof i=="number"&&Number.isFinite(i)?i:null)}return{totals:l,rows:a.rows.length}}function Oo(e,t){return t&&!e.some(n=>ze(n,t))?[...e,{field:t.field??null,agg:t.agg}]:e}function ln(e,t){let n=[];for(let o of e.values){let r={field:o.field??null,agg:o.agg};Yt(o,o.field?t(o.field)??"string":"number")&&!n.some(a=>ze(a,r))&&n.push(r)}return n.length?n:[{field:null,agg:"count"}]}function ma(e,t,n=[]){let o=new Set(n.map(r=>JSON.stringify(r)));return fe(e,t,St).filter(r=>!o.has(JSON.stringify(r))).reduce((r,a)=>We(r,t,a,null),e)}var da=Object.freeze(["grandTotalRow","grandTotalColumn","rowSubtotals","colSubtotals"]);function pa(e,t){return t==="grandTotalRow"?e.rows.length>=1?null:"needsRowField":t==="grandTotalColumn"?e.cols.length>=1?null:"needsColField":t==="rowSubtotals"?e.rows.length>=2?null:"needsRowFields":e.cols.length>=2?null:"needsColFields"}function Ao(e,t,n){let o=e.column(Re(t,n))?.type??"string";return o==="date"||o==="boolean"?null:o==="number"?"number":"text"}function fa(e,t,n,o,r){let a=s=>typeof s.field=="string"&&s.field.toLowerCase()===t.toLowerCase(),l=[];n&&n.summary&&l.push(L(o.filterSummary,{shown:n.summary.shown.toLocaleString(r),total:n.summary.total.toLocaleString(r)})),l.push(...n?.rules??[]);for(let s of e.filters.filter(a))(s.type==="value"||s.type==="label"&&!n?.rules)&&l.push(Co(e,s,{labels:o,locale:r,timeZone:"UTC",date:!1}));return l.length?l.join(", "):null}var hn=300,se=e=>JSON.stringify(e);function Io({items:e,selected:t,onChange:n,labels:o,locale:r,autoFocus:a=!1,tail:l,children:s}){let[i,d]=(0,V.useState)(""),u=ie(),c=i.trim().toLocaleLowerCase(),p=c?e.filter(S=>S.label.toLocaleLowerCase().includes(c)):e,h=l?p.filter(S=>!l.isOut(S)):p,g=l?p.filter(S=>l.isOut(S)):[],f=h.slice(0,hn),N=S=>{let C=new Set(t);for(let x of p)S?C.add(se(x.value)):C.delete(se(x.value));n(C)},w=S=>{let C=new Set(t),x=se(S);C.has(x)?C.delete(x):C.add(x),n(C)},v=(S,C)=>{let x=se(S.value);return V.default.createElement("li",{key:x,className:`pk-value${C?" pk-value-out":""}`},V.default.createElement("label",null,V.default.createElement("input",{type:"checkbox",name:u,checked:t.has(x),onChange:()=>w(S.value)}),V.default.createElement("span",{className:"pk-value-label"},S.label),V.default.createElement("span",{className:"pk-count"},S.count.toLocaleString(r))),V.default.createElement("button",{type:"button",className:"pk-link pk-only",onClick:()=>n(new Set([x])),"aria-label":`${o.onlyThis}: ${S.label}`},o.onlyThis))};return V.default.createElement(V.default.Fragment,null,V.default.createElement("label",{className:"pk-search"},V.default.createElement(X,{name:"search"}),V.default.createElement("span",{className:"pk-sr"},o.searchValues),V.default.createElement(Ee,{type:"search",value:i,placeholder:o.searchValues,onChange:d,clearLabel:o.clearText,"data-autofocus":a?"":void 0,"data-testid":"filter-search"})),V.default.createElement("div",{className:"pk-filter-actions"},V.default.createElement("button",{type:"button",className:"pk-action",onClick:()=>N(!0),"data-testid":"select-all"},o.selectAll),V.default.createElement("button",{type:"button",className:"pk-action",onClick:()=>N(!1),"data-testid":"select-none"},o.selectNone)),V.default.createElement("div",{className:"pk-filter-body"},V.default.createElement("ul",{className:"pk-values",role:"list"},f.map(S=>v(S,!1)),h.length>f.length?V.default.createElement("li",{className:"pk-hint pk-values-more"},L(o.valuesShown,{shown:f.length,total:h.length.toLocaleString(r)})):null,g.length&&l?l.render(g,S=>v(S,!0),c!==""):null),s))}function ha({view:e,base:t,field:n,encoded:o,locale:r,labels:a,commit:l,close:s}){let i=t??e,d=ie(),u=(0,V.useMemo)(()=>Pe(o,n,{view:i,locale:r,labels:a.core}),[o,n,i,r,a]),c=(0,V.useMemo)(()=>u?u.items.map(O=>O.value):[],[u]),[p,h]=(0,V.useState)(()=>new Set(Qt(i,n,c).map(se))),g=fe(i,n,["label"])[0],[f,N]=(0,V.useState)(g?.op??""),[w,v]=(0,V.useState)(g?.value??"");if(!u)return null;let S=Q(n,a.core),C=()=>{let O=sn(i,n,c.filter(B=>p.has(se(B))),c);O=uo(O,n,f?{op:f,value:w}:null),s(),l(O,{step:"filter",field:S})},x=Ao(o,i,n)??(g?"text":null);return V.default.createElement("form",{className:"pk-filter",onSubmit:O=>{O.preventDefault(),C()}},V.default.createElement("div",{className:"pk-popover-head"},V.default.createElement("h3",null,L(a.filterTitle,{field:S})),V.default.createElement("span",{className:"pk-muted"},L(a.selected,{count:p.size.toLocaleString(r)}))),V.default.createElement(Io,{items:u.items,selected:p,onChange:h,labels:a,locale:r,autoFocus:!0},x?V.default.createElement("fieldset",{className:"pk-condition"},V.default.createElement("legend",null,x==="number"?a.conditionNumber:a.condition),V.default.createElement("select",{name:`${d}-op`,value:f,onChange:O=>N(O.target.value),"aria-label":x==="number"?a.conditionNumber:a.condition},V.default.createElement("option",{value:""},a.conditionNone),H.labelOps.map(O=>V.default.createElement("option",{key:O,value:O},a.labelOps[O]??O))),f?V.default.createElement(Ee,{type:"text",value:w,onChange:v,onClear:()=>{!t&&fe(i,n,["label"]).length&&l(uo(i,n,null),{step:"filter",field:S})},clearLabel:a.clearText,"aria-label":a.conditionValue,placeholder:a.conditionValue,maxLength:1e3,"data-testid":"filter-condition-text"}):null):null),V.default.createElement("div",{className:"pk-popover-foot"},V.default.createElement("button",{type:"button",className:"pk-btn",onClick:s},a.cancel),V.default.createElement("button",{type:"submit",className:"pk-btn pk-primary","data-testid":"filter-apply"},a.apply)))}function ns({target:e,onClose:t,view:n,encoded:o,locale:r,labels:a,commit:l}){let s=(0,V.useMemo)(()=>({current:e?e.anchor:null}),[e]);return V.default.createElement(Dt,{open:!!e,anchor:s,onClose:t,label:e?L(a.filterTitle,{field:Q(e.field,a.core)}):"",className:"pk-filter-popover",fill:!0},e?V.default.createElement(ha,{key:e.field,view:n,base:e.base,field:e.field,encoded:o,locale:r,labels:a,commit:l,close:t}):null)}function lt({id:e,name:t,tabIndex:n}){let{explain:o,labels:r}=(0,Ge.useContext)(rt),a=r&&r.settingInfo&&Object.hasOwn(r.settingInfo,e)?r.settingInfo[e]:null;return!o||!r||!a?null:Ge.default.createElement(_t,{info:{description:a},name:t,label:L(r.aboutSetting,{setting:t}),labels:r,className:"pk-setting-info",testId:`setting-info-${e}`,tabIndex:n})}function Qe({title:e,children:t,info:n}){let o=typeof e=="string"?e:"";return Ge.default.createElement(gt,{title:e,head:n?Ge.default.createElement(lt,{id:n,name:o}):null},t)}var po=Object.freeze(["number","number:0","number:2","currency","percent"].filter(Me)),fo=Object.freeze(["integer","compact","bytes","duration:h","duration:s"].filter(Me)),ho=H.showAs.filter(e=>["percentOfGrandTotal","percentOfRowTotal","percentOfColumnTotal"].includes(e)),go=Object.freeze({percent:.256,bytes:1536e3,"duration:h":1.5,"duration:s":3725}),cn=Object.freeze([3,5,10]);function gn(e,t,n,o,r,a,l,s){let i=u=>({step:"moved",field:a,zone:u}),d=Wn.filter(u=>u!==t).map(u=>({id:`move-${u}`,text:L(r.moveTo,{zone:r.zones[u]}),icon:"chevronRight",closes:!0,change:()=>({view:Gn(e,t,n,u,void 0,{type:l,defaults:u==="values"?s:void 0}),note:i(u)})}));return t!=="filters"&&n>0&&d.push({id:"move-left",text:r.moveLeft,icon:"chevronRight",closes:!0,change:()=>({view:Ht(e,t,n,n-1),note:{step:"reordered",zone:t}})}),t!=="filters"&&n<o-1&&d.push({id:"move-right",text:r.moveRight,icon:"chevronRight",closes:!0,change:()=>({view:Ht(e,t,n,n+1),note:{step:"reordered",zone:t}})}),{id:"move",title:r.moveToTitle,kind:"menu",icon:"swap",groups:[{choices:d}]}}function ga({view:e,zone:t,index:n,field:o,types:r,labels:a,locale:l,state:s,defaultsOf:i,encoded:d}){let u=Re(e,o),c=Q(o,a.core),p=r.get(u.toLowerCase()),h=p==="date",g=vt(e,o),f=Yn(e,o),N=R=>R.toLocaleString(l,{maximumFractionDigits:6}),w=Oo(ln(e,R=>r.get(R.toLowerCase())),f?.by==="value"?f.value:null),v=u===o?i?.(u)?.order:void 0,S=Array.isArray(v)&&v.length>0,C=f?.by==="custom"?f.items:S?v:null,x=(R,y,M)=>f?f.by===R&&f.order===y&&(R!=="value"||ze(f.value,M)):R==="label"&&y==="asc",O=(R,y,M,q,U,ee)=>({id:`sort-${R}`,text:y,icon:ee,checked:x(M,q,U),change:()=>{let K=M==="value"?{by:M,order:q,value:U}:M==="custom"?{by:M,order:q,items:[...C]}:{by:M,order:q};return{view:Qn(e,o,Xn(K,S)),note:{step:"sort",field:c}}}}),B=w.flatMap((R,y)=>{let M=_e(e,R,a);return[O(`value-desc-${y}`,L(a.sortValueDesc,{value:M}),"value","desc",R,"sortDesc"),O(`value-asc-${y}`,L(a.sortValueAsc,{value:M}),"value","asc",R,"sortAsc")]});C&&B.push(O("custom",a.sortCustom,"custom","asc",null,"sortAsc"),O("custom-desc",a.sortCustomDesc,"custom","desc",null,"sortDesc"));let E=f&&f.by!=="label"?Jn(e,f,a):null,A=[{id:"sort",title:a.sort,kind:"segmented",icon:"sortAsc",state:E,changed:!!E,groups:[{choices:[O("label-asc",h?a.sortOldestShort:a.sortLabelAsc,"label","asc",null),O("label-desc",h?a.sortNewestShort:a.sortLabelDesc,"label","desc",null)]}]},{id:"sortValue",title:a.sortByValue,kind:B.length<=2?"inline":"menu",icon:"sortDesc",state:E,changed:!!E,groups:[{choices:B}]},$o({view:e,field:o,labels:a,locale:l,state:s,encoded:d})];if(h){let R=M=>()=>{let q=Q(u,a.core),U=M?Kt(q,M,a):null;return{view:Gt(e,o,M,{name:U??void 0}).view,note:{step:"group",field:q}}},y=M=>({id:`group-${M}`,text:a.units[M]??M,hint:a.unitHints[M]||void 0,checked:g?.by===M,closes:!0,change:R(M)});A.push({id:"group",title:a.groupTopic,kind:"menu",icon:"date",state:g?a.units[g.by]??g.by:a.groupNoneShort,changed:!!g,groups:[{title:a.groupTimeline,choices:H.timelineUnits.map(y)},{title:a.groupCyclic,choices:H.cyclicUnits.map(y)},{choices:[{id:"group-none",text:a.groupNone,checked:!g,closes:!0,change:R(null)}]}]})}else if(p==="number"){let R=g?.by==="bin"?g:null;A.push({id:"bins",title:a.bins,kind:"panel",icon:"number",state:R?L(a.binsState,{size:N(R.size),start:N(R.origin??0)}):a.off,changed:!!R})}let I=fe(e,o,["top"])[0],D=I?.by??ln(e,R=>r.get(R.toLowerCase()))[0];return A.push({id:"top",title:a.topN,kind:"panel",icon:"top",state:I?ya(e,I,a,l):a.off,changed:!!I,searchExtra:cn.map(R=>({id:`top-${R}`,text:L(a.topBadge,{count:R.toLocaleString(l)}),choice:{id:`top-${R}`,text:L(a.topBadge,{count:R.toLocaleString(l)}),checked:!!(I&&!I.bottom&&I.count===R),change:()=>({view:xo(e,o,{count:R,bottom:!1,by:D},I),note:{step:"top",field:c}})}}))}),A.push(gn(e,t,n,e[t].length,a,c,p,i?.(o))),A}var ka=/\d+/;function $o({view:e,field:t,labels:n,locale:o,state:r,encoded:a}){let s={step:"filter",field:Q(t,n.core)},i=fa(e,t,r,n,o),d=a?So(a,e,t):null,u=a?.timeZone??"UTC",c=h=>h.charAt(0).toLocaleUpperCase(o)+h.slice(1),p=d?.quick?h=>{let g=Number(ka.exec(h)?.[0]);if(!Number.isSafeInteger(g)||g<1)return[];let f=g>H.relativeMaxCount?[]:d.months?["year","month"]:["year"],N=fe(e,t,["relative"])[0]?.anchor,w=Wt(a,Re(e,t)),v=f.map(x=>{let O=c(Ut({unit:x,count:g,anchor:N},n,o,u,void 0,w));return{id:`quick-${x}-${g}`,text:O,choice:{id:`quick-${x}-${g}`,text:O,change:()=>({view:Lo(e,t,{unit:x,count:g,anchor:N}),note:s})}}});return d.item==="group"&&g>=1e3&&g<=9999&&e.derived.some(x=>x.name.toLowerCase()===t.toLowerCase()&&x.by==="year")?[...[">=","<=","<",">"].map(x=>{let O={field:t,type:"compare",op:x,value:g},B=c(L(n.compareShort[x],{value:String(g)}));return{id:`compare-${x}-${g}`,text:B,choice:{id:`compare-${x}-${g}`,text:B,change:()=>({view:We(e,t,null,O),note:s})}}}),...v]:v}:void 0;return{id:"filter",title:n.filterTopic,kind:"panel",icon:"filter",state:i??n.filterAll,changed:i!==null,keywords:n.filterKeywords,searchExtra:[{id:"open-filter-rules",text:n.rulesTitle,focus:"conditions"},{id:"open-filter-text",text:n.addRuleName,focus:"conditions"},{id:"open-filter-value",text:n.addRuleTotal,focus:"conditions"}],searchFor:p}}function va({view:e,index:t,field:n,types:o,labels:r,locale:a,state:l,encoded:s}){let i=o.get(Re(e,n).toLowerCase());return[$o({view:e,field:n,labels:r,locale:a,state:l,encoded:s}),gn(e,"filters",t,kt(e).length,r,Q(n,r.core),i)]}function ya(e,t,n,o){let r=t.by??(e.values?.[0]?{field:e.values[0].field??null,agg:e.values[0].agg}:null);return`${L(t.bottom?n.bottomBadge:n.topBadge,{count:t.count.toLocaleString(o)})} ${L(n.by,{value:_e(e,r,n)})}`}function wa(e,t,n){if(Object.hasOwn(t.formats,e))return t.formats[e];let o=/^number:(\d+)$/.exec(e);if(o)return W(t.formatDecimals,Number(o[1]),{lang:t.lang,locale:n});let r=e.split(":")[0];return Object.hasOwn(t.formats,r)?t.formats[r]:e}function Ea({view:e,index:t,types:n,labels:o,locale:r,defaultsOf:a,earlier:l}){let s=e.values[t],i=s.field?n.get(s.field.toLowerCase())??"string":"number",d=s.field?a?.(s.field):void 0,u=ot(s,o),c=N=>()=>({view:rn(e,t,N,{defaults:d}),note:{step:"value",field:u}}),p=s.field?In(i):["count"],h=N=>({id:`agg-${N}`,text:o.core.aggregators[N]??N,checked:s.agg===N,closes:!0,change:c({agg:N})}),g=p.filter(N=>!H.commonAggregators.includes(N)),f=[{id:"summarize",title:o.aggregation,kind:"menu",icon:"sigma",state:o.core.aggregators[s.agg]??s.agg,groups:[{choices:H.commonAggregators.filter(N=>p.includes(N)).map(h)},...g.length?[{title:o.moreStatistics,choices:g.map(h)}]:[]]}];if(Yt(s,i)){let N=E=>{let A=o.showAsNames[E]??E;return{id:`showas-${E}`,text:A,keywords:A.includes("%")?o.showAsKeywords:void 0,checked:s.showAs?.type===E,change:c({showAs:{type:E,axis:s.showAs?.axis??"rows"}})}},w=s.showAs&&H.showAsAlongAxis.includes(s.showAs.type)?s.showAs:null;f.push({id:"showAs",title:o.showAs,kind:"menu",info:"showAs",icon:"table",state:s.showAs?o.showAsNames[s.showAs.type]??s.showAs.type:o.showAsNone,changed:!!s.showAs,groups:[{choices:[{id:"showas-none",text:o.showAsNone,checked:!s.showAs,change:c({showAs:null})},...ho.map(N)]},{title:o.moreCalculations,choices:H.showAs.filter(E=>!ho.includes(E)).map(N)},...w?[{title:o.along,choices:["rows","cols"].map(E=>({id:`along-${E}`,text:o.zones[E],checked:w.axis===E,change:c({showAs:{...w,axis:E}})}))}]:[]]});let v=E=>Be(E,{locale:r})(Object.hasOwn(go,E)?go[E]:1234.5),S=E=>({id:`format-${E}`,text:o.formats[E]??E,hint:v(E),checked:s.format===E,change:c({format:E})}),C=s.format?wa(s.format,o,r):o.formatAuto,x=!s.format||po.includes(s.format)||fo.includes(s.format);f.push({id:"format",title:o.format,kind:"menu",icon:"number",state:C,changed:!!s.format&&s.format!==d?.format,groups:[{choices:[...x?[]:[{id:"format-current",text:C,checked:!0,change:c({format:s.format})}],{id:"format-auto",text:o.formatAuto,checked:!s.format,change:c({format:null})},...po.map(S)]},{title:o.moreFormats,choices:fo.map(S)}]});let O=E=>{let A=I=>I.agg===s.agg&&(I.field??null)===(s.field??null);for(let I of[e,...[...l?.()??[]].reverse()]){let D=(I.values??[]).find(A)?.conditional;if(D?.type===E)return D}return E==="colorScale"?{type:E}:{type:E,color:null}},B=(E,A,I)=>{let D=(s.conditional?.type??null)===I;return{id:E,text:A,checked:D,change:D?()=>null:c({conditional:I?O(I):null})}};f.push({id:"highlight",title:o.conditional,kind:"segmented",icon:"sparkle",changed:!!s.conditional,groups:[{choices:[B("cond-none",o.conditionalNone,null),B("cond-colorScale",o.colorScale,"colorScale"),B("cond-dataBar",o.dataBar,"dataBar")]}]})}return f.push({id:"name",title:o.rename,kind:"panel",icon:"text",state:u,changed:!!s.label,keywords:o.nameKeywords}),f.push(gn(e,"values",t,e.values.length,o,u,i)),f}function ba({view:e,labels:t,folding:n,tips:o,explanations:r,act:a}){let l=[];return o.controls&&l.push({id:"show-tips",text:t.showTips,checkbox:!0,checked:o.on,run:()=>a.tipsOn(!o.on)}),r&&l.push({id:"show-explanations",text:t.showSettingInfo,checkbox:!0,checked:r.on,run:()=>a.explain(!r.on)}),o.controls&&l.push({id:"reset-tips",text:t.resetTips,icon:"reset",disabled:!o.canReset,run:a.resetTips}),[{id:"totals",title:t.totals,kind:"inline",titled:!0,groups:[{choices:da.map(s=>{let i=pa(e,s);return{id:`total-${s}`,text:t[s],checkbox:!0,checked:e.totals[s],disabled:i!==null,reason:i?t[i]:void 0,info:s,run:()=>a.total(s,!e.totals[s])}})}]},{id:"rows",title:t.zones.rows,kind:"inline",titled:!0,groups:[{choices:[{id:"expand-all",text:t.expandAll,icon:"plus",closes:!0,disabled:!n.canExpand,reason:n.why.expand?t[n.why.expand]:void 0,run:a.expand},{id:"collapse-all",text:t.collapseAll,icon:"chevronRight",closes:!0,disabled:!n.canCollapse,reason:n.why.collapse?t[n.why.collapse]:void 0,run:a.collapse}]}]},{id:"help",title:t.help,kind:"inline",titled:!0,groups:[{choices:l}]},{id:"shortcuts",title:t.shortcutsTitle,kind:"panel",icon:"info"}]}function Na(e){let t=new Map;return e.map(n=>{let o=`${n.scope}:${n.name}`;return t.set(o,(t.get(o)??0)+1),`entry:${o}:${t.get(o)}`})}var xa=(e,t)=>e[t+1]??e[t-1];function Sa(e,t=""){return e.flatMap(n=>{if(n.hidden)return[];let r=[...t&&n.searchFor?n.searchFor(t):[],...n.searchExtra??[]].map(a=>({id:a.id,text:a.text,path:n.title,topic:n,choice:a.choice,focus:a.focus}));return n.kind==="panel"?[{id:`open-${n.id}`,text:n.title,path:"",topic:n},...r]:(n.groups??[]).flatMap(a=>a.choices.map(l=>({id:l.id,text:l.text,path:[n.title,a.title].filter(Boolean).join(" \u203A "),topic:n,choice:l})))})}var Ca=8;function Ta(e,t,n){let o=i=>i.toLocaleLowerCase(n),r=o(t).split(/\s+/).filter(Boolean);if(!r.length)return[];let a=e.filter(i=>{let d=o(`${i.text} ${i.path} ${i.topic.keywords??""} ${i.choice?.keywords??""}`);return r.every(u=>d.includes(u))}),l=i=>o(i.choice?.keywords??"").split(/\s+/).includes(r[0]),s=i=>l(i)?0:o(i.text).startsWith(r[0])?1:2;return[0,1,2].flatMap(i=>a.filter(d=>s(d)===i)).slice(0,Ca)}var Ro=(e,t,n,o)=>`${e}${t?`, ${t}`:""}${n?o:""}`;function La(e,t,n){if(n===0)return null;switch(e){case"ArrowDown":return(t+1)%n;case"ArrowUp":return t<=0?n-1:t-1;case"Home":return 0;case"End":return n-1;default:return null}}function Oa(e,t,n,o){let r=n.toLocaleLowerCase(o),a=n.length>1?t:t+1;for(let l=0;l<e.length;l++){let s=(Math.max(0,a)+l)%e.length;if(e[s].trim().toLocaleLowerCase(o).startsWith(r))return s}return null}var bt='[role="menuitem"], [role="menuitemradio"], [role="menuitemcheckbox"]';function wt(e){return[...e.querySelectorAll(bt)].filter(t=>t.closest('[role="menu"]')===e&&t.getClientRects().length>0)}function Aa(e){let t=e.closest(".pk-popover")?.id;return t?Cn(e)?.querySelector(`[aria-controls="${CSS.escape(t)}"]`)??null:null}function Ia(e,t){if(e.key!=="Tab"||e.shiftKey)return!1;let n=Aa(e.target),o=n?Tn(n):null;return e.preventDefault(),o?.focus(),n&&(!o||Je(o)!==o)&&n.focus({preventScroll:!0}),t(),!0}function un({label:e,labelledBy:t,className:n,close:o,children:r,testId:a}){let l=(0,b.useRef)(null),s=(0,b.useRef)(null),i=(0,b.useRef)({text:"",at:0});(0,b.useLayoutEffect)(()=>{let c=l.current;if(!c)return;let p=wt(c),h=p.find(g=>g.dataset.pkItem===s.current)??p.find(g=>g.hasAttribute("data-pk-start"))??p[0];for(let g of p)g.tabIndex=g===h?0:-1});let d=c=>{let p=c.target.closest?.(bt);if(p&&l.current&&p.closest('[role="menu"]')===l.current){s.current=p.dataset.pkItem??null;for(let h of wt(l.current))h.tabIndex=h===p?0:-1}},u=c=>{let p=l.current;if(!p||c.target.closest('[role="menu"]')!==p||c.altKey||c.ctrlKey||c.metaKey||Ia(c,o))return;let h=wt(p),g=h.indexOf(Je(p)),f=S=>{S!==null&&h[S]&&(c.preventDefault(),c.stopPropagation(),h[S].focus())},N=c.target.closest("[data-pk-seg]");if(N&&(c.key==="ArrowLeft"||c.key==="ArrowRight")){let S=wt(p).filter(x=>N.contains(x)),C=S.indexOf(c.target)+(c.key==="ArrowRight"?1:-1);C>=0&&C<S.length?(c.preventDefault(),c.stopPropagation(),S[C].focus()):c.key==="ArrowRight"&&(c.preventDefault(),c.stopPropagation());return}let w=c.target.closest("[data-pk-level]");if(w&&(c.key==="ArrowRight"||c.key==="Enter"||c.key===" ")){c.preventDefault(),c.stopPropagation(),w.click();return}let v=La(c.key,g,h.length);if(v!==null){f(v);return}if(c.key.length===1&&c.key!==" "){let S=Date.now();i.current={text:S-i.current.at<600?i.current.text+c.key:c.key,at:S},f(Oa(h.map(C=>C.dataset.pkText??C.textContent??""),g,i.current.text))}};return b.default.createElement("div",{ref:l,role:"menu","aria-label":e,"aria-labelledby":t,className:`pk-level-menu${n?` ${n}`:""}`,onKeyDown:u,onFocus:d,"data-testid":a},r)}function Ct({id:e,text:t,onSelect:n,checked:o,checkbox:r,hint:a,icon:l,danger:s,testId:i,start:d,plain:u,label:c,className:p,disabled:h,reason:g,haspopup:f,level:N,description:w,current:v,children:S}){let C=o===void 0?"menuitem":r?"menuitemcheckbox":"menuitemradio",x=(0,b.useId)(),O=[h&&g?x:null,w?`${x}-d`:null].filter(Boolean).join(" ")||void 0;return b.default.createElement("button",{type:"button",role:C,"aria-checked":o===void 0?void 0:o,"aria-label":c,"aria-haspopup":f,"aria-disabled":h||void 0,"aria-describedby":O,"aria-current":v?"true":void 0,tabIndex:-1,className:`pk-option${o?" pk-checked":""}${s?" pk-danger":""}${h?" pk-disabled":""}${p?` ${p}`:""}`,"data-pk-option":"","data-pk-item":e,"data-pk-text":u??(typeof t=="string"?t:void 0),"data-pk-start":d?"":void 0,"data-pk-level":N,"data-testid":i??e,onClick:h?void 0:n},b.default.createElement("span",{className:"pk-option-icon"},o||v?b.default.createElement(X,{name:"check"}):l?b.default.createElement(X,{name:l}):null),b.default.createElement("span",{className:"pk-option-text"},t,h&&g?b.default.createElement("span",{id:x,className:"pk-option-hint","data-testid":`${i??e}-reason`},g):null),a?b.default.createElement("span",{className:"pk-item-hint"},a):null,w?b.default.createElement("span",{id:`${x}-d`,hidden:!0},w):null,S)}function Fo({choice:e,onPick:t,start:n}){let{explain:o,labels:r}=(0,b.useContext)(rt),a=e.info&&o&&r?.settingInfo&&Object.hasOwn(r.settingInfo,e.info)?r.settingInfo[e.info]:null,l=b.default.createElement(Ct,{id:e.id,testId:e.testId,text:e.text,hint:e.hint,icon:e.icon,checked:e.checked,checkbox:e.checkbox,current:e.current,disabled:e.disabled,reason:e.reason,description:a,start:n,haspopup:e.open?"dialog":void 0,className:e.open?"pk-topic-row":void 0,onSelect:()=>t(e)},e.open?b.default.createElement(X,{name:"chevronRight",size:16,className:"pk-topic-chevron"}):null);return!a&&!e.actions?.length?l:b.default.createElement("div",{role:"none",className:"pk-setting-row"},l,(e.actions??[]).map(s=>b.default.createElement("button",{key:s.id,type:"button",role:"menuitem",tabIndex:-1,className:"pk-icon-btn","aria-label":s.label,title:s.label,"aria-haspopup":s.open?"dialog":void 0,"data-pk-item":s.id,"data-pk-text":s.label,"data-testid":s.testId??s.id,onClick:()=>t(s)},b.default.createElement(X,{name:s.icon}))),a?b.default.createElement("span",{"aria-hidden":"true"},b.default.createElement(lt,{id:e.info,name:e.text,tabIndex:-1})):null)}function $a({topic:e,labels:t,onOpen:n}){return b.default.createElement(Ct,{id:`topic-${e.id}`,level:e.id,text:e.title,plain:e.title,icon:e.icon,label:Ro(e.title,e.state,e.changed,t.sectionChanged),haspopup:e.kind==="menu"?"menu":"dialog",className:"pk-topic-row",onSelect:n},e.state?b.default.createElement("span",{className:"pk-topic-state","data-testid":`topic-state-${e.id}`},e.changed?b.default.createElement("span",{className:"pk-section-mark","aria-hidden":"true"},"\u25CF "):null,b.default.createElement("span",{className:"pk-badge-cut"},e.state)):null,b.default.createElement(X,{name:"chevronRight",size:16,className:"pk-topic-chevron"}))}function Ra({topic:e,onPick:t}){return b.default.createElement(b.default.Fragment,null,(e.groups??[]).map((n,o)=>b.default.createElement(gt,{key:o,menu:!0,title:n.title,label:n.title?void 0:e.title},n.choices.map(r=>b.default.createElement(Fo,{key:r.id,choice:r,start:r.checked,onPick:t})))),b.default.createElement(mn,{topic:e}))}function mn({topic:e}){return e.note?b.default.createElement("p",{className:"pk-hint pk-menu-hint",role:"none","data-testid":e.noteId},e.note):null}function Fa({topic:e,labels:t,onPick:n,onOpen:o}){if(e.hidden)return null;if(e.kind==="menu"||e.kind==="panel")return b.default.createElement($a,{topic:e,labels:t,onOpen:o});let r=e.groups?.[0]?.choices??[];if(e.kind==="segmented")return b.default.createElement("div",{role:"group","aria-label":Ro(e.title,e.state,e.changed,t.sectionChanged),className:"pk-topic-seg","data-pk-seg":"","data-testid":`topic-${e.id}`},b.default.createElement("span",{className:"pk-topic-seg-title","aria-hidden":"true"},b.default.createElement("span",{className:"pk-option-icon"},e.icon?b.default.createElement(X,{name:e.icon}):null),e.title,e.changed&&!e.state?b.default.createElement("span",{className:"pk-section-mark"}," \u25CF"):null),e.state?b.default.createElement("span",{className:"pk-topic-state pk-topic-seg-state","data-testid":`topic-state-${e.id}`},e.changed?b.default.createElement("span",{className:"pk-section-mark","aria-hidden":"true"},"\u25CF "):null,b.default.createElement("span",{className:"pk-badge-cut"},e.state)):null,b.default.createElement("span",{className:"pk-segmented pk-small"},r.map(l=>b.default.createElement("button",{key:l.id,type:"button",role:"menuitemradio","aria-checked":!!l.checked,tabIndex:-1,"data-pk-option":"","data-pk-item":l.id,"data-pk-text":l.text,"data-testid":l.id,onClick:()=>n(l)},l.text))));let a=r.map(l=>b.default.createElement(Fo,{key:l.id,choice:l,onPick:n}));return e.titled?b.default.createElement(gt,{menu:!0,title:e.title,testId:`topic-${e.id}`,titleTestId:`topic-title-${e.id}`,after:b.default.createElement(mn,{topic:e})},a):b.default.createElement(b.default.Fragment,null,b.default.createElement("div",{role:"group","aria-label":e.title,"data-testid":`topic-${e.id}`},a),b.default.createElement(mn,{topic:e}))}function Da({hits:e,labels:t,onPick:n,onOpen:o,close:r}){return e.length?b.default.createElement(un,{label:t.searchResults,close:r,testId:"menu-search-hits"},e.map(a=>b.default.createElement(Ct,{key:a.id,id:`hit-${a.id}`,text:a.choice?a.text:`${a.text}\u2026`,plain:a.text,checked:a.choice?.checked,icon:a.choice?a.topic.icon:"chevronRight",hint:a.path||void 0,haspopup:a.choice?void 0:"dialog",onSelect:()=>a.choice?n(a.choice):o(a.topic.id,void 0,a.focus)}))):b.default.createElement("p",{className:"pk-hint pk-level-nothing",role:"status","data-testid":"menu-search-nothing"},t.searchNothing)}function it({name:e,labels:t,topics:n,close:o,onPick:r,panel:a,head:l,foot:s,search:i=!1,locale:d,focusAgain:u}){let[c,p]=(0,b.useState)({stack:[],focus:null}),h=c.stack.length?c.stack[c.stack.length-1].level:null,[g,f]=(0,b.useState)(""),N=(0,b.useRef)(null),w=(0,b.useId)(),v=h?n.find(E=>E.id===h)??null:null;(0,b.useLayoutEffect)(()=>{let E=N.current,A=c.focus;if(!E||!A)return;let I=A.indexOf(":"),[D,R]=[A.slice(0,I),A.slice(I+1)],y=A==="level"?E.querySelector(".pk-level-body [data-autofocus]")??E.querySelector('.pk-level-body [role="menuitemradio"][aria-checked="true"]')??E.querySelector(".pk-level-body :is(button, input, select):not([disabled])")??E.querySelector(".pk-level-back"):A==="search"?E.querySelector(".pk-level-search input"):E.querySelector(D==="row"?`[data-pk-level="${CSS.escape(R)}"]`:`[data-pk-item="${CSS.escape(R)}"]`)??E.querySelector(bt);y?.focus({preventScroll:!0}),y?.scrollIntoView?.({block:"nearest"})},[c,u]);let S=(E,A=`row:${E}`,I=void 0)=>{f(""),p({stack:[...c.stack,{level:E,from:A,hint:I}],focus:"level"})},C=(E=void 0)=>{let A=c.stack[c.stack.length-1];p({stack:c.stack.slice(0,-1),focus:E??A?.from??null})},x=E=>{if(E.open){E.run?.(),S(E.open,E.backTo??`item:${E.id}`);return}E.closes||(p({stack:[],focus:g?"search":c.stack.length?c.stack[0].from:`item:${E.id}`}),f("")),r(E)},O=E=>{if(E.defaultPrevented)return;let A=E.target,I=A.matches("input:not([type=checkbox], [type=radio]), textarea, select");if(E.key==="/"&&i&&!h&&!I){E.preventDefault(),N.current?.querySelector(".pk-level-search input")?.focus();return}h&&(E.key==="Escape"||E.key==="ArrowLeft"&&!I&&!A.closest("[data-pk-seg], .pk-segmented"))&&(E.preventDefault(),E.stopPropagation(),C())},B=()=>{let E=i&&g.trim()?Ta(Sa(n,g),g,d):null;return b.default.createElement(b.default.Fragment,null,l,i?b.default.createElement("label",{className:"pk-search pk-level-search"},b.default.createElement(X,{name:"search"}),b.default.createElement("span",{className:"pk-sr"},L(t.searchMenu,{name:e})),b.default.createElement(Ee,{type:"search",value:g,placeholder:t.searchMenuShort,onChange:f,clearLabel:t.clearText,"aria-label":L(t.searchMenu,{name:e}),autoComplete:"off","data-testid":"menu-search",onKeyDown:A=>{A.key==="ArrowDown"?(A.preventDefault(),N.current?.querySelector(`.pk-level-first ${bt}`)?.focus()):A.key==="Enter"&&A.preventDefault()}})):null,b.default.createElement("div",{className:"pk-level-first"},E?b.default.createElement(Da,{hits:E,labels:t,onPick:x,onOpen:S,close:o}):b.default.createElement(un,{label:e,close:o,testId:"level-first"},n.map(A=>b.default.createElement(Fa,{key:A.id,topic:A,labels:t,onPick:x,onOpen:()=>S(A.id)})),s?b.default.createElement(b.default.Fragment,null,b.default.createElement("div",{role:"separator",className:"pk-level-sep"}),s):null)))};return b.default.createElement("div",{ref:N,className:"pk-levels",onKeyDown:O,"data-level":h??""},v?b.default.createElement(b.default.Fragment,null,b.default.createElement("div",{className:"pk-level-head"},b.default.createElement("button",{type:"button",className:"pk-link pk-level-back",onClick:()=>C(),"aria-label":L(t.backTo,{name:e}),"data-testid":"level-back"},b.default.createElement(X,{name:"chevronRight",size:16,className:"pk-flip"}),t.back),b.default.createElement("h3",{id:w,className:"pk-level-title","data-testid":"level-title"},L(t.levelTitle,{name:e,topic:v.levelTitle??v.title})),v.info?b.default.createElement(lt,{id:v.info,name:v.title}):null),b.default.createElement("div",{className:"pk-level-body","data-testid":`level-${v.id}`},v.kind==="menu"?b.default.createElement(un,{labelledBy:w,close:o},b.default.createElement(Ra,{topic:v,onPick:x})):b.default.createElement("div",{role:"group","aria-labelledby":w,className:"pk-level-panel"},a(v.id,C,c.stack[c.stack.length-1]?.hint)))):B())}function ct(e=450){let t=(0,b.useRef)(null),n=(0,b.useRef)(null),o=()=>{t.current&&clearTimeout(t.current),t.current=null,n.current=null},r=()=>{let l=n.current;o(),l?.()},a=(0,b.useRef)(r);return(0,b.useEffect)(()=>{a.current=r}),(0,b.useEffect)(()=>()=>a.current(),[]),{later:l=>{o(),n.current=l,t.current=setTimeout(r,e)},now:r,cancel:o}}function Do(e,t,n=450){let[o,r]=(0,b.useState)(e),[a,l]=(0,b.useState)(e);e!==a&&(l(e),o===a&&r(e));let s=(0,b.useRef)({text:o,seen:a,apply:t});(0,b.useEffect)(()=>{s.current={...s.current,seen:a,apply:t}});let i=ct(n),d=()=>{i.cancel(),s.current.text!==s.current.seen&&(s.current.seen=s.current.text,s.current.apply(s.current.text))},u=(0,b.useRef)(d);return(0,b.useEffect)(()=>{u.current=d}),(0,b.useEffect)(()=>()=>u.current(),[]),{text:o,set:c=>{s.current.text=c,r(c),n>0&&i.later(d)},flush:d,restore:()=>(i.cancel(),s.current.text===s.current.seen?!1:(s.current.text=s.current.seen,r(s.current.seen),!0))}}var ko=new Map;function Ma(e){let t=ko.get(e);if(!t){let n;try{n=new Intl.NumberFormat(e).formatToParts(12345.6)}catch{n=new Intl.NumberFormat("en-US").formatToParts(12345.6)}t={decimal:n.find(o=>o.type==="decimal")?.value??".",group:n.find(o=>o.type==="group")?.value??","},ko.set(e,t)}return t}var vo=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Ba=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i;function Nt(e,t){let n=String(e??"").replace(/[\s\u00a0\u202f]/g,"").replace(/\u2212/g,"-");if(n==="")return null;let{decimal:o,group:r}=Ma(t),a=/[\s\u00a0\u202f]/.test(r)?"":vo(r),l=vo(o),s=a?`\\d{1,3}(?:${a}\\d{3})+`:"(?!)",d=new RegExp(`^([+-]?)(${s}|\\d+)?(?:${l}(\\d+))?$`).exec(n);if(d&&(d[2]!==void 0||d[3]!==void 0)){let u=(d[2]??"0").split(r).join(""),c=+`${d[1]}${u}${d[3]!==void 0?`.${d[3]}`:""}`;return Number.isFinite(c)?c:null}if(Ba.test(n)){let u=Number(n);return Number.isFinite(u)?u:null}return null}function ce(e,t){if(typeof e!="number"||!Number.isFinite(e))return"";try{return e.toLocaleString(t,{useGrouping:!1,maximumFractionDigits:20})}catch{return String(e)}}function Ne(e,{kind:t="number",required:n=!0,tried:o=!1,max:r,labels:a,locale:l}){let s=Nt(e,l);if(r!==void 0&&s!==null&&Number.isInteger(s)&&s>r)return{value:null,problem:L(a.countMax,{max:r.toLocaleString(l)})};let i=s!==null&&(t==="number"||(t==="size"?s>0:Number.isInteger(s)&&s>=1)),d=()=>t==="count"?a.countInvalid:L(t==="size"?a.sizeInvalid:a.numberInvalid,{example:(t==="size"?.5:1234.5).toLocaleString(l)});return e.trim()===""?{value:null,problem:n&&o?d():null}:i?{value:s,problem:null}:{value:null,problem:d()}}function Ye({value:e,onChange:t,problem:n,label:o,testId:r,className:a="pk-field-label",shown:l,shownClass:s,onKeyDown:i,onBlur:d,onFocus:u,autoFocus:c}){let p=(0,oe.useId)(),h=ie();return oe.default.createElement(oe.default.Fragment,null,oe.default.createElement("label",{className:a},l?oe.default.createElement("span",{className:s},l):oe.default.createElement("span",{className:"pk-sr"},o),oe.default.createElement("input",{type:"text",name:h,inputMode:"decimal",autoComplete:"off",spellCheck:!1,value:e,onChange:g=>t(g.target.value),onKeyDown:i,onBlur:d,onFocus:u,"aria-label":o,"aria-invalid":n?!0:void 0,"aria-describedby":n?p:void 0,"data-autofocus":c?"":void 0,"data-testid":r})),n?oe.default.createElement("p",{id:p,className:"pk-form-problem","data-testid":`${r}-problem`},n):null)}var Xe=({now:e,restore:t,back:n})=>o=>{o.key==="Enter"?(o.preventDefault(),e()):o.key==="Escape"&&(o.preventDefault(),o.stopPropagation(),t()||n())};function Mo({choices:e,names:t,index:n,onChange:o,label:r,prefix:a,testId:l}){let s=ie();return e.length<2?oe.default.createElement("span",{className:"pk-by","data-testid":l},a?`${a} ${t[0]}`:t[0]):oe.default.createElement("label",{className:"pk-field-label pk-by-pick"},a?oe.default.createElement("span",null,a):oe.default.createElement("span",{className:"pk-sr"},r),oe.default.createElement("select",{name:s,value:n,onChange:i=>o(Number(i.target.value)),"aria-label":r,"data-testid":l},e.map((i,d)=>oe.default.createElement("option",{key:`${i.field}:${i.agg}`,value:d},t[d]))))}var Bo=(e,t)=>Math.max(0,e.findIndex(n=>ze(n,t)));function Tt(e,t,n,o){let r=Oo(ln(e,a=>t.get(a.toLowerCase())),o);return{choices:r,names:r.map(a=>_e(e,a,n))}}var je=e=>e==="between"||e==="notBetween",Pa=(e,t)=>e.charAt(0).toLocaleUpperCase(t)+e.slice(1),yo=e=>JSON.stringify(e,(t,n)=>n&&typeof n=="object"&&!Array.isArray(n)?Object.fromEntries(Object.entries(n).sort(([o],[r])=>o<r?-1:1)):n),Va=e=>e.type==="value"?"total":e.type==="label"?"name":"item",Et=Object.freeze({year:10,month:24,day:90}),ja=13,qa=864e5;function Ua(e,t){let n=e.unit,o=n===null?e.item==="number"?"value":e.item==="date"?"date":"item":n==="bin"?"range":n==="day"?"day":n.replace(/^year(.)/,(r,a)=>a.toLowerCase());return Object.hasOwn(t.nouns,o)?t.nouns[o]:t.nouns.item}function Ja(e,t,n){let o=Date.parse(`${e.from}T00:00Z`),r=Date.parse(`${e.to}T00:00Z`)+qa,a=0;return t.dict.forEach((l,s)=>{typeof l=="number"&&l>=o&&l<r&&(a+=n[s])}),a}function Ka(e){let t=new Float64Array(e.dict.length);for(let n=0;n<e.codes.length;n++)e.codes[n]>=0&&t[e.codes[n]]++;return t}function _a(e,t){let n=new Map;return e.dict.forEach((o,r)=>{if(typeof o=="number"){let a=new Date(o).getUTCFullYear();n.set(a,(n.get(a)??0)+t[r])}}),[...n.entries()].sort((o,r)=>o[0]-r[0]).map(([o,r])=>({year:o,rows:r}))}function za({out:e,row:t,searching:n,labels:o,locale:r}){let[a,l]=(0,m.useState)(!1),s=(0,m.useId)(),i=a||n,d=(0,m.useRef)(null);return(0,m.useEffect)(()=>{a&&d.current?.firstElementChild?.scrollIntoView?.({block:"nearest"})},[a]),m.default.createElement("li",{className:"pk-values-tail"},m.default.createElement("button",{type:"button",className:"pk-tail-toggle","aria-expanded":i,"aria-controls":s,onClick:()=>l(!i),"data-testid":"tail-toggle"},m.default.createElement(X,{name:i?"chevronDown":"chevronRight",size:14}),m.default.createElement("span",null,L(W(o.tailOut,e.length,{lang:o.lang,locale:r}),{count:e.length.toLocaleString(r)}))),i?m.default.createElement("ul",{ref:d,id:s,role:"list",className:"pk-tail-list","data-testid":"tail-list"},e.slice(0,hn).map(t)):null)}function on({id:e,title:t,state:n,open:o,onToggle:r,action:a,children:l}){let s=(0,m.useId)();return m.default.createElement("section",{className:"pk-fsection","data-testid":`fsection-${e}`},m.default.createElement("div",{className:"pk-fsection-head"},m.default.createElement("button",{type:"button",className:"pk-fsection-toggle","aria-expanded":o,"aria-controls":s,onClick:r,"data-testid":`section-${e}`},m.default.createElement(X,{name:o?"chevronDown":"chevronRight",size:16}),m.default.createElement("span",{className:"pk-fsection-title"},t),n?m.default.createElement("span",{className:"pk-fsection-state"},n):null),a),o?m.default.createElement("div",{className:"pk-fsection-body",id:s,"data-testid":`${e}-body`},l):null)}function Ha({ctx:e,state:t}){let{labels:n,locale:o,view:r,field:a}=e,{shown:l,total:s,noun:i,unpicked:d,byQuick:u,byRules:c,byTotals:p,rows:h,rowsAll:g,span:f,yearsText:N,empty:w,quickWords:v}=t,S=E=>E.toLocaleString(o),C={lang:n.lang,locale:o},x=l===0?n.summaryNone:l===s?L(n.summaryAll,{total:S(s),noun:W(i,s,C)}):L(n.summarySome,{shown:S(l),total:S(s),noun:W(i,s,C)}),O=[];l===0&&w?O.push(w):(d&&O.push(L(n.summaryPicks,{count:S(d)})),u&&O.push(L(n.summaryQuick,{count:S(u),quick:v})),c&&O.push(L(W(n.summaryRules,t.itemRules,C),{items:S(c)})),p&&O.push(L(W(n.summaryTotals,t.totalRules,C),{items:S(p)})));let B=[L(n.summaryRows,{rows:S(h),total:S(g)})];return f&&B.push(L(n.summaryData,{range:`${we(Ae(f.min),o)} \u2013 ${we(Ae(f.max),o)}`})),N&&B.push(N),m.default.createElement("div",{className:"pk-filter-summary"},m.default.createElement("div",{className:`pk-summary-card${l===0?" pk-summary-empty":""}`,role:"status","data-testid":"filter-summary"},m.default.createElement("p",{className:"pk-summary-head","data-testid":"filter-summary-head"},x),m.default.createElement("p",{className:"pk-summary-why","data-testid":"filter-summary-why"},O.length?O.join(" \xB7 "):t.rules?n.summaryKept:v?L(n.summaryQuickOnly,{quick:v}):n.summaryOk),m.default.createElement("p",{className:"pk-summary-meta","data-testid":"filter-summary-meta"},B.join(" \xB7 ")),m.default.createElement("button",{type:"button",className:"pk-action pk-summary-reset",disabled:!t.canReset,onClick:()=>e.act(ua(r,a),"section-picks"),"data-testid":"filter-reset"},n.resetFilter)))}function Wa({ctx:e,quick:t,anchor:n,setAnchorLocal:o,span:r,column:a,counts:l}){let{view:s,field:i,labels:d,locale:u,fk:c,timeZone:p,commit:h,note:g,back:f}=e,N={lang:d.lang,locale:u},w=r.max,v=Ae(w),[S]=(0,m.useState)(()=>Date.now()),C=(F,_)=>jt({unit:F,count:_,anchor:n},p,S,w),x=F=>{for(let _=1;_<=Et[F];_++){let ue=C(F,_);if(ue&&ue.from<=v)return _}return null},O=(0,m.useMemo)(()=>({year:Math.max(2,x("year")??Et.year),month:x("month")??Et.month,day:x("day")??Et.day}),[n,w,p]),B={year:t.id==="years"?t.count:O.year,month:t.id==="months"?t.count:O.month,day:t.id==="days"?t.count:O.day},[E,A]=(0,m.useState)(()=>Object.fromEntries(Object.entries(B).map(([F,_])=>[F,ce(_,u)]))),[I,D]=(0,m.useState)(null),R=`${t.id}:${t.count??""}:${n}`,[y,M]=(0,m.useState)(R);if(R!==y){M(R);let F={...E};for(let _ of H.relativeUnits)_!==I&&(F[_]=ce(B[_],u));A(F)}let q=ct(),U=(0,m.useId)(),ee=ie(),K=F=>h(Lo(s,i,F?{...F,anchor:n}:null),g),j=(F,_,ue)=>{let te=_n(F,_,r,u);if(te?.none)return null;let pe=te?`${te.data} `:qt(F,_,u),Se=te?L(W(d.noData,te.count,N),{range:te.missing.join(", ")}):null;return m.default.createElement("span",{className:"pk-quick-sub",id:G(ue)},m.default.createElement("span",null,pe,Se?m.default.createElement("span",{className:"pk-quick-missing"},"(",Se,")"):null),m.default.createElement("span",{className:"pk-quick-rows"},L(d.quickRows,{rows:Ja(F,a,l).toLocaleString(u)})))},G=F=>`${U}-${F}`,Y=(F,_,ue,te,pe,Se,ne=!!Se)=>m.default.createElement("label",{className:"pk-radio pk-quick",key:F},m.default.createElement("input",{type:"radio",name:ee,checked:_,onChange:ue,"aria-label":te,"aria-describedby":ne?G(F):void 0,"data-autofocus":_&&e.hint!=="conditions"?"":void 0,"data-testid":`quick-${F}`}),pe,Se),he=[],xe=[Y("all",t.id==="all"||t.id==="custom",()=>K(null),d.filterAll,m.default.createElement("span",null,d.filterAll),m.default.createElement("span",{className:"pk-quick-sub",id:G("all")},m.default.createElement("span",null,`${we(Ae(r.min),u)}\u2013${we(v,u)}`),m.default.createElement("span",{className:"pk-quick-rows"},L(d.quickRows,{rows:a.codes.length.toLocaleString(u)}))))],ae=C("year",1),re=Pa(d.relative.year,u);ae&&j(ae,"year","thisYear")?xe.push(Y("thisYear",t.id==="thisYear",()=>K({unit:"year",count:1}),re,m.default.createElement("span",null,re),j(ae,"year","thisYear"))):ae&&he.push(`${re} (${qt(ae,"year",u)})`);for(let F of["year","month","day"]){if(F==="month"&&!c.months||F==="day"&&!c.days)continue;let _=Ne(E[F],{kind:"count",max:H.relativeMaxCount,labels:d,locale:u}),ue=_.value,te=`${F}s`,pe=ue??B[F],Se=Object.fromEntries(Object.entries(d.quickLast[F]).map(([ke,Te])=>[ke,String(Te).replace("{count}","{n}")])),ne=W(Se,pe,N),[le,ut]=ne.split("{n}"),Ce=C(F,pe),Ze=Ce?j(Ce,F,te):null;if(!Ze&&t.id!==te){he.push(L(ne,{n:pe.toLocaleString(u)}));continue}let et=()=>K({unit:F,count:pe});xe.push(m.default.createElement("div",{className:"pk-quick-row",key:F},Y(te,t.id===te,et,L(ne,{n:pe.toLocaleString(u)}),m.default.createElement("span",{"aria-hidden":"true"},le),null,!!Ze),m.default.createElement(Ye,{value:E[F],onChange:ke=>{A({...E,[F]:ke}),q.later(()=>{let Te=Ne(ke,{kind:"count",max:H.relativeMaxCount,labels:d,locale:u}).value;Te!==null&&K({unit:F,count:Te})})},onKeyDown:Xe({now:q.now,restore:()=>{q.cancel();let ke=ce(B[F],u);return E[F]===ke?!1:(A({...E,[F]:ke}),!0)},back:f}),onBlur:()=>{D(null),q.now()},onFocus:()=>D(F),problem:_.problem,label:d.quickCount[F],testId:`quick-${te}-count`,className:"pk-field-label pk-count-input"}),m.default.createElement("span",{"aria-hidden":"true"},ut),Ze))}let de=new Date(jt({unit:"day",count:1},p,S)?.from??Ae(S)),ge=c.months?Date.UTC(de.getUTCFullYear(),de.getUTCMonth(),1):Date.UTC(de.getUTCFullYear(),0,1),qe=w<ge,Ue=(0,m.useId)(),De=ie();return m.default.createElement(m.default.Fragment,null,m.default.createElement("div",{role:"radiogroup","aria-label":d.quickTitle,className:"pk-radios pk-quick-choices","data-testid":"quick-choices"},xe),qe?m.default.createElement("div",{className:"pk-quick-anchor"},m.default.createElement("label",{htmlFor:Ue},d.anchorLabel),m.default.createElement("select",{id:Ue,name:De,value:n,onChange:F=>{let _=F.target.value;o(_),t.filters.length&&h(ca(s,i,_),g)},"data-testid":"quick-anchor"},m.default.createElement("option",{value:"today"},L(d.anchorToday,{date:we(Ae(de.getTime()),u)})),m.default.createElement("option",{value:"latest"},L(d.anchorLatest,{date:we(v,u)})))):null,he.length?m.default.createElement("p",{className:"pk-hint pk-quick-hidden","data-testid":"quick-hidden"},L(W(d.quickHidden,he.length,N),{choices:he.join(", "),latest:we(v,u)})):null)}function Ga({ctx:e,years:t,on:n}){let{view:o,field:r,labels:a,locale:l,commit:s,note:i,noun:d}=e,u=t.map(p=>p.year),c=p=>{let h=n.includes(p)?n.filter(g=>g!==p):[...n,p].sort((g,f)=>g-f);s(ia(o,r,h,u),i)};return m.default.createElement(m.default.Fragment,null,m.default.createElement("p",{className:"pk-hint pk-years-hint"},L(a.yearsCombinedHint,{noun:W(d,1,{lang:a.lang,locale:l})})),m.default.createElement("div",{className:"pk-years",role:"group","aria-label":a.yearsCombined,"data-testid":"years-combined"},t.map(p=>{let h=n.includes(p.year);return m.default.createElement("button",{key:p.year,type:"button",className:"pk-year-chip","aria-pressed":h,disabled:h&&n.length===1,onClick:()=>c(p.year),"data-testid":`year-${p.year}`},h?m.default.createElement(X,{name:"check",size:12}):null,m.default.createElement("span",null,String(p.year)),m.default.createElement("span",{className:"pk-quick-rows"},L(a.quickRows,{rows:p.rows.toLocaleString(l)})))})),n.length===1?m.default.createElement("p",{className:"pk-hint"},L(a.yearsCombinedOne,{year:String(n[0])})):null)}function Qa({items:e,value:t,onChange:n,label:o,testId:r,labels:a,locale:l}){let[s,i]=(0,m.useState)(!1),[d,u]=(0,m.useState)(""),[c,p]=(0,m.useState)(0),h=(0,m.useRef)(null),g=(0,m.useId)(),f=ie(),N=d.trim().toLocaleLowerCase(),w=N?e.filter(A=>A.label.toLocaleLowerCase().includes(N)):e,v=w.slice(0,hn),S=e.find(A=>String(A.value)===t),C=()=>{u(""),p(Math.max(0,e.findIndex(A=>String(A.value)===t))),i(!0)},x=()=>i(!1),O=A=>{x(),n(String(A.value))},B=A=>`${g}-${A}`,E=A=>{A.key==="ArrowDown"||A.key==="ArrowUp"?(A.preventDefault(),p(I=>Math.min(v.length-1,Math.max(0,I+(A.key==="ArrowDown"?1:-1))))):A.key==="Enter"?(A.preventDefault(),v[c]&&O(v[c])):A.key==="Escape"&&(A.preventDefault(),A.stopPropagation(),x())};return m.default.createElement("span",{className:"pk-picker"},m.default.createElement("button",{ref:h,type:"button",className:"pk-picker-button","aria-haspopup":"listbox","aria-expanded":s,"aria-label":o,onClick:()=>s?x():C(),onKeyDown:A=>{!s&&(A.key==="ArrowDown"||A.key==="ArrowUp")&&(A.preventDefault(),C())},"data-testid":r},S?S.label:t||a.ruleValue),m.default.createElement(Dt,{open:s,anchor:h,onClose:x,label:o,className:"pk-picker-pop"},m.default.createElement("input",{type:"search",name:f,role:"combobox",className:"pk-picker-search",value:d,onChange:A=>{u(A.target.value),p(0)},onKeyDown:E,"aria-label":a.pickerSearch,"aria-expanded":"true","aria-controls":g,"aria-activedescendant":v[c]?B(c):void 0,"aria-autocomplete":"list",autoComplete:"off",placeholder:a.pickerSearch,"data-autofocus":"","data-testid":"picker-search"}),m.default.createElement("ul",{role:"listbox",id:g,className:"pk-picker-list","aria-label":o,"data-testid":"picker-list"},v.map((A,I)=>m.default.createElement("li",{key:String(A.value),id:B(I),role:"option","aria-selected":String(A.value)===t,className:`pk-picker-option${I===c?" pk-picker-active":""}`,onMouseMove:()=>p(I),onClick:()=>O(A),"data-testid":"picker-option"},m.default.createElement("span",null,A.label),m.default.createElement("span",{className:"pk-count"},A.count.toLocaleString(l)))),v.length?null:m.default.createElement("li",{className:"pk-hint pk-picker-none"},a.pickerNone)),m.default.createElement("p",{className:"pk-hint pk-picker-count","aria-live":"polite","data-testid":"picker-count"},L(a.pickerMatch,{count:w.length.toLocaleString(l),total:e.length.toLocaleString(l)}))))}function Ya({rule:e,ctx:t,apply:n,first:o}){let{field:r,labels:a,locale:l,fk:s,items:i}=t,d=(0,m.useContext)(ht).size==="narrow",u=s.dates?a.dateOps:a.valueOps,c=s.dates?[...H.valueOps,"last"]:H.valueOps,p=y=>y===void 0?"":s.item==="number"?ce(y,l):String(y),h=e?.type==="compare"?e:null,g=e?.type==="relative"?e:null,[f,N]=(0,m.useState)(()=>({op:g?"last":h?.op??">=",a:p(h?.value),b:p(h?.value2),count:ce(g?.count??5,l),unit:g?.unit??"year"})),w=ct(),v=ie(),S=y=>s.item==="number"?Nt(y,l):s.item==="date"?/^\d{4,}-\d{2}-\d{2}$/.test(y)?y:null:y===""?null:Number(y),C=y=>{if(y.op==="last"){let U=Ne(y.count,{kind:"count",max:H.relativeMaxCount,labels:a,locale:l}).value;return U!==null?{field:r,type:"relative",unit:y.unit,count:U,...g?.anchor==="latest"?{anchor:"latest"}:{}}:null}let[M,q]=[S(y.a),S(y.b)];return M===null||je(y.op)&&q===null?null:{field:r,type:"compare",op:y.op,value:M,...je(y.op)?{value2:q}:{}}},x=(y,M=!1)=>{let q={...f,...y};N(q);let U=()=>{let ee=C(q);ee&&n(ee)};M?w.later(U):(w.cancel(),U())},O=()=>{w.cancel();let y={a:p(h?.value),b:p(h?.value2),count:ce(g?.count??5,l)};return f.a===y.a&&f.b===y.b&&f.count===y.count?!1:(N({...f,...y}),!0)},B=Xe({now:w.now,restore:O,back:t.back}),E=(y,M,q)=>{if(s.item==="number"){let K=Ne(f[y],{required:!1,labels:a,locale:l}).problem;return m.default.createElement(Ye,{value:f[y],onChange:j=>x({[y]:j},!0),onKeyDown:B,onBlur:w.now,problem:K,label:M,testId:q,className:"pk-field-label pk-narrow-input"})}if(s.item==="date")return m.default.createElement("input",{type:"date",name:`${v}-${y}`,value:f[y],onChange:K=>x({[y]:K.target.value}),"aria-label":M,"data-testid":q});let U=i.filter(K=>typeof K.value=="number"),ee=f[y]!==""&&!U.some(K=>String(K.value)===f[y]);return U.length>=ja&&!d?m.default.createElement(Qa,{items:ee?[{value:Number(f[y]),label:f[y],count:0},...U]:U,value:f[y],onChange:K=>x({[y]:K}),label:M,testId:q,labels:a,locale:l}):m.default.createElement("select",{name:`${v}-${y}`,value:f[y],onChange:K=>x({[y]:K.target.value}),"aria-label":M,"data-testid":q},m.default.createElement("option",{value:"",disabled:!0},a.ruleValue),ee?m.default.createElement("option",{value:f[y]},f[y]):null,U.map(K=>m.default.createElement("option",{key:String(K.value),value:String(K.value)},K.label)))},A=s.item==="date"?a.ruleDate:a.ruleValue,I={lang:a.lang,locale:l},D=Ne(f.count,{kind:"count",max:H.relativeMaxCount,labels:a,locale:l}),R=D.value??2;return m.default.createElement(m.default.Fragment,null,m.default.createElement("span",{className:"pk-rule-subject"},Q(r,a.core)),m.default.createElement("select",{className:"pk-rule-op",name:`${v}-op`,value:f.op,onChange:y=>x({op:y.target.value}),"aria-label":a.valueFilterOp,"data-autofocus":o?"":void 0,"data-testid":"rule-item-op"},c.map(y=>m.default.createElement("option",{key:y,value:y},y==="last"?W(a.lastOp,R,I):u[y]??y))),f.op==="last"?m.default.createElement(m.default.Fragment,null,m.default.createElement(Ye,{value:f.count,onChange:y=>x({count:y},!0),onKeyDown:B,onBlur:w.now,problem:D.problem,label:a.quickCount[f.unit],testId:"rule-last-count",className:"pk-field-label pk-count-input"}),m.default.createElement("select",{name:`${v}-unit`,value:f.unit,onChange:y=>x({unit:y.target.value}),"aria-label":a.ruleUnit,"data-testid":"rule-last-unit"},H.relativeUnits.map(y=>m.default.createElement("option",{key:y,value:y},W(a.ruleUnits[y],R,I))))):m.default.createElement(m.default.Fragment,null,E("a",A,"rule-item-value"),je(f.op)?m.default.createElement(m.default.Fragment,null,m.default.createElement("span",null,a.valueFilterTo),E("b",`${a.valueFilterTo} ${A}`,"rule-item-value2")):null,f.op==="!="||f.op==="notBetween"?m.default.createElement("span",{className:"pk-hint pk-rule-note","data-testid":"rule-blanks"},a.blanksOut):null))}function Xa({rule:e,ctx:t,apply:n,first:o}){let{view:r,types:a,labels:l,locale:s}=t,{choices:i,names:d}=Tt(r,a,l,e?.by),[u,c]=(0,m.useState)(()=>({by:Bo(i,e?.by),op:e?.op??">",a:ce(e?.value,s),b:ce(e?.value2,s)})),p=ct(),h=ie(),g=(v,S=!1)=>{let C={...u,...v};c(C);let x=()=>{let[O,B]=[Nt(C.a,s),Nt(C.b,s)];if(O!==null&&(!je(C.op)||B!==null)){let E=i[C.by];n({field:t.field,type:"value",by:{field:E.field,agg:E.agg},op:C.op,value:O,...je(C.op)?{value2:B}:{}})}};S?p.later(x):(p.cancel(),x())},f=()=>{p.cancel();let v={a:ce(e?.value,s),b:ce(e?.value2,s)};return u.a===v.a&&u.b===v.b?!1:(c({...u,...v}),!0)},N=Xe({now:p.now,restore:f,back:t.back}),w=(v,S,C,x)=>m.default.createElement(Ye,{value:u[v],onChange:O=>g({[v]:O},!0),onKeyDown:N,onBlur:p.now,problem:Ne(u[v],{required:!1,labels:l,locale:s}).problem,label:S,shown:x,testId:C,className:"pk-field-label pk-narrow-input"});return m.default.createElement(m.default.Fragment,null,m.default.createElement("span",{className:"pk-rule-subject pk-rule-lead"},L(l.ruleWhose,{field:Q(t.field,l.core)})),m.default.createElement(Mo,{choices:i,names:d,index:u.by,onChange:v=>g({by:v}),label:l.valueFilterBy,testId:"value-filter-by"}),m.default.createElement("select",{className:"pk-rule-op",name:`${h}-op`,value:u.op,onChange:v=>g({op:v.target.value}),"aria-label":l.valueFilterOp,"data-autofocus":o?"":void 0,"data-testid":"value-filter-op"},H.valueOps.map(v=>m.default.createElement("option",{key:v,value:v},l.valueOps[v]??v))),w("a",l.valueFilterNumber,"value-filter-number"),je(u.op)?w("b",`${l.valueFilterTo} ${l.valueFilterNumber}`,"value-filter-number2",l.valueFilterTo):null)}function Za({rule:e,ctx:t,apply:n,first:o}){let{field:r,labels:a}=t,[l,s]=(0,m.useState)(e?.op??"contains"),i=(c,p)=>{p!==""&&n({field:r,type:"label",op:c,value:p})},d=Do(e?.value??"",c=>i(l,c)),u=ie();return m.default.createElement(m.default.Fragment,null,m.default.createElement("span",{className:"pk-rule-subject"},a.ruleName),m.default.createElement("select",{className:"pk-rule-op",name:u,value:l,onChange:c=>{s(c.target.value),i(c.target.value,d.text)},"aria-label":a.condition,"data-autofocus":o?"":void 0,"data-testid":"filter-condition-op"},H.labelOps.map(c=>m.default.createElement("option",{key:c,value:c},a.labelOps[c]??c))),m.default.createElement(Ee,{type:"text",value:d.text,onChange:d.set,onBlur:d.flush,onKeyDown:Xe({now:d.flush,restore:d.restore,back:t.back}),onClear:()=>d.set(""),clearLabel:a.clearText,"aria-label":a.conditionValue,placeholder:a.conditionValue,maxLength:1e3,"data-testid":"filter-condition-text"}))}var er={item:Ya,total:Xa,name:Za};function tr({ctx:e,rules:t,focusFirst:n,quickLine:o,results:r}){let{view:a,field:l,labels:s,locale:i,commit:d,note:u,fk:c,nameKind:p,noun:h}=e,{explain:g}=(0,m.useContext)(rt),f={lang:s.lang,locale:i},[N,w]=(0,m.useState)(null),[v,S]=(0,m.useState)(null),[C,x]=(0,m.useState)(0),O=yo(t),[B,E]=(0,m.useState)(O),[A,I]=(0,m.useState)(null);O!==B&&(E(O),O!==A&&(x(C+1),w(null)));let D=(0,m.useRef)(null),R=(0,m.useRef)(!1);(0,m.useEffect)(()=>{R.current&&(R.current=!1,D.current?.querySelector(".pk-rule-adds button:not([disabled])")?.focus())},[C]),(0,m.useEffect)(()=>{if(N){let j=D.current?.querySelector(".pk-rule:last-child");j?.querySelector("[data-autofocus]")?.focus({preventScroll:!0}),j?.scrollIntoView?.({block:"nearest"});let G=j?.closest(".pk-level-body");if(j&&G){let Y=j.getBoundingClientRect().bottom-G.getBoundingClientRect().bottom;Y>0&&(G.scrollTop+=Math.ceil(Y))}}},[N]);let y=["item","total","name"].filter(j=>j==="item"?!!c.item:j==="name"?!!p:!0),M=t.length+(N?1:0),q=M>=mo||a.filters.length>=An.filters,U={item:L(s.addRuleItem,{field:Q(l,s.core)}),total:s.addRuleTotal,name:s.addRuleName},ee=(j,G)=>{let Y=W(h,1,f);if(G==="total"){let he=j?.by??Tt(a,e.types,s,void 0).choices[0];return L(s.ruleInfo.total,{noun:Y,nouns:W(h,2,f),measure:_e(a,he,s),scope:e.scope})}return G==="name"?L(s.ruleInfo.name,{noun:Y}):L(s.ruleInfo[c.item==="group"?c.cyclic?"cyclic":"group":c.item??"group"],{noun:Y})},K=(j,G,Y)=>{let he=er[G],xe=qe=>{let Ue=We(a,l,j,qe);I(yo(fe(Ue,l,St).filter(De=>!e.quickFilters.includes(De)))),j||w(null),d(Ue,u)},ae=()=>{R.current=!0,j?d(We(a,l,j,null),u):(w(null),x(C+1))},re=j?r.get(j):null,de=v===Y,ge=`${C}-${Y}`;return m.default.createElement("li",{key:`${C}:${Y}`,className:"pk-rule","data-testid":"rule","data-kind":G},Y>0||o?m.default.createElement("span",{className:"pk-rule-and"},s.ruleAnd):null,m.default.createElement("span",{className:"pk-rule-body"},m.default.createElement(he,{rule:j,ctx:e,apply:xe,first:n&&Y===0||!j&&N!==null})),m.default.createElement("span",{className:"pk-rule-tools"},g?m.default.createElement("button",{type:"button",className:"pk-icon-btn pk-rule-info","aria-expanded":de,"aria-controls":de?ge:void 0,onClick:()=>S(de?null:Y),"aria-label":s.explainRule,title:s.explainRule,"data-testid":"rule-info"},m.default.createElement(X,{name:"info",size:14})):null,m.default.createElement("button",{type:"button",className:"pk-icon-btn pk-rule-remove",onClick:ae,"aria-label":s.removeRule,title:s.removeRule,"data-testid":"rule-remove"},m.default.createElement(X,{name:"x",size:14}))),m.default.createElement("p",{className:`pk-hint pk-rule-result${re&&re.kept===0?" pk-rule-result-empty":""}`,"data-testid":"rule-result"},re?re.text:s.ruleIncomplete),de?m.default.createElement("p",{className:"pk-rule-info-text",id:ge,"data-testid":"rule-info-text"},ee(j,G)):null)};return m.default.createElement("fieldset",{ref:D,className:"pk-condition pk-rules","data-testid":"rules"},m.default.createElement("legend",{className:"pk-sr"},s.rulesTitle),m.default.createElement("p",{className:"pk-hint"},L(M||o?s.rulesKeep:s.rulesNone,{noun:W(h,2,f)})),M||o?m.default.createElement("ul",{className:"pk-rule-list",role:"list"},o?m.default.createElement("li",{className:"pk-rule pk-rule-quick","data-testid":"rule-quick"},m.default.createElement("span",null,L(s.quickLine,{text:o})),m.default.createElement("button",{type:"button",className:"pk-action",onClick:e.focusQuick,"data-testid":"rule-quick-change"},s.changeAbove)):null,[...t.map((j,G)=>K(j,Va(j),G)),...N?[K(null,N,t.length)]:[]]):null,m.default.createElement("div",{className:"pk-rule-adds",role:"group","aria-label":s.addRule},y.map((j,G)=>m.default.createElement("button",{key:j,type:"button",className:"pk-btn pk-small-btn",disabled:q,onClick:()=>w(j),"data-autofocus":n&&!M&&G===0?"":void 0,"data-testid":`rule-add-${j}`},m.default.createElement(X,{name:"plus",size:14}),m.default.createElement("span",{className:"pk-btn-text"},U[j])))),q?m.default.createElement("p",{className:"pk-hint"},L(s.rulesFull,{max:mo})):null)}var nr=(e,t,n)=>e.filters.filter(o=>!(typeof o.field=="string"&&o.field.toLowerCase()===t.toLowerCase()&&n.includes(o.type)));function Po({view:e,field:t,encoded:n,types:o,labels:r,locale:a,commit:l,back:s,hint:i}){let d=(0,m.useMemo)(()=>Pe(n,t,{view:e,locale:a,labels:r.core}),[n,t,e,a,r]),u=(0,m.useContext)(ht).size==="narrow",c=(0,m.useMemo)(()=>So(n,e,t),[n,e,t]),p=Re(e,t),h=c.dates?n.column(p):null,g=(0,m.useMemo)(()=>c.dates?Wt(n,p):null,[n,c.dates,p]),f=(0,m.useMemo)(()=>h?Ka(h):null,[h]),N=(0,m.useMemo)(()=>c.cyclic&&h&&f?_a(h,f):[],[c.cyclic,h,f]),w=ra(e,t,c,N.map(T=>T.year)),[v,S]=(0,m.useState)(null),C=w.anchor??v??"today",[x,O]=(0,m.useState)(!0),[B,E]=(0,m.useState)(null),[A,I]=(0,m.useState)(i==="conditions"?!0:null),D=(0,m.useRef)(null),y=fe(e,t,St).filter(T=>!w.filters.includes(T)),M=y.filter(T=>T.type!=="value"),q=y.filter(T=>T.type==="value"),U=y.length>0||w.filters.length>0,ee=(0,m.useRef)(U),K=(0,m.useRef)(!1),j=(0,m.useRef)(!1),G=()=>{if(!j.current)return;let T=D.current?Je(D.current):null;(!T||!T.isConnected||!D.current?.contains(T)||T instanceof HTMLButtonElement&&T.disabled)&&D.current?.querySelector('[data-testid="section-rules"]')?.focus(),j.current=!1};(0,m.useEffect)(G),(0,m.useEffect)(()=>{ee.current!==U&&(ee.current=U,K.current?K.current=!1:(I(U),E(!U)),j.current=!0,setTimeout(G,100))},[U]);let[Y,he]=(0,m.useState)(0);(0,m.useEffect)(()=>{if(Y){let T=D.current?.querySelector('[data-testid="quick-choices"] input:checked, [data-testid="years-combined"] [aria-pressed="true"]:not(:disabled)')??D.current?.querySelector('[data-testid="years-combined"] button:not(:disabled)');T?.scrollIntoView?.({block:"center"}),T?.focus({preventScroll:!0})}},[Y]);let xe=n.timeZone,ae=Ua(c,r),re={lang:r.lang,locale:a},de=JSON.stringify(e),ge=(0,m.useMemo)(()=>{if(!d)return null;let T=nr(e,t,["value","top"]),J=q[0]?.by??Tt(e,o,r,void 0).choices[0],z=nn(n,e,t,J,[...T,...q]),ve=new Map;for(let ye of q){let Ft=nn(n,e,t,ye.by,T),ft=nn(n,e,t,ye.by,[...T,ye]);ve.set(ye,{totals:Ft.totals,kept:ft.totals.size})}return{shown:z.totals,rows:z.rows,perRule:ve,by:J}},[n,de,t,d]),qe=(0,m.useMemo)(()=>{let T=new Map;for(let J of M){let z=Pe(n,t,{view:{...e,filters:[J]},locale:a,labels:r.core});T.set(J,z?z.items.filter(ve=>ve.kept).length:0)}if(w.filters.length&&M.length){let J=Pe(n,t,{view:{...e,filters:w.filters},locale:a,labels:r.core});T.set("quick",new Set(J?J.items.filter(z=>!z.kept).map(z=>se(z.value)):[]))}return T},[n,de,t,a,r]);if(!d||!ge)return null;let De={step:"filter",field:Q(t,r.core)},F=d.items.map(T=>T.value),_=Qt(e,t,F),ue=new Set(_.map(se)),te=Ao(n,e,t)??(y.some(T=>T.type==="label")?"text":null),pe=T=>d.items.find(J=>J.value===T)?.label,Se=T=>Co(e,T,{labels:r,locale:a,timeZone:xe,date:c.dates,labelOf:pe,span:g}),ne=T=>T.toLocaleString(a),le=w.id==="yearsCombined"&&w.years?w.years:N.map(T=>T.year),ut=c.cyclic&&N.length>1?le.length===1?L(r.yearsOne,{year:String(le[0])}):L(r.yearsAll,{years:le.length===N.length||le[le.length-1]-le[0]===le.length-1?`${le[0]}\u2013${le[le.length-1]}`:le.join(", ")}):null,Ce=w.id==="yearsCombined"?ut:w.filters.length?Ut(w.filters[0],r,a,xe,void 0,g):null,Ze=qe.get("quick")??(w.filters.length?new Set(d.items.filter(T=>!T.kept).map(T=>se(T.value))):new Set),et=d.items.filter(T=>T.kept&&ue.has(se(T.value))),ke=q.length?et.filter(T=>ge.shown.has(se(T.value))).length:et.length,Te=F.length-_.length,Lt=d.items.filter(T=>ue.has(se(T.value))&&Ze.has(se(T.value))).length,Nn=d.items.filter(T=>ue.has(se(T.value))&&!T.kept).length-Lt,_o=et.length-ke,xn=(T,J)=>{let z=[...T.entries()].filter(([,me])=>me!==null);if(!z.length)return null;let[ve,ye]=[z.reduce((me,tt)=>tt[1]<me[1]?tt:me),z.reduce((me,tt)=>tt[1]>me[1]?tt:me)],Ft=e.values.find(me=>ze({field:me.field??null,agg:me.agg},J)),ft=Be(Ft?.format??(J.agg==="count"||J.agg==="countUnique"?"integer":"number"),{locale:a}),Sn=me=>pe(JSON.parse(me))??me;return L(r.totalSpread,{low:ft(ve[1]),lowItem:Sn(ve[0]),high:ft(ye[1]),highItem:Sn(ye[0])})},zo=T=>{let J=_e(e,T.by,r),z=r.valueOps[T.op]??T.op,ve=ye=>typeof ye=="number"?ye.toLocaleString(a,{maximumFractionDigits:6}):"";return je(T.op)?L(r.totalWordsTwo,{measure:J,op:z,from:ve(Math.min(T.value,T.value2)),to:ve(Math.max(T.value,T.value2))}):L(r.totalWords,{measure:J,op:z,number:ve(T.value)})},mt=null;if(ke===0){let T=q.find(J=>ge.perRule.get(J)?.kept===0);T?mt=L(r.emptyTotal,{noun:W(ae,1,re),rule:zo(T),spread:xn(ge.perRule.get(T).totals,T.by)??""}):_.length===0?mt=r.emptyPicks:Lt+Nn>0&&(mt=L(r.emptyRules,{noun:W(ae,1,re),rules:[...Ce?[Ce]:[],...M.map(Se)].join(r.listAnd)}))}let Ot=new Map;for(let T of y)if(T.type==="value"){let J=ge.perRule.get(T),z=J.kept===0?L(r.ruleKeepsNone,{total:ne(F.length),noun:W(ae,F.length,re),spread:xn(J.totals,T.by)??""}):L(r.ruleKeeps,{kept:ne(J.kept),total:ne(F.length),noun:W(ae,F.length,re)});Ot.set(T,{kept:J.kept,text:z})}else{let J=qe.get(T)??0;Ot.set(T,{kept:J,text:L(r.ruleKeeps,{kept:ne(J),total:ne(F.length),noun:W(ae,F.length,re)})})}let At=[...e.rows,...e.cols].filter(T=>T.toLowerCase()!==t.toLowerCase()).map(T=>L(r.scopeItems,{count:ne(Pe(n,T,{view:e,locale:a,labels:r.core})?.items.length??0),field:Q(T,r.core)}));g&&At.push(L(r.scopeDates,{range:`${we(Ae(g.min),a)} \u2013 ${we(Ae(g.max),a)}`}));let Ho=At.length?At.join(r.listAnd):r.scopeRows,Wo=()=>{O(!0),he(T=>T+1)},It=(T,J)=>{l(T,De),requestAnimationFrame(()=>{let z=D.current?Je(D.current):null;(!z||!z.isConnected||!D.current?.contains(z)||z instanceof HTMLButtonElement&&z.disabled)&&D.current?.querySelector(`[data-testid="${J}"]`)?.focus()})},dt={view:e,field:t,types:o,labels:r,locale:a,commit:l,note:De,back:s,fk:c,nameKind:te,timeZone:xe,hint:i,items:d.items,noun:ae,scope:Ho,quickFilters:w.filters,focusQuick:Wo,act:It},$t=B??!U,Rt=A??U,Go=()=>{K.current=!0,E(!$t),u&&!$t&&I(!1)},Qo=()=>{K.current=!0,I(!Rt),u&&!Rt&&E(!1)},Yo={shown:ke,total:F.length,noun:ae,unpicked:Te,byQuick:Lt,byRules:Nn,byTotals:_o,itemRules:M.length,totalRules:q.length,rows:ge.rows,rowsAll:n.length,span:g,yearsText:ut,empty:mt,quickWords:Ce,rules:y.length,canReset:Te>0||U},Xo=T=>T.kept===!1,pt=c.quick&&g&&h&&f?{id:"quick",title:r.quickTitle,body:m.default.createElement(Wa,{ctx:dt,quick:w,anchor:C,setAnchorLocal:S,span:g,column:h,counts:f})}:c.cyclic&&N.length>1&&N.length<=12?{id:"years",title:r.yearsCombined,body:m.default.createElement(Ga,{ctx:dt,years:N,on:le})}:null;return m.default.createElement("div",{ref:D,className:"pk-filter pk-filter-level"},m.default.createElement(Ha,{ctx:dt,state:Yo}),pt?m.default.createElement(on,{id:pt.id,title:pt.title,state:Ce&&!x?Ce:null,open:x,onToggle:()=>O(!x)},pt.body):null,m.default.createElement(on,{id:"picks",title:r.pickItems,state:Te?L(r.picksState,{picked:ne(_.length),total:ne(F.length)}):L(r.picksAll,{total:ne(F.length)}),open:$t,onToggle:Go,action:m.default.createElement("button",{type:"button",className:"pk-action",disabled:!Te,"aria-label":r.clearPicks,onClick:()=>It(sn(e,t,F,F),"section-picks"),"data-testid":"filter-clear-picks"},r.clear)},m.default.createElement(Io,{items:d.items,selected:ue,onChange:T=>l(sn(e,t,F.filter(J=>T.has(se(J))),F),De),labels:r,locale:a,autoFocus:!U&&!c.quick&&i!=="conditions",tail:U?{isOut:Xo,render:(T,J,z)=>m.default.createElement(za,{out:T,row:J,searching:z,labels:r,locale:a})}:void 0})),m.default.createElement(on,{id:"rules",title:r.rulesTitle,state:y.length?m.default.createElement(m.default.Fragment,null,m.default.createElement("span",{className:"pk-section-mark"},"\u25CF")," ",L(W(r.rulesState,y.length,re),{count:ne(y.length)})):r.rulesNoneState,open:Rt,onToggle:Qo,action:m.default.createElement("button",{type:"button",className:"pk-action",disabled:!y.length,"aria-label":r.removeRules,onClick:()=>It(ma(e,t,w.filters),"section-rules"),"data-testid":"filter-remove-rules"},r.removeAll)},m.default.createElement(tr,{ctx:dt,rules:y,focusFirst:i==="conditions",quickLine:Ce,results:Ot})))}function or({view:e,field:t,types:n,labels:o,locale:r,commit:a,back:l}){let s=fe(e,t,["top"])[0],{choices:i,names:d}=Tt(e,n,o,s?.by),[u,c]=(0,$.useState)(()=>Bo(i,s?.by)),p=s&&!s.bottom&&cn.includes(s.count)?s.count:null,[h,g]=(0,$.useState)(!!s&&p===null),[f,N]=(0,$.useState)(!!s?.bottom),[w,v]=(0,$.useState)(ce(s?.count??10,r)),S=ct(),C=Ne(w,{kind:"count",labels:o,locale:r}),x=Q(t,o.core),O=I=>a(xo(e,t,I,s),{step:"top",field:x}),B=I=>{let D={bottom:f,count:w,by:u,...I},R=Ne(D.count,{kind:"count",labels:o,locale:r}).value;R!==null&&O({count:R,bottom:D.bottom,by:i[D.by]})},E=ie(),A=(I,D,R,y)=>$.default.createElement("label",{className:"pk-radio"},$.default.createElement("input",{type:"radio",name:E,checked:R,onChange:y,"data-autofocus":R?"":void 0,"data-testid":`top-${I}`}),$.default.createElement("span",null,D));return $.default.createElement("div",{className:"pk-level-form"},$.default.createElement("div",{role:"radiogroup","aria-label":o.topN,className:"pk-radios"},A("off",o.off,!s&&!h,()=>{g(!1),O(null)}),cn.map(I=>$.default.createElement($.default.Fragment,{key:I},A(String(I),L(o.topBadge,{count:I.toLocaleString(r)}),!h&&p===I,()=>{g(!1),O({count:I,bottom:!1,by:i[u]})}))),A("own",o.topOwn,h,()=>{g(!0),B({})})),h?$.default.createElement("div",{className:"pk-inline-form"},$.default.createElement("div",{className:"pk-segmented pk-small",role:"group","aria-label":o.topN},[!1,!0].map(I=>$.default.createElement("button",{key:String(I),type:"button","aria-pressed":f===I,onClick:()=>{N(I),B({bottom:I})},"data-testid":I?"top-bottom":"top-top"},I?o.bottom:o.top))),$.default.createElement(Ye,{value:w,onChange:I=>{v(I),S.later(()=>B({count:I}))},onKeyDown:Xe({now:S.now,restore:()=>{S.cancel();let I=ce(s?.count??10,r);return w===I?!1:(v(I),!0)},back:l}),onBlur:S.now,problem:C.problem,label:o.topCount,testId:"top-count",className:"pk-field-label pk-narrow-input"})):null,$.default.createElement("div",{className:"pk-inline-form"},$.default.createElement(Mo,{choices:i,names:d,index:u,onChange:I=>{c(I),s&&O({count:s.count,bottom:!!s.bottom,by:i[I]})},label:o.topBy,prefix:o.topBy,testId:"top-by"})))}function ar({view:e,field:t,labels:n,locale:o,range:r,regroup:a,back:l}){let s=vt(e,t),i=s?.by==="bin"?s:null,[d,u]=(0,$.useState)(ce(i?.size,o)),[c,p]=(0,$.useState)(ce(i?.origin,o)),[h,g]=(0,$.useState)(!1),f=(0,$.useId)(),N=Ne(d,{kind:"size",tried:h,labels:n,locale:o}),w=Ne(c,{required:!1,labels:n,locale:o}),v=N.value,S=c.trim()===""?0:w.value,C=v!==null&&S!==null&&oa(v,S,r)==="far",x=O=>O.toLocaleString(o,{maximumFractionDigits:6});return $.default.createElement("form",{className:"pk-inline-form pk-bin-form",onSubmit:O=>{if(O.preventDefault(),i&&d.trim()===""){a(null);return}g(!0),v!==null&&S!==null&&!C&&a("bin",v,S)},onKeyDown:O=>{O.key==="Escape"&&(O.preventDefault(),O.stopPropagation(),l())}},$.default.createElement(Ye,{value:d,onChange:u,problem:N.problem,label:n.binSize,shown:n.binSize,testId:"bin-size",autoFocus:!0}),$.default.createElement("label",{className:"pk-field-label"},$.default.createElement("span",null,n.binStart),$.default.createElement(Ee,{type:"text",inputMode:"decimal",autoComplete:"off",spellCheck:!1,value:c,placeholder:"0",onChange:p,clearLabel:n.clearText,"data-testid":"bin-start","aria-invalid":C||w.problem?!0:void 0,"aria-describedby":C||w.problem?f:void 0})),w.problem?$.default.createElement("p",{id:f,className:"pk-form-problem","data-testid":"bin-start-problem"},w.problem):C&&r&&S!==null&&v!==null?$.default.createElement("p",{id:f,className:"pk-form-problem","data-testid":"bin-problem"},L(n.binStartFar,{start:x(S),min:x(r.min),max:x(r.max)})):null,$.default.createElement("button",{type:"submit",className:"pk-btn pk-primary",disabled:C,"data-testid":"bin-apply"},n.apply),i?$.default.createElement("button",{type:"button",className:"pk-btn",onClick:()=>a(null),"data-testid":"bin-off"},n.binsOff):null)}function rr({view:e,index:t,labels:n,commit:o,back:r}){let a=e.values[t],s={step:"value",field:ot(a,n)},i=Do(a.label??"",d=>o(rn(e,t,{label:d.trim()||null}),s),0);return $.default.createElement("div",{className:"pk-inline-form pk-level-form"},$.default.createElement(Ee,{type:"text",value:i.text,placeholder:ot({...a,label:null},n),onChange:i.set,onBlur:i.flush,onKeyDown:Xe({now:()=>{i.flush(),r()},restore:i.restore,back:r}),onClear:()=>a.label?o(rn(e,t,{label:null}),s):void 0,clearLabel:n.defaultName,"aria-label":n.rename,maxLength:200,"data-autofocus":"","data-testid":"value-name"}),$.default.createElement("p",{className:"pk-hint"},n.nameHint))}function kn({name:e,info:t,extra:n,labels:o}){let r=$.default.createElement($.default.Fragment,null,t?.description,t?.href?$.default.createElement($.default.Fragment,null," ",$.default.createElement("a",{href:t.href,target:"_blank",rel:"noopener noreferrer",className:"pk-learn-more"},o.learnMore)):null,t?.description&&n?$.default.createElement($.default.Fragment,null,$.default.createElement("br",null),$.default.createElement("br",null)):null,n);return $.default.createElement("div",{className:"pk-level-name"},$.default.createElement("span",{className:"pk-level-name-text","data-testid":"menu-head"},e),t?.description||n?$.default.createElement(_t,{info:{description:r},name:e,labels:o,className:"pk-menu-info",testId:"menu-info"}):null)}function vn({labels:e,onRemove:t,close:n}){return $.default.createElement(Ct,{id:"menu-remove",text:e.remove,icon:"trash",danger:!0,onSelect:()=>{n(),t()}})}var yn=(e,t)=>n=>{let o=n.change?.();n.closes&&t(),o&&e(o.view,o.note)};function as({view:e,zone:t,index:n,field:o,types:r,labels:a,commit:l,close:s,onRemove:i,defaultsOf:d,rangeOf:u,locale:c,info:p,state:h,encoded:g}){let f=Re(e,o),N=ga({view:e,zone:t,index:n,field:o,types:r,labels:a,locale:c,state:h,defaultsOf:d,encoded:g}),w=(C,x,O)=>{s();let B=Q(f,a.core),E=C?Kt(B,C,a,x):null;l(Gt(e,o,C,{size:x,origin:O,name:E??void 0}).view,{step:"group",field:B})},v=(C,x,O)=>C==="filter"?$.default.createElement(Po,{view:e,field:o,encoded:g,types:r,labels:a,locale:c,commit:l,back:x,hint:O}):C==="top"?$.default.createElement(or,{view:e,field:o,types:r,labels:a,locale:c,commit:l,back:x}):C==="bins"?$.default.createElement(ar,{view:e,field:o,labels:a,locale:c,range:u?.(f)??null,regroup:w,back:x}):null,S=Q(o,a.core);return $.default.createElement(it,{name:S,labels:a,locale:c,topics:N,close:s,onPick:yn(l,s),panel:v,search:!0,head:$.default.createElement(kn,{name:S,info:p,labels:a}),foot:$.default.createElement(vn,{labels:a,onRemove:i,close:s})})}function rs({view:e,index:t,field:n,types:o,labels:r,commit:a,close:l,onRemove:s,locale:i,info:d,state:u,encoded:c}){let p=Q(n,r.core);return $.default.createElement(it,{name:p,labels:r,locale:i,topics:va({view:e,index:t,field:n,types:o,labels:r,locale:i,state:u,encoded:c}),close:l,onPick:yn(a,l),panel:(h,g,f)=>h==="filter"?$.default.createElement(Po,{view:e,field:n,encoded:c,types:o,labels:r,locale:i,commit:a,back:g,hint:f}):null,search:!0,head:$.default.createElement(kn,{name:p,info:d,labels:r}),foot:$.default.createElement(vn,{labels:r,onRemove:s,close:l})})}function ss({view:e,index:t,types:n,labels:o,commit:r,close:a,onRemove:l,defaultsOf:s,info:i,earlier:d,locale:u="en-US"}){let{explain:c}=$.default.useContext(rt),p=ot(e.values[t],o),h=Ea({view:e,index:t,types:n,labels:o,locale:u,defaultsOf:s,earlier:d});return $.default.createElement(it,{name:p,labels:o,locale:u,topics:h,close:a,onPick:yn(r,a),panel:(g,f)=>g==="name"?$.default.createElement(rr,{view:e,index:t,labels:o,commit:r,back:f}):null,search:!0,head:$.default.createElement(kn,{name:p,info:i,extra:c?o.settingInfo.valuesFilter:null,labels:o}),foot:$.default.createElement(vn,{labels:o,onRemove:l,close:a})})}var sr=/[<>:"/\\|?*\u0000-\u001F\u007F]+/g,lr=/^(con|prn|aux|nul|com\d|lpt\d)$/i;function wn(e){let n=ir((typeof e=="string"?e:"").replace(sr,"-").replace(/^[\s.-]+/,"").slice(0,120));return n&&!lr.test(n)?n:"pivot"}function ir(e){let t=e.length;for(;t>0&&(e[t-1]==="."||/\s/.test(e[t-1]));)t--;return e.slice(0,t)}function cr(e){let t=/^data:([^,;]*)((?:;[^,;]*)*?)(;base64)?,(.*)$/s.exec(e);if(!t)throw new TypeError("not a data: URL");let n=t[1]||"application/octet-stream";if(t[3]){let o=atob(t[4]),r=new Uint8Array(o.length);for(let a=0;a<o.length;a++)r[a]=o.charCodeAt(a);return new Blob([r],{type:n})}return new Blob([decodeURIComponent(t[4])],{type:n})}function Vo(e,t,n=document){let o=URL.createObjectURL(e),r=n.createElement("a");r.href=o,r.download=t,r.rel="noopener",n.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(o),1e4)}async function dn(e,t){try{if(typeof navigator<"u"&&navigator.clipboard&&typeof navigator.clipboard.writeText=="function")return await navigator.clipboard.writeText(e),!0}catch{}if(!t)return!1;let n=t.ownerDocument,o=n.createElement("textarea");o.value=e,o.readOnly=!0,o.className="pk-sr";let r=t.getRootNode()instanceof ShadowRoot?t.getRootNode().activeElement:n.activeElement;t.appendChild(o);let a;try{o.select(),a=typeof n.execCommand=="function"&&n.execCommand("copy")}catch{a=!1}return o.remove(),r?.focus?.({preventScroll:!0}),a}var ur="0.4.0",mr=()=>typeof location<"u"?location.href:void 0;function dr(e,t){let{view:n,viewName:o,sourceId:r,sourceName:a,schemaUrl:l,encoded:s,announce:i,limits:d,param:u}=e,c=()=>Dn(nt(n,{name:o??"",createdAt:new Date,generator:{name:"pivotkit-react",version:ur},source:{id:r,name:a},data:s,...l!==void 0?{schemaUrl:l}:{}}));return{copyLink:async()=>{let p=eo(e.shareLink,mr());if(p===null)return;let h;try{h=(Zt()??await Xt()).encodeViewLink(nt(n,{name:o??void 0,source:{id:r}},{link:!0}))}catch(f){i(f&&f.code==="LIMIT_EXCEEDED"?t.toastLinkTooLong:L(t.error,{message:String(f)}),{tone:"error"});return}let g=await dn(Zn(p,u,h),e.root.current);i(g?t.toastLinkCopied:t.toastCopyFailed,g?void 0:{tone:"error"})},copyJson:async()=>{let p=await dn(c(),e.root.current);i(p?t.toastJsonCopied:t.toastCopyFailed,p?void 0:{tone:"error"})},download:()=>{let p=Mn(o||a||wn(e.fileName)),h=new Blob([c()],{type:"application/json"});e.onExport?.({kind:"json",fileName:p,blob:h})!==!1&&(Vo(h,p,e.root.current?.ownerDocument??document),i(L(t.toastExported,{file:p})))},loadText:async p=>{let h=to(p,s,{limits:d,sourceId:r});if(h.failed==="notJson"){let v=p.trim(),C=(v.includes("#")?en(v.slice(v.indexOf("#")),u)??en(v.slice(v.indexOf("#")),"pivot"):null)??(v.startsWith("1.")?v:null);if(!C)return t.viewFailed.notJson;try{let x=(Zt()??await Xt()).decodeViewLink(C);h=x.view?no(x.view,s,{limits:d,sourceId:r}):{view:null,issues:[],failed:"badLink",file:null}}catch{return t.viewFailed.badLink}}if(!h.view)return t.viewFailed[h.failed??"notView"]??t.viewFailed.notView;let g=h,f=oo(g,t,Array.isArray(e.sources)?e.sources:[]);if(!f)return e.applyLoaded(g),null;let N=f.switchTo,w=e.onSourceSwitch;return{lines:f.lines,load:()=>e.applyLoaded(g),switchTo:N&&typeof w=="function"?{name:N.name,run:()=>w({source:{id:N.id,name:N.name},view:g.file?.view??g.view,name:g.file?.name||void 0})}:void 0}}}}var xt=e=>e.host||e.store,pr=(e,t)=>!!t&&e.name===t.name&&(e.scope==="user"?"user":"shared")===t.scope&&e.at!==void 0===t.store&&(!t.store||(e.sourceId??null)===(t.storeSource??null)),pn=(e,t,n)=>e.find(o=>o.at!==void 0&&o.name===t&&(o.sourceId??null)===(n??null));function fr(e,t,n,o=!1){if(!e)return null;let r;if(e.scope==="shared")r=n.publish?{kind:"publish"}:xt(n)?{kind:null,why:"saveSharedLocked"}:null;else if(e.scope==="user"&&e.store){let a=pn(t,e.name,e.storeSource);r=n.store?a?{kind:"store",at:a.at,storeSource:e.storeSource??null}:{kind:"store",storeSource:n.sourceId??null}:null}else e.scope==="user"?r=n.host?{kind:"host"}:null:r=xt(n)?{kind:null,why:"saveNotInViews"}:null;return r&&r.kind&&o?{kind:null,why:"exportNeedsField"}:r}function hr(e,t,n){if(n.host)return{kind:"host",replaces:t.find(r=>r.scope==="user"&&r.at===void 0&&r.name===e)??null};let o=pn(t,e,n.sourceId)??pn(t,e,null);return o?{kind:"store",at:o.at,storeSource:o.sourceId??null,replaces:o}:{kind:"store",storeSource:n.sourceId??null,replaces:null}}var He=Object.freeze({count:100,text:5e5}),wo=!1;function jo(e){return e?e.length>He.text?(wo||(wo=!0,console.warn(`pivotkit: the browser store of views holds more than ${He.text} characters; it is not read, and the next save replaces it`)),[]):co(e).templates:[]}function ms(e,t){return jo(e).map((n,o)=>({name:n.name,view:n.view,at:o,...n.source?.id?{sourceId:n.source.id}:{}})).filter(n=>!n.sourceId||!t||n.sourceId===t)}function gr(e,t,n){let o=jo(e),r=o;if(t.remove!==void 0){if(o[t.remove]?.name!==t.removeName)throw new Error(n("changed",0));r=o.filter((s,i)=>i!==t.remove)}let a=!!(t.name&&t.view);if(a&&t.replace!==void 0){let s=o[t.replace];if(s?.name!==t.name)throw new Error(n("changed",0));r=o.map((i,d)=>d===t.replace?{name:s.name,view:t.view,...s.source?{source:s.source}:{}}:i)}else if(a){let s=t.sourceId;if(r=r.filter(i=>i.name!==t.name||(i.source?.id??void 0)!==s),r.push({name:t.name,view:t.view,...s?{source:{id:s}}:{}}),r.length>He.count)throw new Error(n("count",He.count))}let l=r.length?JSON.stringify(r.map(s=>nt(s.view,{name:s.name,source:s.source},{link:!0}))):null;if(a&&l&&l.length>He.text)throw new Error(n("text",He.text));return l}function kr(e,t,n,o,r){let a={count:n.storeFull,text:n.storeTooLarge,changed:n.storeChanged},l=gr(e,t,(s,i)=>L(a[s],{max:i.toLocaleString(o)}));if(!r(l))throw new Error(n.storeRefused)}function vr({view:e,plan:t,labels:n,onChart:o,close:r}){let a=Vt(e.chart);return Un.map(l=>k.default.createElement($e,{key:l,icon:Pt[l].icon,checked:e.display==="chart"&&a===l,hint:l==="auto"&&t?L(n.chartAutoNow,{type:n.chartTypes[t.name]}):void 0,onSelect:()=>{r(),o(l)},testId:`chart-${l}`},n.chartTypes[l]))}var Eo={slices:["auto","off","value","percent","both"],other:["auto","off","value"]},yr=["outside","inside"],wr=["auto","bottom","right","off"],Er=["auto","all","nth"],br=["auto","on","off"];function Nr({title:e,labels:t,onDisplay:n}){let[o,r]=(0,k.useState)(e??""),[a,l]=(0,k.useState)(e);return e!==a&&(l(e),r(e??"")),k.default.createElement("form",{className:"pk-inline-form",onSubmit:s=>{s.preventDefault(),n({title:o.trim()||null})}},k.default.createElement(Ee,{type:"text",value:o,onChange:r,onClear:()=>e?n({title:null}):void 0,clearLabel:t.clearText,placeholder:t.chartTitleNone,"aria-label":t.chartTitle,maxLength:200,"data-testid":"chart-title"}),k.default.createElement("button",{type:"submit",className:"pk-btn pk-primary",disabled:(o.trim()||null)===(e??null)},t.apply))}function Ve({title:e,info:t,children:n}){let o=(0,k.useId)();return k.default.createElement("div",{className:"pk-subsection",role:e?"group":void 0,"aria-labelledby":e?o:void 0},e?k.default.createElement("div",{className:`pk-subtitle${t?" pk-setting-row":""}`},k.default.createElement("span",{id:o},e),t?k.default.createElement(lt,{id:t,name:e}):null):null,n)}function xr({view:e,plan:t,labels:n,onDisplay:o}){let r=e.chart,a=t?t.name:Vt(r),l=qn.includes(a),s=Pt[a].axis,i=l?Eo.slices:Eo.other,d=!l&&(r.valueLabels==="percent"||r.valueLabels==="both")?"value":r.valueLabels;return k.default.createElement(Qe,{title:n.chartDisplay},k.default.createElement(Ve,{title:n.valueLabels},k.default.createElement("div",{className:"pk-choice-grid"},i.map(u=>k.default.createElement($e,{key:u,checked:d===u,onSelect:()=>o({valueLabels:u}),testId:`labels-${u}`},n.valueLabelNames[u])))),l?k.default.createElement(Ve,{title:n.labelPosition,info:"labelPosition"},k.default.createElement("div",{className:"pk-choice-grid"},yr.map(u=>k.default.createElement($e,{key:u,checked:(r.labelPosition??"outside")===u,disabled:r.valueLabels==="off",onSelect:()=>o({labelPosition:u}),testId:`label-position-${u}`},n.labelPositionNames[u])))):null,k.default.createElement(Ve,{title:n.legend},k.default.createElement("div",{className:"pk-choice-grid"},wr.map(u=>k.default.createElement($e,{key:u,checked:r.legend===u,onSelect:()=>o({legend:u}),testId:`legend-${u}`},n.legendNames[u])))),k.default.createElement(Ve,{title:n.chartTitle},k.default.createElement(Nr,{title:r.title,labels:n,onDisplay:o})),s?k.default.createElement(Ve,{title:n.axisLabels},k.default.createElement("div",{className:"pk-choice-grid"},Er.map(u=>k.default.createElement($e,{key:u,checked:r.axisLabels===u,onSelect:()=>o({axisLabels:u}),testId:`axis-${u}`},n.axisLabelNames[u])))):null,s&&e.rows.length>=2?k.default.createElement(Ve,{title:n.groupLabels,info:"groupLabels"},k.default.createElement("div",{className:"pk-choice-grid"},br.map(u=>k.default.createElement($e,{key:u,checked:r.groupLabels===u,onSelect:()=>o({groupLabels:u}),testId:`groups-${u}`},n.groupLabelNames[u])))):null,a==="line"||a==="area"?k.default.createElement(Ve,null,k.default.createElement(Cr,{checked:r.smooth,onChange:u=>o({smooth:u}),testId:"chart-smooth"},n.smoothLines)):null)}function ds({view:e,plan:t,labels:n,onChart:o,onDisplay:r,close:a}){return k.default.createElement(k.default.Fragment,null,k.default.createElement(Qe,{title:n.chartType},k.default.createElement("div",{className:"pk-choice-grid"},k.default.createElement(vr,{view:e,plan:t,labels:n,onChart:o,close:a}))),k.default.createElement(xr,{view:e,plan:t,labels:n,onDisplay:r}))}function Sr({labels:e,mod:t}){let n=o=>o==="Mod"?t==="\u2318"?"\u2318":e.keys.Mod:Object.hasOwn(e.keys,o)?e.keys[o]:o;return k.default.createElement("dl",{className:"pk-shortcuts","data-testid":"shortcuts"},ao.map(o=>k.default.createElement("div",{key:o.text,className:"pk-shortcut"},k.default.createElement("dt",null,o.keys.map((r,a)=>k.default.createElement(k.default.Fragment,{key:r},a?" + ":null,k.default.createElement("kbd",null,n(r))))),k.default.createElement("dd",null,e.shortcuts[o.text]))))}function Cr({checked:e,onChange:t,testId:n,children:o}){let r=ie();return k.default.createElement("label",{className:"pk-switch"},k.default.createElement("input",{type:"checkbox",name:r,checked:e,onChange:a=>t(a.target.checked),"data-testid":n}),k.default.createElement("span",{className:"pk-switch-track","aria-hidden":"true"}),k.default.createElement("span",{className:"pk-switch-text"},o))}function ps({view:e,labels:t,onTotal:n,onExpand:o,onCollapse:r,close:a,tips:l,mod:s,folding:i,help:d}){let u=ba({view:e,labels:t,folding:i,tips:l,explanations:d?.explanations??null,act:{total:n,expand:()=>o(t),collapse:()=>r(t),tipsOn:c=>l.onOn(c),resetTips:()=>l.onReset(),explain:c=>d?.explanations?.set(c)}});return k.default.createElement(it,{name:t.options,labels:t,topics:u,close:a,onPick:qo(a),panel:c=>c==="shortcuts"?k.default.createElement(Sr,{labels:t,mod:s}):null})}var qo=e=>t=>{t.closes&&e(),t.run?.()};function Uo({question:e,action:t,cancel:n,onYes:o,onNo:r,testId:a,yesId:l,noId:s,danger:i=!1,busy:d=!1,focusYes:u=!1}){let c=(0,k.useRef)(null),p=(0,k.useRef)(null);return(0,k.useEffect)(()=>{(u?p:c).current?.focus({preventScroll:!0})},[u]),k.default.createElement("div",{className:"pk-confirm pk-save-confirm",role:"group","aria-label":e,"data-testid":a},k.default.createElement("span",{className:"pk-confirm-text"},e),k.default.createElement("button",{ref:p,type:"button",className:i?"pk-btn pk-danger-btn":"pk-btn pk-primary",disabled:d,"data-autofocus":u?"":void 0,"data-testid":l,onClick:o},t),k.default.createElement("button",{ref:c,type:"button",className:"pk-btn",disabled:d,"data-autofocus":u?void 0:"","data-testid":s,onClick:r},n))}function Tr({labels:e,button:t,onSave:n,resolve:o,close:r}){let[a,l]=(0,k.useState)(""),[s,i]=(0,k.useState)(null),d=(0,k.useRef)(null),u=(0,k.useRef)(!1);return(0,k.useEffect)(()=>{s?u.current=!0:u.current&&d.current?.focus({preventScroll:!0})},[s]),s?k.default.createElement(Uo,{question:L(e.replaceConfirm,{name:s.name}),action:e.replaceAction,cancel:e.cancel,testId:"replace-confirm",yesId:"confirm-replace",noId:"cancel-replace",onYes:()=>{r(),n(s.name,s.target)},onNo:()=>i(null)}):k.default.createElement("form",{className:"pk-inline-form",onSubmit:c=>{c.preventDefault();let p=a.trim(),h=p?o(p):null;h?.replaces?i({name:p,target:h}):h&&(r(),n(p,h))}},k.default.createElement(Ee,{type:"text",value:a,onChange:l,clearLabel:e.clearText,placeholder:e.viewName,"aria-label":e.viewName,maxLength:120,"data-testid":"saved-view-name",inputRef:d}),k.default.createElement("button",{type:"submit",className:"pk-btn pk-primary",disabled:!a.trim()},t))}function Lr({check:e,labels:t,onCancel:n,close:o,title:r,quiet:a=!1}){let l=(0,k.useId)(),s=(0,k.useRef)(null);return(0,k.useEffect)(()=>{a||s.current?.focus({preventScroll:!0})},[a]),k.default.createElement("div",{className:"pk-load-check",role:"group","aria-labelledby":l,"data-testid":"load-check"},k.default.createElement("p",{id:l,className:"pk-load-check-title"},k.default.createElement(X,{name:"info",size:16}),k.default.createElement("span",null,r??t.loadCheckTitle)),k.default.createElement("ul",{className:"pk-load-check-lines"},e.lines.map((i,d)=>k.default.createElement("li",{key:d},i))),k.default.createElement("div",{className:"pk-load-check-actions"},e.switchTo?k.default.createElement("button",{ref:s,type:"button",className:"pk-btn pk-primary","data-autofocus":"","data-testid":"load-switch",onClick:()=>{o(),e.switchTo?.run()}},L(t.switchAndLoad,{source:e.switchTo.name})):null,k.default.createElement("button",{ref:e.switchTo?void 0:s,type:"button",className:e.switchTo?"pk-btn":"pk-btn pk-primary","data-autofocus":e.switchTo?void 0:"","data-testid":"load-anyway",onClick:()=>{o(),e.load()}},t.loadAnyway),k.default.createElement("button",{type:"button",className:"pk-btn","data-testid":"load-cancel",onClick:n},t.cancel)),e.switchTo?k.default.createElement("p",{className:"pk-hint"},t.switchStartsFresh):null)}function Or({labels:e,onLoadText:t,close:n}){let[o,r]=(0,k.useState)(""),[a,l]=(0,k.useState)(null),[s,i]=(0,k.useState)(null),[d,u]=(0,k.useState)(!1),c=(0,k.useRef)(null),p=(0,k.useRef)(null),h=(0,k.useId)(),g=ie();(0,k.useEffect)(()=>{s||p.current?.focus({preventScroll:!0})},[s]);let f=async N=>{u(!0);let w=await t(N);u(!1),typeof w=="string"?l(w):w?i(w):n()};return s?k.default.createElement(Lr,{check:s,labels:e,onCancel:()=>i(null),close:n}):k.default.createElement("form",{className:"pk-inline-form pk-load-view",onSubmit:N=>{N.preventDefault(),f(o)}},k.default.createElement("p",{className:"pk-hint"},e.loadViewHint),k.default.createElement(Ee,{multiline:!0,value:o,onChange:N=>{r(N),l(null)},clearLabel:e.clearText,"aria-label":e.loadViewText,placeholder:e.loadViewText,rows:4,spellCheck:!1,"aria-invalid":a?!0:void 0,"aria-describedby":a?h:void 0,"data-testid":"load-view-text",inputRef:p}),a?k.default.createElement("p",{id:h,className:"pk-form-problem",role:"alert","data-testid":"load-view-problem"},a):null,k.default.createElement("input",{ref:c,type:"file",name:`${g}-file`,accept:"application/json,.json",className:"pk-sr",tabIndex:-1,"aria-hidden":"true","aria-label":e.chooseFile,"data-testid":"load-view-file",onChange:async N=>{let w=N.target.files?.[0];if(N.target.value="",w){let v;try{v=w.size>Ke.text?null:await w.text()}catch{v=null}v===null?l(w.size>Ke.text?e.viewFailed.tooLarge:e.viewFailed.file):f(v)}}}),k.default.createElement("button",{type:"button",className:"pk-btn",onClick:()=>c.current?.click(),disabled:d,"data-testid":"load-view-choose"},k.default.createElement(X,{name:"file"}),k.default.createElement("span",{className:"pk-btn-text"},e.chooseFile)),k.default.createElement("button",{type:"submit",className:"pk-btn pk-primary",disabled:d||!o.trim(),"data-testid":"load-view-apply"},e.load))}function Ar(e,t){let n=(a,l,s,i,d)=>Promise.resolve().then(a).then(()=>(e.announce(L(l,{name:d})),!0),u=>(e.announce(Pn(s,i,u),{tone:"error"}),!1)),o=a=>kr(e.viewsText,a,t,e.locale,e.keep);return{save:(a,l)=>{let s=e.viewKey;return n(()=>a.kind==="publish"?e.onPublish(l,e.view):a.kind==="host"?e.onSave(l,e.view,{scope:"user"}):o({name:l,view:e.view,sourceId:e.sourceId,replace:a.at}),t.toastSaved,t.toastSaveFailed,t.toastSaveRejected,l).then(i=>i&&e.onSaved({name:l,scope:a.kind==="publish"?"shared":"user",store:a.kind==="store",storeSource:a.kind==="store"?a.storeSource:null},s))},remove:e.onDelete||e.store?a=>n(()=>a.at!==void 0?o({remove:a.at,removeName:a.name}):e.onDelete(a.name,{scope:a.scope}),t.toastDeleted,t.toastDeleteFailed,t.toastDeleteRejected,a.name):null,publish:e.onPublish?a=>n(()=>e.onPublish(a.name,e.normalized(a.view)),t.toastPublished,t.toastPublishFailed,t.toastPublishRejected,a.name):null}}function fs({templates:e,labels:t,onLoad:n,actions:o,close:r,share:a}){let{save:l,remove:s,publish:i}=Ar(o,t),d={host:!!o.onSave,store:!!o.store,publish:!!i,sourceId:o.sourceId},u=fr(o.loaded,e,d,o.empty),c=o.store&&!o.onSave,[p,h]=(0,k.useState)(null),[g,f]=(0,k.useState)(!1);(0,k.useEffect)(()=>{a?.prepare?.()},[a]);let N=!!i||e.some(D=>D.scope==="shared"&&D.deletable),w=Na(e),v=D=>e.flatMap((R,y)=>R.scope===D?[y]:[]),S=(D,R)=>{let y=e[D],M=w[D],q=xa(R,R.indexOf(D)),U=(ee,K)=>()=>h({kind:ee,t:y,focus:K});return{id:M,testId:`saved-view-${y.name}`,text:y.name,icon:"bookmark",current:pr(y,o.loaded),closes:!0,run:()=>n(y),info:y.scope==="shared"&&N&&!(s&&y.deletable)?"sharedView":void 0,actions:[...i&&y.scope==="user"?[{id:`publish:${M}`,testId:`publish-view-${y.name}`,text:y.name,label:L(t.publishView,{name:y.name}),icon:"upload",open:"confirm",backTo:`item:${M}`,run:U("publish",`item:${M}`)}]:[],...s&&y.deletable?[{id:`delete:${M}`,testId:`delete-view-${y.name}`,text:y.name,label:L(t.deleteView,{name:y.name}),icon:"trash",open:"confirm",backTo:`item:${M}`,run:U("delete",q===void 0?void 0:`item:${w[q]}`)}]:[]]}},C=v("shared"),x=v("user"),O=[];u&&O.push({id:"save-loaded",text:L(t.saveNamed,{name:o.loaded.name}),icon:"save",disabled:u.kind===null,reason:u.kind===null?t[u.why]:void 0,...u.kind==="publish"?{open:"confirm",run:()=>h({kind:"replaceShared"})}:{closes:!0,run:()=>l(u,o.loaded.name)}}),xt(d)&&O.push({id:"save-as",text:o.loaded?t.saveAs:`${t.saveView}\u2026`,icon:"save",open:"saveAs"});let B=a?dr(a,t):null,E=p?.kind==="replaceShared"?{text:L(t.replaceSharedConfirm,{name:o.loaded?.name}),action:t.replaceAction,testId:"replace-shared-confirm",yesId:"confirm-replace-shared",noId:"cancel-replace-shared"}:p?{text:L(p.kind==="publish"?t.publishConfirm:t.deleteConfirm,{name:p.t.name}),action:p.kind==="publish"?t.publishAction:t.deleteAction,testId:`${p.kind}-confirm`,yesId:`confirm-${p.kind}`,noId:`cancel-${p.kind}`}:null,A=[...O.length?[{id:"thisView",title:t.thisView,kind:"inline",titled:!0,groups:[{choices:O}]}]:[],...C.length?[{id:"sharedViews",title:t.sharedViews,kind:"inline",titled:!0,groups:[{choices:C.map(D=>S(D,C))}]}]:[],...x.length||xt(d)||!C.length?[{id:"myViews",title:t.myViews,kind:"inline",titled:!0,groups:[{choices:x.map(D=>S(D,x))}],note:x.length?c?t.storeNote:null:c?t.noViewsStore:t.noViews,noteId:c?"store-note":void 0}]:[],...B?[{id:"share",title:t.shareThisView,kind:"inline",titled:!0,groups:[{choices:[...a.canLink?[{id:"copy-link",text:t.copyLink,icon:"link",closes:!0,run:B.copyLink}]:[],{id:"copy-json",text:t.copyJson,icon:"copy",closes:!0,run:B.copyJson},{id:"download-view",text:t.downloadView,icon:"download",closes:!0,run:B.download},{id:"load-view",text:t.loadView,icon:"upload",open:"load"}]}],note:t.sharePrivacy,noteId:"share-privacy"}]:[],{id:"saveAs",title:t.saveAs,levelTitle:(o.loaded?t.saveAs:t.saveView).replace(/…$/,""),kind:"panel",hidden:!0},{id:"load",title:t.loadView,levelTitle:t.loadView.replace(/…$/,""),kind:"panel",hidden:!0},{id:"confirm",title:E?.action??"",kind:"panel",hidden:!0}],I=(D,R)=>D==="saveAs"?k.default.createElement(Tr,{labels:t,button:o.loaded?t.saveAs.replace(/…$/,""):t.save,onSave:(y,M)=>l(M,y),resolve:y=>hr(y,e,d),close:r}):D==="load"&&B?k.default.createElement(Or,{labels:t,onLoadText:B.loadText,close:r}):D==="confirm"&&E&&p?k.default.createElement(Uo,{question:E.text,action:E.action,cancel:t.cancel,danger:p.kind==="delete",focusYes:p.kind!=="replaceShared",busy:g,testId:E.testId,yesId:E.yesId,noId:E.noId,onNo:()=>R(),onYes:async()=>{if(p.kind==="replaceShared"){r(),l(u,o.loaded.name);return}f(!0);let y=await(p.kind==="publish"?i:s)?.(p.t);f(!1),y&&R(p.focus)}}):null;return k.default.createElement(it,{name:t.views,labels:t,topics:A,close:r,onPick:qo(r),panel:I,focusAgain:e.length})}function Ie({icon:e,text:t,info:n,onSelect:o,testId:r,disabled:a,reason:l}){let s=k.default.createElement($e,{icon:e,onSelect:o,disabled:a,reason:l,testId:r},t);return n?k.default.createElement("div",{className:"pk-setting-row"},s,k.default.createElement(lt,{id:n,name:t})):s}function hs({labels:e,onExport:t,chartReady:n,display:o,empty:r=!1,prepare:a,close:l}){(0,k.useEffect)(()=>{a()},[a]);let s=d=>()=>{l(),t(d)},i=r?{disabled:!0,reason:e.exportNeedsField}:{};return k.default.createElement(k.default.Fragment,null,k.default.createElement(Qe,{title:e.exportDownload},k.default.createElement(Ie,{icon:"file",text:e.exportXlsx,info:"exportXlsx",onSelect:s("xlsx"),...i,testId:"export-xlsx"}),k.default.createElement(Ie,{icon:"file",text:e.exportCsv,info:"exportCsv",onSelect:s("csv"),...i,testId:"export-csv"}),k.default.createElement(Ie,{icon:"image",text:e.exportPng,disabled:r||!n,reason:r?i.reason:o!=="chart"?e.exportPngNeedsChart:void 0,onSelect:s("png"),testId:"export-png"})),k.default.createElement(Qe,{title:e.exportCopy},k.default.createElement(Ie,{icon:"copy",text:e.copyTable,info:"copyTable",onSelect:s("copy-table"),...i,testId:"export-copy-table"}),k.default.createElement(Ie,{icon:"copy",text:e.copyDataJson,info:"copyDataJson",onSelect:s("copy-json"),...i,testId:"export-copy-json"})))}var Jo="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",En=null,an=null;function bn(){return an??=import("./export-6ILXDVGS.js").then(e=>(En=e,e),e=>{throw an=null,e}),an}var Ir=()=>En,$r=()=>{bn().catch(()=>{})};function fn(e,{doc:t,onExport:n,...o}){return n?.({...o,blob:e})===!1?!1:(Vo(e,o.fileName,t),!0)}async function Ko(e,{type:t,container:n,onExport:o,...r}){return o?.({...r,blob:new Blob([e],{type:t}),text:e})===!1?"kept":await dn(e,n)?"copied":"blocked"}async function ks(e,{fileName:t,result:n,locale:o,labels:r,limits:a,root:l,chartRef:s,announce:i,onExport:d}){r=io(r);let u=wn(t),c=l.current?.ownerDocument;try{if(e==="png"){let N=l.current?getComputedStyle(l.current).getPropertyValue("--pk-surface").trim():"",w=s.current?.getDataURL({type:"png",pixelRatio:2,backgroundColor:N||void 0}),v=`${u}.png`;w&&fn(cr(w),{kind:e,fileName:v,doc:c,onExport:d})&&i(L(r.toastExported,{file:v}));return}if(!n)return;let p=En??await bn(),h=Fn(n,{locale:o,labels:r.core,limits:a});if(e==="copy-table"||e==="copy-json"){let N=e==="copy-json",w=await Ko(N?p.toJson(h):p.toTsv(h),{kind:e,fileName:`${u}.${N?"json":"tsv"}`,type:N?"application/json":"text/tab-separated-values",container:l.current,onExport:d});w!=="kept"&&i(w==="copied"?N?r.toastDataCopied:r.toastTableCopied:r.toastCopyBlocked,w==="copied"?void 0:{tone:"error"});return}let g=`${u}.${e}`,f=e==="xlsx"?p.toXlsx(h,{sheetName:u}):p.toCsvBytes(h,{bom:!0});fn(new Blob([f],{type:e==="xlsx"?Jo:"text/csv;charset=utf-8"}),{kind:e,fileName:g,doc:c,onExport:d})&&i(L(r.toastExported,{file:g}))}catch(p){i(L(r.toastExportFailed,{message:Bt(p)}),{tone:"error"})}}function Rr({shown:e,count:t},n,o){return e<t?L(n.drillPart,{shown:e.toLocaleString(o),count:t.toLocaleString(o)}):W(n.drillCount,t,{lang:n.lang,locale:o})}async function Fr(e,{drill:t,encoded:n,labels:o,onExport:r,announce:a,root:l}){let{locale:s}=t,i={shown:t.rows.length,count:t.count},d=Rr(i,o,s),u=wn(t.name);try{let c=Ir()??await bn();if(e==="drill-copy"||e==="drill-json"){let v=e==="drill-json",S=v?JSON.stringify(Array.from(t.indices,x=>Hn(n,x)),null,2):c.toTsv([t.columns.map(x=>x.label??x.name),...t.rows]),C=await Ko(S,{kind:e,fileName:`${u}.${v?"json":"tsv"}`,type:v?"application/json":"text/tab-separated-values",container:l,onExport:r,rows:i});C!=="kept"&&a(C==="copied"?L(v?o.drillCopiedJson:o.drillCopied,{rows:d}):o.toastCopyBlocked,C==="copied"?void 0:{tone:"error"});return}let p=e==="drill-xlsx",h=Object.fromEntries(t.columns.map(v=>[v.name,v.label??v.name])),g={locale:s,formats:t.formats,labels:{fields:h,true:o.core.true,false:o.core.false}},f=`${u}.${p?"xlsx":"csv"}`,N=p?c.rowsToXlsx(n,t.indices,{...g,sheetName:t.name}):c.rowsToCsvBytes(n,t.indices,g),w=new Blob([N],{type:p?Jo:"text/csv;charset=utf-8"});fn(w,{kind:e,fileName:f,doc:l?.ownerDocument,onExport:r,rows:i})&&a(L(o.drillExported,{file:f,rows:d}))}catch(c){a(L(o.toastExportFailed,{message:Bt(c)}),{tone:"error"})}}var bo=new Set(["date","datetime","time"]);function Dr(e,{locale:t,labels:n,format:o}){let r=typeof o=="string"&&Me(o)?o.trim().toLowerCase():null;if(e.type==="date")return{text:Be(r&&bo.has(r.split(":")[0])?r:e.dateOnly?"date":"datetime",{locale:t}),numeric:!1};if(e.type==="number"){let a=new Intl.NumberFormat(t,{maximumFractionDigits:6});return{text:r&&!bo.has(r.split(":")[0])?Be(r,{locale:t}):s=>a.format(s),numeric:r!=="text"}}return e.type==="boolean"?{text:a=>a?n.true:n.false,numeric:!1}:{text:a=>String(a),numeric:!1}}function Mr(e,t,{locale:n,labels:o,formatOf:r=()=>{}}){let a=e.columns.map(s=>({column:s,...Dr(s,{locale:n,labels:o,format:r(s.name)})})),l=Array.from(t,s=>a.map(({column:i,text:d})=>{let u=i.codes[s],c=u<0?null:i.dict[u];return c==null?"":d(c)}));return{columns:a.map(s=>({name:s.column.name,numeric:s.numeric})),rows:l}}function Br(e,t,n,o){let r=[],a=[],l=(s,i,d)=>{let u=$n(e,s,d);for(let c=u;c&&c.parent;c=c.parent){let p=e.label(s,c,o.core);r.unshift(`${Q(i[c.depth-1],o.core)}: ${p}`),a.unshift(p)}};return l("cols",e.colFields,n),l("rows",e.rowFields,t),{title:r.length?r.join(" \xB7 "):o.core.grandTotal,name:a.length?a.join(" \u2013 "):o.core.grandTotal}}function Pr({result:e,rowPath:t,colPath:n,count:o,indices:r,formatOf:a,nameOf:l,infoOf:s},i){let d=Mr(e.encoded,r,{locale:e.locale,labels:i.core,formatOf:a}),u=d.columns.map(p=>({...p,label:l(p.name),description:s(p.name)?.description})),c=Object.fromEntries(d.columns.map(p=>[p.name,a(p.name)]).filter(([,p])=>typeof p=="string"));return{...Br(e,t,n,i),count:o,rows:d.rows,columns:u,indices:r,formats:c,locale:e.locale}}function ys({drill:e,onClose:t,labels:n,locale:o,exportContext:r}){let a=(0,P.useId)(),l=(0,P.useMemo)(()=>e?Pr(e,n):null,[e,n]),s=(0,P.useRef)(null),[i,d]=(0,P.useState)(!1),u=(0,P.useContext)(ht).size==="narrow",{onKeyDown:c}=Ln(s,!!l,i?()=>d(!1):t);if((0,P.useEffect)(()=>{l&&r&&$r()},[l,r]),!l)return null;let p=l.count.toLocaleString(o),h=l.rows.length<l.count,g=(f,N)=>()=>{N(),r&&Fr(f,{drill:l,labels:n,...r,root:r.root.current})};return P.default.createElement(P.default.Fragment,null,P.default.createElement("div",{className:"pk-scrim pk-drill-scrim",onClick:t,"aria-hidden":"true"}),P.default.createElement("div",{className:`pk-drill${i&&!u?" pk-drill-big":""}`,role:"dialog","aria-modal":"true","aria-labelledby":a,"data-testid":"drill-panel","data-pk-enlarged":i&&!u?"":void 0,ref:s,tabIndex:-1,onKeyDown:f=>{f.target instanceof Node&&s.current?.contains(f.target)&&c(f)}},P.default.createElement("div",{className:"pk-drill-head"},P.default.createElement("div",{className:"pk-drill-heading"},P.default.createElement("h2",{id:a},n.drillTitle),P.default.createElement("p",{className:"pk-drill-path"},l.title),P.default.createElement("p",{className:"pk-muted","data-testid":"drill-count"},h?L(n.drillShown,{shown:l.rows.length.toLocaleString(o),count:p}):W(n.drillCount,l.count,{lang:n.lang,locale:o}))),P.default.createElement("div",{className:"pk-drill-actions"},r?P.default.createElement(On,{label:n.exportLabel,icon:"download",text:n.exportLabel,role:"dialog",align:"end",testId:"drill-export",className:"pk-btn pk-small-btn"},f=>P.default.createElement(P.default.Fragment,null,h?P.default.createElement("p",{className:"pk-hint pk-menu-hint","data-testid":"drill-export-note"},L(n.drillExportNote,{shown:l.rows.length.toLocaleString(o),count:p})):null,P.default.createElement(Qe,{title:n.exportDownload},P.default.createElement(Ie,{icon:"file",text:n.drillCsv,onSelect:g("drill-csv",f),testId:"drill-csv"}),P.default.createElement(Ie,{icon:"file",text:n.drillXlsx,onSelect:g("drill-xlsx",f),testId:"drill-xlsx"})),P.default.createElement(Qe,{title:n.exportCopy},P.default.createElement(Ie,{icon:"copy",text:n.drillCopy,info:"drillCopy",onSelect:g("drill-copy",f),testId:"drill-copy"}),P.default.createElement(Ie,{icon:"copy",text:n.drillJson,info:"drillJson",onSelect:g("drill-json",f),testId:"drill-json"})))):null,u?null:P.default.createElement("button",{type:"button",className:"pk-btn pk-pressable pk-small-btn","data-pk-on":i?"":void 0,onClick:()=>d(f=>!f),"data-testid":"drill-enlarge"},P.default.createElement(X,{name:"enlarge",size:14}),P.default.createElement("span",{className:"pk-btn-text"},i?n.reduce:n.enlarge)),P.default.createElement("button",{type:"button",className:"pk-icon-btn",onClick:t,"data-autofocus":"","aria-label":n.close,title:n.close},P.default.createElement(X,{name:"x"})))),P.default.createElement("div",{className:"pk-drill-body",tabIndex:0,"aria-label":l.title},P.default.createElement("table",{className:"pk-drill-table"},P.default.createElement("thead",null,P.default.createElement("tr",null,l.columns.map(f=>P.default.createElement("th",{key:f.name,scope:"col",className:f.numeric?"pk-num":void 0,title:f.description,"aria-description":f.description},f.label??f.name)))),P.default.createElement("tbody",null,l.rows.map((f,N)=>P.default.createElement("tr",{key:N},l.columns.map((w,v)=>P.default.createElement("td",{key:w.name,className:w.numeric?"pk-num":void 0},w.numeric||f[v].length<24?f[v]:P.default.createElement("div",{className:"pk-drill-text"},f[v]))))))))))}function ws({api:e,close:t,labels:n}){let o=ro(),[r,a]=(0,Z.useState)(!1),[l,s]=(0,Z.useState)(0),i=(0,Z.useRef)(null),[d]=(0,Z.useState)(()=>!o),u=(0,Z.useRef)(e.load);return(0,Z.useEffect)(()=>{u.current=e.load}),(0,Z.useEffect)(()=>{if(o)return;let c=!0;return u.current().catch(()=>c&&a(!0)),()=>{c=!1}},[o,l]),(0,Z.useEffect)(()=>{let c=i.current?.closest(".pk-popover"),p=Je(c);d&&c&&(p===c||!p||!c.contains(p))&&c.querySelector("[data-pk-option], [data-autofocus]")?.focus({preventScroll:!0})},[d,o,r]),Z.default.createElement("div",{ref:i},o?Z.default.createElement(o.DataMenuPanel,{api:e,close:t}):r?Z.default.createElement("div",{className:"pk-menu-failed",role:"alert","data-testid":"menu-failed"},Z.default.createElement("p",null,n.menuFailed),Z.default.createElement("button",{type:"button",className:"pk-btn pk-small-btn","data-autofocus":"",onClick:()=>{a(!1),s(c=>c+1)}},n.tryAgain)):Z.default.createElement("p",{className:"pk-hint pk-menu-loading",role:"status"},n.loadingMenu))}export{as as AxisMenu,ds as ChartTypePanel,ws as DataMenu,ys as DrillPanel,hs as ExportPanel,rs as FilterMenu,ns as FilterPopover,Lr as LoadCheck,ps as OptionsPanel,ss as ValueMenu,fs as ViewsPanel,Zo as addMenuTexts,ea as hasMenuTexts,io as menuLabels,$r as prepareExporters,ks as runExport,ms as storedViews};
@@ -1 +1 @@
1
- import"./chunk-DCANE7XH.js";var k={item:"{subject}: {text}",quote:"\u201C{key}\u201D",position:"{subject} (no. {n} in {part})",view:"The view",sections:{sort:"Sorting",derived:"Groupings",totals:"Totals",collapsed:"Collapsed groups",display:"Table or chart",chart:"Chart",formatting:"Formatting"},settings:{display:"display",type:"chart type",valueLabels:"value labels",legend:"legend position",axisLabels:"axis labels",groupLabels:"group labels",labelPosition:"label position",other:"setting"},dropped:{rows:"it is left out of Rows",cols:"it is left out of Columns",values:"this value is left out",filters:"this filter is left out",sort:"the usual order is used",derived:"this grouping is left out",other:"it is left out"},codes:{notView:"this is not a pivotkit view - the report starts empty",notJson:"this is not valid JSON - the report starts empty",tooLarge:"the view is too large - the report starts empty",badVersion:"the view has an unknown version - the report starts empty",newerVersion:"the view comes from a newer pivotkit - the report starts empty; update pivotkit to open it",noMigration:"the view cannot be brought to this version - the report starts empty",unknownKey:"this setting is unknown here - it is ignored",notList:"this is not a list - nothing of it is used",tooMany:"more than {max} entries - only the first {max} are used",tooManyItems:"more than {max} items - only the first {max} are used",itemType:"the item \u201C{value}\u201D does not fit a {type} field - it is left out",unknownField:"the data has no field \u201C{field}\u201D - {dropped}",unknownFieldHere:"the data has no field of this name - {dropped}",placedTwice:"the field is in Rows or Columns twice - only its first place is used",groupingNoName:"the grouping has no name - it is left out",groupingNameTaken:"the data already has a field of this name - the grouping is left out",groupingNoSource:"the data has no field \u201C{field}\u201D to group - the grouping is left out",groupingUnknown:"the grouping \u201C{value}\u201D is unknown - it is left out",binsNeedNumber:"ranges need a number field, \u201C{field}\u201D is not one - the grouping is left out",groupingNeedsDate:"a date grouping needs a date field, \u201C{field}\u201D is not one - the grouping is left out",binSize:"ranges need a size above zero - the grouping is left out",notValueRef:"this is not a value - {dropped}",unknownAggregator:"the calculation \u201C{value}\u201D is unknown - {dropped}",aggregatorNeedsField:"{agg} needs a field - {dropped}",aggregatorType:"{agg} does not work on \u201C{field}\u201D ({type}) - {dropped}",unknownFormat:"the number format \u201C{value}\u201D is unknown - the usual format is used",badLabel:"the name is empty or longer than {max} characters - the usual name is used",unknownShowAs:"\u201CShow as\u201D \u201C{value}\u201D is unknown - the plain value is shown",showAsNotAdditive:"this \u201CShow as\u201D needs a sum or a count, not {agg} - the plain value is shown",showAsNotNumber:"{agg} gives no number to show as a share - the plain value is shown",unknownConditional:"the colour format \u201C{value}\u201D is unknown - the value is shown without colours",conditionalNotNumber:"colours need a number value - the value is shown without colours",colorScaleColors:"the colour scale needs two or three colours - the default colours are used",dataBarColor:"the bar colour is not a colour - the default colour is used",unknownFilterType:"the filter type \u201C{value}\u201D is unknown - this filter is left out",filterNoItems:"the filter lists no items - it is left out",filterLabelOp:"the text condition \u201C{value}\u201D is unknown - this filter is left out",filterText:"the text condition has no text - this filter is left out",filterNotNumber:"{agg} gives no number to filter by - this filter is left out",filterCount:"Top needs a whole number from 1 to {max} - this filter is left out",filterValue:"the condition needs a comparison and a number - this filter is left out",filterValue2:"\u201C{value}\u201D needs a second number - this filter is left out",sortNoItems:"the custom order lists no items - the usual order is used",sortedTwice:"the field is sorted twice - only its first sort is used",badTotals:"the totals cannot be read - the usual totals are shown",collapsedPath:"a collapsed group does not fit the fields - it is shown expanded",unknownSetting:"the {setting} \u201C{value}\u201D is unknown - the default is used",badTitle:"the title is empty or longer than {max} characters - the chart has no title",unknownLocale:"the language \u201C{value}\u201D is unknown - the report's language is used",unknownTimeZone:"the time zone \u201C{value}\u201D is unknown - the data's time zone is used",timeZoneMismatch:"the view was made for the time zone {value}, the data is in {zone} - times are read in {zone}"},other:"this part could not be used - it is left out"},p=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),n=(e,a)=>p(e)&&Object.hasOwn(e,a)?e[a]:void 0,f=e=>typeof e=="string"&&e.trim()!==""?e.trim():null,g=/^(rows|cols|values|filters|sort|derived)\[(\d+)\]/;function C(e,a){let s=f(n(e,"label"));if(s)return s;let i=n(e,"agg");if(typeof i!="string")return null;let o=n(e,"field");return a.value({field:typeof o=="string"?o:null,agg:i,label:null,showAs:null})}function N(e,a,s,i){if(e.code==="unknownKey")return i.fill(s.quote,{key:e.path});let o=g.exec(e.path);if(o){let r=n(a,o[1]),l=Array.isArray(r)?r[Number(o[2])]:void 0,d=o[1]==="values"?C(l,i):f(o[1]==="rows"||o[1]==="cols"?l:o[1]==="derived"?n(l,"name"):n(l,"field"));if(d)return o[1]==="values"||o[1]==="derived"?d:i.field(d)}let t=/^[a-z]*/i.exec(e.path)?.[0]??"";return n(i.labels.zones,t)??n(s.sections,t)??s.view}function c(e,a,s,i){let{labels:o,fill:t}=i,r=/^[a-z]*/i.exec(e.path)?.[0]??"",l=typeof e.code=="string"?e.code:"",d=l==="unknownField"&&/^(rows|cols|filters|sort)\[\d+\]$/.test(e.path)?"unknownFieldHere":l,m=l?n(s.codes,d)??s.other:"{message}",u=p(e.params)?e.params:{},w=o.core,v={dropped:n(s.dropped,r)??s.dropped.other,setting:n(s.settings,e.path.split(".").pop()??"")??s.settings.other,field:typeof u.field=="string"?i.field(u.field):"",value:u.value??"",agg:typeof u.agg=="string"?n(w.aggregators,u.agg)??u.agg:"",type:typeof u.type=="string"?n(o.types,u.type)??u.type:"",max:typeof u.max=="number"?u.max.toLocaleString(o.lang):"",zone:u.zone??"",message:e.message},[b,y=""]=s.item.split("{subject}"),h={text:t(m,v)};return{pre:t(b,h),subject:N(e,a,s,i),post:t(y,h)}}function D(e,a,s){let i=e.map(t=>({...c(t.issue,t.raw,a,s),at:g.exec(t.issue.path)})),o=new Map;for(let t of i){let r=o.get(t.subject)??new Set;r.add(t.at?t.at[0]:""),o.set(t.subject,r)}return i.map(({at:t,...r})=>{if(!t||o.get(r.subject).size<2)return r;let l=n(s.labels.zones,t[1])??n(a.sections,t[1])??t[1];return{...r,subject:s.fill(a.position,{subject:r.subject,n:Number(t[2])+1,part:l})}})}export{k as en,c as unusedItem,D as unusedItems};
1
+ import"./chunk-DCANE7XH.js";var k={item:"{subject}: {text}",quote:"\u201C{key}\u201D",position:"{subject} (no. {n} in {part})",view:"The view",sections:{sort:"Sorting",derived:"Groupings",totals:"Totals",collapsed:"Collapsed groups",display:"Table or chart",chart:"Chart",formatting:"Formatting"},settings:{display:"display",type:"chart type",valueLabels:"value labels",legend:"legend position",axisLabels:"axis labels",groupLabels:"group labels",labelPosition:"label position",other:"setting"},dropped:{rows:"it is left out of Rows",cols:"it is left out of Columns",values:"this value is left out",filters:"this filter is left out",sort:"the usual order is used",derived:"this grouping is left out",other:"it is left out"},codes:{notView:"this is not a pivotkit view - the report starts empty",notJson:"this is not valid JSON - the report starts empty",tooLarge:"the view is too large - the report starts empty",badVersion:"the view has an unknown version - the report starts empty",newerVersion:"the view comes from a newer pivotkit - the report starts empty; update pivotkit to open it",noMigration:"the view cannot be brought to this version - the report starts empty",unknownKey:"this setting is unknown here - it is ignored",notList:"this is not a list - nothing of it is used",tooMany:"more than {max} entries - only the first {max} are used",tooManyItems:"more than {max} items - only the first {max} are used",itemType:"the item \u201C{value}\u201D does not fit a {type} field - it is left out",unknownField:"the data has no field \u201C{field}\u201D - {dropped}",unknownFieldHere:"the data has no field of this name - {dropped}",placedTwice:"the field is in Rows or Columns twice - only its first place is used",groupingNoName:"the grouping has no name - it is left out",groupingNameTaken:"the data already has a field of this name - the grouping is left out",groupingNoSource:"the data has no field \u201C{field}\u201D to group - the grouping is left out",groupingUnknown:"the grouping \u201C{value}\u201D is unknown - it is left out",binsNeedNumber:"ranges need a number field, \u201C{field}\u201D is not one - the grouping is left out",groupingNeedsDate:"a date grouping needs a date field, \u201C{field}\u201D is not one - the grouping is left out",binSize:"ranges need a size above zero - the grouping is left out",notValueRef:"this is not a value - {dropped}",unknownAggregator:"the calculation \u201C{value}\u201D is unknown - {dropped}",aggregatorNeedsField:"{agg} needs a field - {dropped}",aggregatorType:"{agg} does not work on \u201C{field}\u201D ({type}) - {dropped}",unknownFormat:"the number format \u201C{value}\u201D is unknown - the usual format is used",badLabel:"the name is empty or longer than {max} characters - the usual name is used",unknownShowAs:"\u201CShow as\u201D \u201C{value}\u201D is unknown - the plain value is shown",showAsNotAdditive:"this \u201CShow as\u201D needs a sum or a count, not {agg} - the plain value is shown",showAsNotNumber:"{agg} gives no number to show as a share - the plain value is shown",unknownConditional:"the colour format \u201C{value}\u201D is unknown - the value is shown without colours",conditionalNotNumber:"colours need a number value - the value is shown without colours",colorScaleColors:"the colour scale needs two or three colours - the default colours are used",dataBarColor:"the bar colour is not a colour - the default colour is used",unknownFilterType:"the filter type \u201C{value}\u201D is unknown - this filter is left out",filterNoItems:"the filter lists no items - it is left out",filterLabelOp:"the text condition \u201C{value}\u201D is unknown - this filter is left out",filterText:"the text condition has no text - this filter is left out",filterNotNumber:"{agg} gives no number to filter by - this filter is left out",filterCount:"Top needs a whole number from 1 to {max} - this filter is left out",filterValue:"the condition needs a comparison and a number - this filter is left out",filterValue2:"\u201C{value}\u201D needs a second number - this filter is left out",filterCompareField:"only numbers and dates can be compared - this filter is left out",filterCompareValue:"the comparison needs an operator and a number or a date (2022-03-01) that fits the field - this filter is left out",filterRelativeField:"a range like \u201Clast 5 years\u201D needs a date field - this filter is left out",filterRelativeUnit:"the unit \u201C{value}\u201D is unknown (years, months or days) - this filter is left out",filterRelativeCount:"the range needs a whole number from 1 to {max} - this filter is left out",filterRelativeAnchor:"the range can count back from \u201Ctoday\u201D or from \u201Clatest\u201D (the latest record), not from \u201C{value}\u201D - this filter is left out",sortNoItems:"the custom order lists no items - the usual order is used",sortedTwice:"the field is sorted twice - only its first sort is used",badTotals:"the totals cannot be read - the usual totals are shown",collapsedPath:"a collapsed group does not fit the fields - it is shown expanded",unknownSetting:"the {setting} \u201C{value}\u201D is unknown - the default is used",badTitle:"the title is empty or longer than {max} characters - the chart has no title",unknownLocale:"the language \u201C{value}\u201D is unknown - the report's language is used",unknownTimeZone:"the time zone \u201C{value}\u201D is unknown - the data's time zone is used",timeZoneMismatch:"the view was made for the time zone {value}, the data is in {zone} - times are read in {zone}"},other:"this part could not be used - it is left out"},f=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),i=(e,a)=>f(e)&&Object.hasOwn(e,a)?e[a]:void 0,p=e=>typeof e=="string"&&e.trim()!==""?e.trim():null,g=/^(rows|cols|values|filters|sort|derived)\[(\d+)\]/;function C(e,a){let s=p(i(e,"label"));if(s)return s;let n=i(e,"agg");if(typeof n!="string")return null;let o=i(e,"field");return a.value({field:typeof o=="string"?o:null,agg:n,label:null,showAs:null})}function D(e,a,s,n){if(e.code==="unknownKey")return n.fill(s.quote,{key:e.path});let o=g.exec(e.path);if(o){let r=i(a,o[1]),u=Array.isArray(r)?r[Number(o[2])]:void 0,d=o[1]==="values"?C(u,n):p(o[1]==="rows"||o[1]==="cols"?u:o[1]==="derived"?i(u,"name"):i(u,"field"));if(d)return o[1]==="values"||o[1]==="derived"?d:n.field(d)}let t=/^[a-z]*/i.exec(e.path)?.[0]??"";return i(n.labels.zones,t)??i(s.sections,t)??s.view}function c(e,a,s,n){let{labels:o,fill:t}=n,r=/^[a-z]*/i.exec(e.path)?.[0]??"",u=typeof e.code=="string"?e.code:"",d=u==="unknownField"&&/^(rows|cols|filters|sort)\[\d+\]$/.test(e.path)?"unknownFieldHere":u,m=u?i(s.codes,d)??s.other:"{message}",l=f(e.params)?e.params:{},w=o.core,v={dropped:i(s.dropped,r)??s.dropped.other,setting:i(s.settings,e.path.split(".").pop()??"")??s.settings.other,field:typeof l.field=="string"?n.field(l.field):"",value:l.value??"",agg:typeof l.agg=="string"?i(w.aggregators,l.agg)??l.agg:"",type:typeof l.type=="string"?i(o.types,l.type)??l.type:"",max:typeof l.max=="number"?l.max.toLocaleString(o.lang):"",zone:l.zone??"",message:e.message},[b,y=""]=s.item.split("{subject}"),h={text:t(m,v)};return{pre:t(b,h),subject:D(e,a,s,n),post:t(y,h)}}function N(e,a,s){let n=e.map(t=>({...c(t.issue,t.raw,a,s),at:g.exec(t.issue.path)})),o=new Map;for(let t of n){let r=o.get(t.subject)??new Set;r.add(t.at?t.at[0]:""),o.set(t.subject,r)}return n.map(({at:t,...r})=>{if(!t||o.get(r.subject).size<2)return r;let u=i(s.labels.zones,t[1])??i(a.sections,t[1])??t[1];return{...r,subject:s.fill(a.position,{subject:r.subject,n:Number(t[2])+1,part:u})}})}export{k as en,c as unusedItem,N as unusedItems};
@@ -1 +1 @@
1
- import"./chunk-DCANE7XH.js";var e={item:"{subject}: {text}",quote:"\u201E{key}\u201C",position:"{subject} (Nr. {n}, {part})",view:"Die Ansicht",sections:{sort:"Sortierung",derived:"Gruppierungen",totals:"Summen",collapsed:"Zugeklappte Gruppen",display:"Tabelle oder Diagramm",chart:"Diagramm",formatting:"Formatierung"},settings:{display:"Darstellung",type:"Diagrammtyp",valueLabels:"Wertbeschriftung",legend:"Legendenposition",axisLabels:"Achsenbeschriftung",groupLabels:"Gruppenbeschriftung",labelPosition:"Beschriftungsposition",other:"Einstellung"},dropped:{rows:"es wird in Zeilen weggelassen",cols:"es wird in Spalten weggelassen",values:"dieser Wert wird weggelassen",filters:"dieser Filter wird weggelassen",sort:"die \xFCbliche Reihenfolge gilt",derived:"diese Gruppierung wird weggelassen",other:"es wird weggelassen"},codes:{notView:"das ist keine pivotkit-Ansicht - der Bericht beginnt leer",notJson:"das ist kein g\xFCltiges JSON - der Bericht beginnt leer",tooLarge:"die Ansicht ist zu gro\xDF - der Bericht beginnt leer",badVersion:"die Ansicht hat eine unbekannte Version - der Bericht beginnt leer",newerVersion:"die Ansicht stammt aus einem neueren pivotkit - der Bericht beginnt leer; aktualisieren Sie pivotkit, um sie zu \xF6ffnen",noMigration:"die Ansicht l\xE4sst sich nicht auf diese Version bringen - der Bericht beginnt leer",unknownKey:"diese Einstellung ist hier unbekannt - sie wird ignoriert",notList:"das ist keine Liste - nichts davon wird verwendet",tooMany:"mehr als {max} Eintr\xE4ge - nur die ersten {max} werden verwendet",tooManyItems:"mehr als {max} Eintr\xE4ge - nur die ersten {max} werden verwendet",itemType:"der Eintrag \u201E{value}\u201C passt nicht zu einem Feld vom Typ {type} - er wird weggelassen",unknownField:"die Daten haben kein Feld \u201E{field}\u201C - {dropped}",unknownFieldHere:"die Daten haben kein Feld mit diesem Namen - {dropped}",placedTwice:"das Feld steht zweimal in Zeilen oder Spalten - nur sein erster Platz gilt",groupingNoName:"die Gruppierung hat keinen Namen - sie wird weggelassen",groupingNameTaken:"die Daten haben schon ein Feld mit diesem Namen - die Gruppierung wird weggelassen",groupingNoSource:"die Daten haben kein Feld \u201E{field}\u201C zum Gruppieren - die Gruppierung wird weggelassen",groupingUnknown:"die Gruppierung \u201E{value}\u201C ist unbekannt - sie wird weggelassen",binsNeedNumber:"Bereiche brauchen ein Zahlenfeld, \u201E{field}\u201C ist keines - die Gruppierung wird weggelassen",groupingNeedsDate:"eine Datumsgruppierung braucht ein Datumsfeld, \u201E{field}\u201C ist keines - die Gruppierung wird weggelassen",binSize:"Bereiche brauchen eine Gr\xF6\xDFe \xFCber null - die Gruppierung wird weggelassen",notValueRef:"das ist kein Wert - {dropped}",unknownAggregator:"die Berechnung \u201E{value}\u201C ist unbekannt - {dropped}",aggregatorNeedsField:"{agg} braucht ein Feld - {dropped}",aggregatorType:"{agg} geht nicht mit \u201E{field}\u201C ({type}) - {dropped}",unknownFormat:"das Zahlenformat \u201E{value}\u201C ist unbekannt - das \xFCbliche Format gilt",badLabel:"der Name ist leer oder l\xE4nger als {max} Zeichen - der \xFCbliche Name gilt",unknownShowAs:"\u201EAnzeigen als\u201C \u201E{value}\u201C ist unbekannt - der Wert wird ohne Berechnung gezeigt",showAsNotAdditive:"dieses \u201EAnzeigen als\u201C braucht eine Summe oder Anzahl, nicht {agg} - der Wert wird ohne Berechnung gezeigt",showAsNotNumber:"{agg} ergibt keine Zahl f\xFCr einen Anteil - der Wert wird ohne Berechnung gezeigt",unknownConditional:"die Farbformatierung \u201E{value}\u201C ist unbekannt - der Wert wird ohne Farben gezeigt",conditionalNotNumber:"Farben brauchen einen Zahlenwert - der Wert wird ohne Farben gezeigt",colorScaleColors:"die Farbskala braucht zwei oder drei Farben - die Standardfarben werden verwendet",dataBarColor:"die Balkenfarbe ist keine Farbe - die Standardfarbe wird verwendet",unknownFilterType:"die Filterart \u201E{value}\u201C ist unbekannt - dieser Filter wird weggelassen",filterNoItems:"der Filter nennt keine Eintr\xE4ge - er wird weggelassen",filterLabelOp:"die Textbedingung \u201E{value}\u201C ist unbekannt - dieser Filter wird weggelassen",filterText:"die Textbedingung hat keinen Text - dieser Filter wird weggelassen",filterNotNumber:"{agg} ergibt keine Zahl zum Filtern - dieser Filter wird weggelassen",filterCount:"\u201EOberste\u201C braucht eine ganze Zahl von 1 bis {max} - dieser Filter wird weggelassen",filterValue:"die Bedingung braucht einen Vergleich und eine Zahl - dieser Filter wird weggelassen",filterValue2:"\u201E{value}\u201C braucht eine zweite Zahl - dieser Filter wird weggelassen",sortNoItems:"die eigene Reihenfolge nennt keine Eintr\xE4ge - die \xFCbliche Reihenfolge gilt",sortedTwice:"das Feld wird zweimal sortiert - nur seine erste Sortierung gilt",badTotals:"die Summen lassen sich nicht lesen - die \xFCblichen Summen werden gezeigt",collapsedPath:"eine zugeklappte Gruppe passt nicht zu den Feldern - sie wird aufgeklappt gezeigt",unknownSetting:"{setting} \u201E{value}\u201C ist unbekannt - die Voreinstellung gilt",badTitle:"der Titel ist leer oder l\xE4nger als {max} Zeichen - das Diagramm hat keinen Titel",unknownLocale:"die Sprache \u201E{value}\u201C ist unbekannt - die Sprache des Berichts gilt",unknownTimeZone:"die Zeitzone \u201E{value}\u201C ist unbekannt - die Zeitzone der Daten gilt",timeZoneMismatch:"die Ansicht wurde f\xFCr die Zeitzone {value} gemacht, die Daten sind in {zone} - Zeiten gelten in {zone}"},other:"dieser Teil konnte nicht verwendet werden - er wird weggelassen"};export{e as de};
1
+ import"./chunk-DCANE7XH.js";var e={item:"{subject}: {text}",quote:"\u201E{key}\u201C",position:"{subject} (Nr. {n}, {part})",view:"Die Ansicht",sections:{sort:"Sortierung",derived:"Gruppierungen",totals:"Summen",collapsed:"Zugeklappte Gruppen",display:"Tabelle oder Diagramm",chart:"Diagramm",formatting:"Formatierung"},settings:{display:"Darstellung",type:"Diagrammtyp",valueLabels:"Wertbeschriftung",legend:"Legendenposition",axisLabels:"Achsenbeschriftung",groupLabels:"Gruppenbeschriftung",labelPosition:"Beschriftungsposition",other:"Einstellung"},dropped:{rows:"es wird in Zeilen weggelassen",cols:"es wird in Spalten weggelassen",values:"dieser Wert wird weggelassen",filters:"dieser Filter wird weggelassen",sort:"die \xFCbliche Reihenfolge gilt",derived:"diese Gruppierung wird weggelassen",other:"es wird weggelassen"},codes:{notView:"das ist keine pivotkit-Ansicht - der Bericht beginnt leer",notJson:"das ist kein g\xFCltiges JSON - der Bericht beginnt leer",tooLarge:"die Ansicht ist zu gro\xDF - der Bericht beginnt leer",badVersion:"die Ansicht hat eine unbekannte Version - der Bericht beginnt leer",newerVersion:"die Ansicht stammt aus einem neueren pivotkit - der Bericht beginnt leer; aktualisieren Sie pivotkit, um sie zu \xF6ffnen",noMigration:"die Ansicht l\xE4sst sich nicht auf diese Version bringen - der Bericht beginnt leer",unknownKey:"diese Einstellung ist hier unbekannt - sie wird ignoriert",notList:"das ist keine Liste - nichts davon wird verwendet",tooMany:"mehr als {max} Eintr\xE4ge - nur die ersten {max} werden verwendet",tooManyItems:"mehr als {max} Eintr\xE4ge - nur die ersten {max} werden verwendet",itemType:"der Eintrag \u201E{value}\u201C passt nicht zu einem Feld vom Typ {type} - er wird weggelassen",unknownField:"die Daten haben kein Feld \u201E{field}\u201C - {dropped}",unknownFieldHere:"die Daten haben kein Feld mit diesem Namen - {dropped}",placedTwice:"das Feld steht zweimal in Zeilen oder Spalten - nur sein erster Platz gilt",groupingNoName:"die Gruppierung hat keinen Namen - sie wird weggelassen",groupingNameTaken:"die Daten haben schon ein Feld mit diesem Namen - die Gruppierung wird weggelassen",groupingNoSource:"die Daten haben kein Feld \u201E{field}\u201C zum Gruppieren - die Gruppierung wird weggelassen",groupingUnknown:"die Gruppierung \u201E{value}\u201C ist unbekannt - sie wird weggelassen",binsNeedNumber:"Bereiche brauchen ein Zahlenfeld, \u201E{field}\u201C ist keines - die Gruppierung wird weggelassen",groupingNeedsDate:"eine Datumsgruppierung braucht ein Datumsfeld, \u201E{field}\u201C ist keines - die Gruppierung wird weggelassen",binSize:"Bereiche brauchen eine Gr\xF6\xDFe \xFCber null - die Gruppierung wird weggelassen",notValueRef:"das ist kein Wert - {dropped}",unknownAggregator:"die Berechnung \u201E{value}\u201C ist unbekannt - {dropped}",aggregatorNeedsField:"{agg} braucht ein Feld - {dropped}",aggregatorType:"{agg} geht nicht mit \u201E{field}\u201C ({type}) - {dropped}",unknownFormat:"das Zahlenformat \u201E{value}\u201C ist unbekannt - das \xFCbliche Format gilt",badLabel:"der Name ist leer oder l\xE4nger als {max} Zeichen - der \xFCbliche Name gilt",unknownShowAs:"\u201EAnzeigen als\u201C \u201E{value}\u201C ist unbekannt - der Wert wird ohne Berechnung gezeigt",showAsNotAdditive:"dieses \u201EAnzeigen als\u201C braucht eine Summe oder Anzahl, nicht {agg} - der Wert wird ohne Berechnung gezeigt",showAsNotNumber:"{agg} ergibt keine Zahl f\xFCr einen Anteil - der Wert wird ohne Berechnung gezeigt",unknownConditional:"die Farbformatierung \u201E{value}\u201C ist unbekannt - der Wert wird ohne Farben gezeigt",conditionalNotNumber:"Farben brauchen einen Zahlenwert - der Wert wird ohne Farben gezeigt",colorScaleColors:"die Farbskala braucht zwei oder drei Farben - die Standardfarben werden verwendet",dataBarColor:"die Balkenfarbe ist keine Farbe - die Standardfarbe wird verwendet",unknownFilterType:"die Filterart \u201E{value}\u201C ist unbekannt - dieser Filter wird weggelassen",filterNoItems:"der Filter nennt keine Eintr\xE4ge - er wird weggelassen",filterLabelOp:"die Textbedingung \u201E{value}\u201C ist unbekannt - dieser Filter wird weggelassen",filterText:"die Textbedingung hat keinen Text - dieser Filter wird weggelassen",filterNotNumber:"{agg} ergibt keine Zahl zum Filtern - dieser Filter wird weggelassen",filterCount:"\u201EOberste\u201C braucht eine ganze Zahl von 1 bis {max} - dieser Filter wird weggelassen",filterValue:"die Bedingung braucht einen Vergleich und eine Zahl - dieser Filter wird weggelassen",filterValue2:"\u201E{value}\u201C braucht eine zweite Zahl - dieser Filter wird weggelassen",filterCompareField:"nur Zahlen und Daten lassen sich vergleichen - dieser Filter wird weggelassen",filterCompareValue:"der Vergleich braucht einen Operator und eine Zahl oder ein Datum (2022-03-01), das zum Feld passt - dieser Filter wird weggelassen",filterRelativeField:"ein Zeitraum wie \u201Eletzte 5 Jahre\u201C braucht ein Datumsfeld - dieser Filter wird weggelassen",filterRelativeUnit:"die Einheit \u201E{value}\u201C ist unbekannt (Jahre, Monate oder Tage) - dieser Filter wird weggelassen",filterRelativeCount:"der Zeitraum braucht eine ganze Zahl von 1 bis {max} - dieser Filter wird weggelassen",filterRelativeAnchor:"der Zeitraum kann ab \u201Etoday\u201C (heute) oder \u201Elatest\u201C (dem letzten Datensatz) zur\xFCckz\xE4hlen, nicht ab \u201E{value}\u201C - dieser Filter wird weggelassen",sortNoItems:"die eigene Reihenfolge nennt keine Eintr\xE4ge - die \xFCbliche Reihenfolge gilt",sortedTwice:"das Feld wird zweimal sortiert - nur seine erste Sortierung gilt",badTotals:"die Summen lassen sich nicht lesen - die \xFCblichen Summen werden gezeigt",collapsedPath:"eine zugeklappte Gruppe passt nicht zu den Feldern - sie wird aufgeklappt gezeigt",unknownSetting:"{setting} \u201E{value}\u201C ist unbekannt - die Voreinstellung gilt",badTitle:"der Titel ist leer oder l\xE4nger als {max} Zeichen - das Diagramm hat keinen Titel",unknownLocale:"die Sprache \u201E{value}\u201C ist unbekannt - die Sprache des Berichts gilt",unknownTimeZone:"die Zeitzone \u201E{value}\u201C ist unbekannt - die Zeitzone der Daten gilt",timeZoneMismatch:"die Ansicht wurde f\xFCr die Zeitzone {value} gemacht, die Daten sind in {zone} - Zeiten gelten in {zone}"},other:"dieser Teil konnte nicht verwendet werden - er wird weggelassen"};export{e as de};
package/dist/element.js CHANGED
@@ -1 +1 @@
1
- import{a,b,c,d}from"./chunks/chunk-BL6ROOK3.js";import"./chunks/chunk-CETTRMB6.js";import"./chunks/chunk-JGSNJX3N.js";import"./chunks/chunk-MB64GADT.js";import"./chunks/chunk-DCANE7XH.js";export{a as EVENTS,c as PivotReportElement,b as TAG,d as define};
1
+ import{a,b,c,d}from"./chunks/chunk-D2E6EFC7.js";import"./chunks/chunk-IBQE3N74.js";import"./chunks/chunk-WNTTPBZ5.js";import"./chunks/chunk-WXBFHMFX.js";import"./chunks/chunk-O2TTHYGT.js";import"./chunks/chunk-MB64GADT.js";import"./chunks/chunk-DCANE7XH.js";export{a as EVENTS,c as PivotReportElement,b as TAG,d as define};
@@ -0,0 +1 @@
1
+ var Ie=Object.defineProperty;var _=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(r){throw n=[r],r}};var ae=(e,t)=>{for(var n in t)Ie(e,n,{get:t[n],enumerable:!0})};var E,$=_(()=>{E=class extends Error{constructor(t,n,r={}){super(n),this.name="PivotkitError",this.code=t,this.details=r}}});function P(e){let t=e&&e.limits;if(t==null)return K;if(typeof t!="object")throw new E("INVALID_OPTION","options.limits must be an object");let n={...K};for(let r of Object.keys(t)){let o=t[r];if(!Object.hasOwn(K,r))throw new E("INVALID_OPTION",`unknown limit "${r}"`);if(!Number.isInteger(o)||o<1)throw new E("INVALID_OPTION",`limits.${r} must be a whole number of 1 or more`);if(Object.hasOwn(Q,r)&&o>Q[r])throw new E("INVALID_OPTION",`limits.${r} must be at most ${Q[r]}`);n[r]=o}return Object.freeze(n)}var K,Q,q=_(()=>{$();K=Object.freeze({json:5e6,name:256,axisFields:8,values:16,filters:128,items:1e5,derived:64,sort:64,collapsed:1e4,topCount:1e6,rows:1e6,groups:5e5,pivotCells:2e6,work:1e8,cells:2e6,cacheEntries:16,fileBytes:104857600,columns:1e3,importCells:1e7,textLength:32767,archiveEntries:1e4,unpackedBytes:524288e3}),Q=Object.freeze({groups:2**27})});function Le(e,t,n,r=0,o=0,a=0,l=0){if(e>=100)return Date.UTC(e,t-1,n,r,o,a,l);let s=new Date(Date.UTC(2e3,t-1,n,r,o,a,l));return s.setUTCFullYear(e),s.getTime()}function R(e){let t=Ce.exec(e.trim());if(!t)return null;let n=t[8],r=+t[1],o=+t[2],a=+t[3],l=t[4]===void 0?0:+t[4],s=t[5]===void 0?0:+t[5],i=t[6]===void 0?0:+t[6],f=t[7];if(o<1||o>12||a<1||l>23||s>59||i>59)return null;let c=Le(r,o,a,l,s,i,f?Math.round(+`0.${f}`*1e3):0);if(new Date(c).getUTCDate()!==a)return null;let m=null;if(n)if(n==="Z")m=0;else{let w=n.slice(1).replace(":",""),g=Number(w.slice(0,2)),d=Number(w.slice(2)||0);if(g>23||d>59)return null;m=(n[0]==="-"?-1:1)*(g*60+d)}return{ms:c,offsetMinutes:m}}var Ce,le=_(()=>{Ce=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?(Z|[+-]\d{2}(?::?\d{2})?)?)?$/});function N(e,t,n,r={}){return new E("INVALID_FILE",`"${t}": ${n}`,{reason:e,file:t,...r})}function C(e,t,n,r,o){let a=l=>l.toLocaleString("en-US");return new E("LIMIT_EXCEEDED",`"${r}" has more than ${a(n)} ${o} (limits.${e}): load a smaller extract of it, or a host can raise limits.${e}`,{limit:e,value:t,max:n,file:r})}function A(e,t,n,r,o){if(t>n)throw C(e,t,n,r,o)}function x(e,t){let n=e&&typeof e=="object"&&typeof e.name=="string"?e.name:"";return ke(String(t?.name??n??"")).slice(0,256)||"file"}async function F(e,t,n){if(e instanceof Uint8Array)return A("fileBytes",e.byteLength,t.fileBytes,n,"bytes"),e;if(e instanceof ArrayBuffer)return A("fileBytes",e.byteLength,t.fileBytes,n,"bytes"),new Uint8Array(e);if(typeof Blob<"u"&&e instanceof Blob)return A("fileBytes",e.size,t.fileBytes,n,"bytes"),new Uint8Array(await e.arrayBuffer());throw new E("INVALID_ARGUMENT","read(file): file must be a File, a Blob, an ArrayBuffer or a Uint8Array")}function B(e){let t=e??{};if(typeof t!="object")throw new E("INVALID_OPTION","read(file, options): options must be an object");return{...t,limits:P(t)}}function Pe(e,t){let n=r=>typeof r=="number"?r.toLocaleString("en-US"):r;switch(e){case"ENCODING":return`Read as ${t.encoding}.`;case"SEPARATOR":return`Values separated by ${t.name}.`;case"LINES_SKIPPED":return`${n(t.count)} line(s) above the column names were skipped (a title block).`;case"COLUMN_RENAMED":return t.from===""?`Column ${n(t.position)} has no name; it is named "${t.to}".`:`Column "${t.from}" is named "${t.to}".`;case"COLUMNS_RENAMED_MORE":return`${n(t.count)} more columns were renamed.`;case"COLUMN_DROPPED":return`Column ${n(t.position)} has no name and no values and was left out.`;case"COLUMNS_ADDED":return`${n(t.rows)} row(s) have more values than there are column names; the extra values are in ${n(t.count)} column(s) named "Column \u2026".`;case"ROWS_EMPTY":return`${n(t.count)} empty row(s) were left out.`;case"TEXT_CUT":return`${n(t.count)} value(s) longer than ${n(t.max)} characters were cut.`;case"CHARACTERS_REMOVED":return`Control or text direction characters were removed from ${n(t.count)} value(s).`;case"DATE_ORDER":return`Dates in "${t.column}" were read as ${t.order==="mdy"?"month/day/year":"day/month/year"}; the values fit both.`;case"VALUES_NOT_CONVERTED":return`${n(t.count)} value(s) in "${t.column}" are no ${t.type} and are empty.`;case"JSON_PROPERTY":return`The rows were read from "${t.property}".`;case"JSON_FLATTENED":return`Nested values became columns named with a dot ("${t.example}").`;case"SHEET":return Number(t.count)>1?`Read sheet "${t.sheet}" of ${n(t.count)} sheets.`:`Read sheet "${t.sheet}".`;case"USED_RANGE":return`The sheet's used range reaches row ${n(t.usedRow)}; values end at row ${n(t.lastRow)}, the empty rows below were skipped.`;case"ERROR_CELLS":return`${n(t.count)} cell(s) hold an Excel error (such as #N/A) and are empty.`;default:return e}}function T(e,t={}){let n={};for(let[r,o]of Object.entries(t))n[r]=typeof o=="string"?o.replace(v,"").slice(0,256):o;return{code:e,params:n,message:Pe(e,n)}}function ke(e){return e.replace(v,"").replace(fe," ").trim()}function ee(e,t,n,r,o,a){if(t<1||t>12||n<1||r>23||o>59||a>59)return null;let l=new Date(Date.UTC(2e3,t-1,n));if(l.setUTCFullYear(e),l.getUTCDate()!==n)return null;let s=`${String(e).padStart(4,"0")}-${I(t)}-${I(n)}`;return r===0&&o===0&&a===0?s:`${s}T${I(r)}:${I(o)}:${I(a)}`}function ce(e){return[+e[1],+e[2],+e[3],e[4]===void 0?0:+e[4],e[5]===void 0?0:+e[5],e[6]===void 0?0:+e[6]]}function ne(e,t){if(e.length>40)return null;if(R(e)!==null)return e;let n=de.exec(e);if(n){let[r,o,a,l,s,i]=ce(n);return ee(a,o,r,l,s,i)}if(n=me.exec(e),n){let[r,o,a,l,s,i]=ce(n);return t==="mdy"?ee(a,r,o,l,s,i):ee(a,o,r,l,s,i)}return null}function ze(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);r>=48&&r<=57&&t++}return t}function V(e,t){if(e.length>40||!(t===","?Ve:Ue).test(e))return null;let n=Number(t===","?e.replaceAll(".","").replace(",","."):e);return Number.isFinite(n)?n:null}function Ge(e){return je.test(e)?!0:/^[+-]?\d+$/.test(e)&&ze(e)>ve}function pe(e){let t=e.toLowerCase();return Fe.has(t)?!0:Be.has(t)?!1:null}function k(e){let t=e.getTime();if(!Number.isFinite(t)||Math.abs(t)>864e13)return null;let n=Math.round(t/1e3)*1e3;Math.abs(t-n)<=2&&(t=n);let r=new Date(t).toISOString();return t%he===0?r.slice(0,10):t%1e3===0?r.slice(0,19):r.slice(0,23)}function He(e,t,n){if(t==="string"&&e.every(l=>l===null||typeof l=="string"))return{values:e,failed:0};let r=Je[t],o=new Array(e.length),a=0;for(let l=0;l<e.length;l++){let s=e[l];if(s===null){o[l]=null;continue}let i=r(s,n);i===void 0?(o[l]=null,a++):o[l]=i}return{values:o,failed:a}}function We(e,t){let n=0,r=0,o=0,a=0;for(let s of e)s!==null&&(typeof s=="number"?n++:typeof s=="boolean"?r++:s instanceof Date?o++:a++);let l=n+r+o+a;return l===0?{type:"string"}:a===0?n===l?{type:"number"}:r===l?{type:"boolean"}:o===l?{type:"date"}:{type:"string"}:a!==l?n===0&&r===0&&e.every(s=>s===null||s instanceof Date||typeof s=="string"&&R(s)!==null)?{type:"date"}:{type:"string"}:t.textNumbers===!1?{type:e.every(s=>s===null||R(s)!==null)?"date":"string"}:Xe(e,t)}function Xe(e,t){let n=!0,r=!0,o=!0,a=!0,l=!1,s=!1,i=!0,f=!0;for(let c of e)if(c!==null){if(n&&pe(c)===null&&(n=!1),r&&R(c)===null&&(r=!1),o&&(!de.test(c)||ne(c,"dmy")===null)&&(o=!1),a){let m=c.length<=40?me.exec(c):null;m?(+m[1]>12&&(l=!0),+m[2]>12&&(s=!0)):a=!1}if((i||f)&&(Ge(c)?(i=!1,f=!1):(i&&V(c,".")===null&&(i=!1),f&&V(c,",")===null&&(f=!1))),!n&&!r&&!o&&!a&&!i&&!f)return{type:"string"}}if(n)return{type:"boolean"};if(r||o)return{type:"date"};if(a&&!(l&&s)){let c=l?"dmy":s?"mdy":t.dateOrder;if(e.every(w=>w===null||ne(w,c)!==null))return{type:"date",dateOrder:c,ambiguousOrder:!l&&!s}}return i&&f?{type:"number",decimal:t.decimal}:i?{type:"number",decimal:"."}:f?{type:"number",decimal:","}:{type:"string"}}function te(e,t,n){if(e==null)return null;switch(typeof e){case"string":return ue(e,t,n);case"number":return Number.isFinite(e)?e:null;case"boolean":return e;case"bigint":return Number.isSafeInteger(Number(e))?Number(e):String(e);case"object":if(e instanceof Date)return Number.isNaN(e.getTime())?null:e;try{return ue(JSON.stringify(e)??"",t,n)}catch{return null}default:return null}}function ue(e,t,n){let r=e;return $e.test(r)&&(r=r.replace(v,""),n.removed++),r=r.replace(fe," ").trim(),r.length>t&&(r=r.slice(0,t),n.cut++),r===""?null:r}function G(e){let{file:t,limits:n}=e,r={decimal:e.hints?.decimal??".",dateOrder:e.hints?.dateOrder??(!e.locale||/^en-US$/i.test(e.locale)?"mdy":"dmy"),...e.hints?.serialDates?{serialDates:!0}:{},...e.hints?.textNumbers===!1?{textNumbers:!1}:{}},o=[],a={removed:0,cut:0,empty:0,extraRows:0},l=[],s=null,i=0,f=0,c=[],m=()=>{A("columns",l.length+1,n.columns,t,"columns"),l.push(new Array(f).fill(null))},w=u=>{let p=0,y=new Array(u.length);for(let h=0;h<u.length;h++){let b=te(u[h],n.textLength,a);y[h]=b,b!==null&&(p=h+1)}if(p===0){a.empty++;return}for(p>i&&a.extraRows++,p>l.length&&(A("columns",p,n.columns,t,"columns"),A("importCells",(f+1)*p,n.importCells,t,"values (rows x columns)"));l.length<p;)m();f++,A("rows",f,n.rows,t,"rows"),A("importCells",f*l.length,n.importCells,t,"values (rows x columns)");for(let h=0;h<l.length;h++)l[h].push(h<p?y[h]:null)},g=u=>{s=u.map(p=>{let y=te(p,n.name,{removed:0,cut:0});return y===null?null:y instanceof Date?k(y):String(y)}),i=s.length,A("columns",i,n.columns,t,"columns");for(let p=0;p<i;p++)l.push([])},d=()=>{let u=c??[];if(c=null,s===null){let p=0,y=u.map(O=>{let ie=0;for(let Re of O)te(Re,n.textLength,{removed:0,cut:0})!==null&&ie++;return ie});for(let O of y)p=Math.max(p,O);let h=y.findIndex(O=>O>0&&O*2>=p);h<0&&(h=u.length),y.slice(0,h).filter(O=>O>0).length>0&&o.push(T("LINES_SKIPPED",{count:h})),g(h<u.length?u[h]:[]),u.splice(0,h+1)}for(let p of u)w(p)};return{header(u){g(u)},row(u){if(c!==null&&s===null){c.push(u),c.length>=Me&&d();return}c!==null&&d(),w(u)},get rowCount(){return f+(c?.length??0)},note(u,p){o.push(T(u,p))},finish(u){return c!==null&&d(),Qe({header:s??[],columns:l,rowCount:f,notes:o,counts:a,hints:r,limits:n,types:u})}}}function Ke(e,t,n){let r=[],o=new Set,a=0,l=(i,f,c)=>{a++,a<=Z&&n.push(T("COLUMN_RENAMED",{position:i,from:f,to:c}))},s=i=>{let f=i;for(let c=2;o.has(f.toLowerCase());c++)f=`${i} (${c})`;return f};for(let i=0;i<t;i++){let f=i<e.length?e[i]:null,c;f===null||f===""?(c=s(`Column ${i+1}`),i<e.length&&l(i+1,"",c)):(c=s(f),c!==f&&l(i+1,f,c)),o.add(c.toLowerCase()),r.push(c)}return a>Z&&n.push(T("COLUMNS_RENAMED_MORE",{count:a-Z})),r}function Qe({header:e,columns:t,rowCount:n,notes:r,counts:o,hints:a,limits:l,types:s}){let i=[];for(let u=0;u<t.length;u++){if(!(u<e.length&&e[u]!==null&&e[u]!=="")&&t[u].every(y=>y===null)){u<e.length&&r.push(T("COLUMN_DROPPED",{position:u+1}));continue}i.push(u)}let f=i.map(u=>u<e.length?e[u]:null),c=Ke(f,i.length,r),m=i.map(u=>t[u]),w=i.filter(u=>u>=e.length).length;o.extraRows>0&&w>0&&r.push(T("COLUMNS_ADDED",{rows:o.extraRows,count:w})),o.empty>0&&r.push(T("ROWS_EMPTY",{count:o.empty})),o.cut>0&&r.push(T("TEXT_CUT",{count:o.cut,max:l.textLength})),o.removed>0&&r.push(T("CHARACTERS_REMOVED",{count:o.removed}));let g={columns:c,types:[],data:[],raw:m,detected:[],rowCount:n,notes:r,hints:a},d=m.map(u=>We(u,a));return g.detected=d.map(u=>u.type),d.forEach((u,p)=>{u.ambiguousOrder&&r.push(T("DATE_ORDER",{column:c[p],order:u.dateOrder}))}),qe(g,s,d)}function qe(e,t,n){let r=Ze(e.columns,t),o=e.notes.filter(s=>s.code!=="VALUES_NOT_CONVERTED"),a=[],l=[];for(let s=0;s<e.columns.length;s++){let i=n?.[s],f=r[s]??e.detected[s],c=i&&i.type===f?{...e.hints,...i.decimal?{decimal:i.decimal}:{},...i.dateOrder?{dateOrder:i.dateOrder}:{}}:e.hints;if(e.types[s]===f&&e.data[s]!==void 0){a.push(f),l.push(e.data[s]);let g=e.notes.find(d=>d.code==="VALUES_NOT_CONVERTED"&&d.params.column===e.columns[s]);g&&o.push(g);continue}let{values:m,failed:w}=He(e.raw[s],f,c);w>0&&o.push(T("VALUES_NOT_CONVERTED",{column:e.columns[s],type:f,count:w})),a.push(f),l.push(m)}return{...e,types:a,data:l,notes:o}}function Ze(e,t){let n=new Array(e.length).fill(void 0);if(Array.isArray(t))for(let r=0;r<e.length;r++)U.includes(t[r])&&(n[r]=t[r]);else if(t&&typeof t=="object"){let r=new Map;for(let o of Object.keys(t))U.includes(t[o])&&r.set(o.toLowerCase(),t[o]);e.forEach((o,a)=>{n[a]=r.get(o.toLowerCase())})}return n}var U,St,Z,Me,j,v,$e,fe,z,Ue,Ve,je,ve,de,me,Fe,Be,I,he,Ye,Je,L=_(()=>{$();q();le();U=Object.freeze(["string","number","date","boolean"]),St=Object.freeze(["ENCODING","SEPARATOR","LINES_SKIPPED","COLUMN_RENAMED","COLUMNS_RENAMED_MORE","COLUMN_DROPPED","COLUMNS_ADDED","ROWS_EMPTY","TEXT_CUT","CHARACTERS_REMOVED","DATE_ORDER","VALUES_NOT_CONVERTED","JSON_PROPERTY","JSON_FLATTENED","SHEET","USED_RANGE","ERROR_CELLS"]),Z=20,Me=50,j=16384,v=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f\u00ad\u061c\u180e\u200b\u200e-\u200f\u202a-\u202e\u2060-\u2064\u2066-\u206f\ufeff\u{E0000}-\u{E007F}]|[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/gu,$e=new RegExp(v.source,"u"),fe=/[\t\r\n\u2028\u2029]+/g;z=()=>new Promise(e=>setTimeout(e,0));Ue=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?$/,Ve=/^[+-]?(?:\d{1,3}(?:\.\d{3})+|\d+)(?:,\d+)?$/,je=/^[+-]?0\d/,ve=15,de=/^(\d{1,2})\.(\d{1,2})\.(\d{4})(?:[ T,]+(\d{1,2}):(\d{2})(?::(\d{2}))?)?$/,me=/^(\d{1,2})\/(\d{1,2})\/(\d{4})(?:[ T,]+(\d{1,2}):(\d{2})(?::(\d{2}))?)?$/,Fe=new Set(["true","wahr"]),Be=new Set(["false","falsch"]),I=e=>String(e).padStart(2,"0");he=864e5,Ye=Date.UTC(1899,11,30);Je={string(e){return typeof e=="string"?e:e instanceof Date?k(e)??void 0:String(e)},number(e,t){if(typeof e=="number")return e;if(typeof e=="boolean")return e?1:0;if(typeof e=="string")return V(e,t.decimal)??V(e,t.decimal===","?".":",")??void 0},date(e,t){if(e instanceof Date)return k(e)??void 0;if(typeof e=="string")return ne(e,t.dateOrder)??void 0;if(typeof e=="number"&&t.serialDates&&e>0&&e<2958466)return k(new Date(Math.round((Ye+e*he)/1e3)*1e3))??void 0},boolean(e){if(typeof e=="boolean")return e;if(typeof e=="number")return e===1?!0:e===0?!1:void 0;if(typeof e=="string"){let t=pe(e);if(t!==null)return t;let n=e.toLowerCase();if(n==="yes"||n==="1")return!0;if(n==="no"||n==="0")return!1}}}});function tt(e){let t=Math.min(e.length,4096)&-2;if(t<8)return!1;let n=0;for(let r=1;r<t;r+=2)e[r]===0&&e[r-1]!==0&&n++;return n>t/2*.9}function J(e,t){for(let s of et)if(Y(e,s.bytes))throw N("WRONG_TYPE",t,`this is ${s.what}, not text.`);let n,r=0;Y(e,[239,187,191])?(n="utf-8",r=3):Y(e,[255,254])?(n="utf-16le",r=2):Y(e,[254,255])?(n="utf-16be",r=2):tt(e)&&(n="utf-16le");let o=e.subarray(r),a;if(n)a=new TextDecoder(n,{fatal:!1,ignoreBOM:!0}).decode(o);else try{a=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}).decode(o),n="utf-8"}catch{a=new TextDecoder("windows-1252",{ignoreBOM:!0}).decode(o),n="windows-1252"}let l=a.indexOf("\0");if(l!==-1&&l<a.length-1)throw N("BINARY",t,"this file holds binary data, not text.");return{text:l===-1?a:a.slice(0,l),encoding:nt[n]}}var et,Y,nt,re=_(()=>{L();et=[{bytes:[80,75,3,4],what:"a ZIP archive (an Excel workbook .xlsx is one); load it with a spreadsheet reader, or save it as CSV"},{bytes:[208,207,17,224,161,177,26,225],what:"an old Excel workbook (.xls) or a password-protected file; save it as .xlsx or CSV"},{bytes:[37,80,68,70],what:"a PDF document"},{bytes:[31,139],what:"a gzip archive; unpack it first"}],Y=(e,t)=>t.every((n,r)=>e[r]===n);nt={"utf-8":"UTF-8","utf-16le":"UTF-16 (little endian)","utf-16be":"UTF-16 (big endian)","windows-1252":"Windows-1252"}});var Ee={};ae(Ee,{detectSeparator:()=>ge,read:()=>lt,splitRows:()=>oe});function oe(e,t,n,r,o={}){let a=t.charCodeAt(0),l=e.length,s=n,i=o.line??1;for(;s<l;){let f=i,c=[];for(;;){let m;if(e.charCodeAt(s)===we){let g=i,d=s+1,u="";for(;;){let y=e.indexOf('"',d);if(y===-1){if(o.sample)return l;throw N("UNCLOSED_QUOTE",o.file??"file",`the quote that opens a value in line ${g} is never closed.`,{line:g})}if(i+=it(e,d,y),u+=e.slice(d,y),e.charCodeAt(y+1)===we){u+='"',d=y+2;continue}s=y+1;break}let p=s;for(;p<l;){let y=e.charCodeAt(p);if(y===a||y===D||y===H)break;p++}m=p>s?u+e.slice(s,p):u,s=p}else{let g=s;for(;g<l;){let d=e.charCodeAt(g);if(d===a||d===D||d===H)break;g++}m=e.slice(s,g),s=g}if(c.push(m),o.maxFields!==void 0&&c.length>o.maxFields)throw C("columns",c.length,o.maxFields,o.file??"file","columns");let w=s<l?e.charCodeAt(s):-1;if(w===a){s++;continue}w===H?(s+=e.charCodeAt(s+1)===D?2:1,i++):w===D&&(s++,i++);break}if(r(c,f))break}return o.line=i,s}function it(e,t,n){let r=0;for(let o=t;o<n;o++){let a=e.charCodeAt(o);(a===D||a===H&&e.charCodeAt(o+1)!==D)&&r++}return r}function ge(e,t,n){let r=e.slice(t,t+ot),o={sep:n??",",score:-1,width:1},a=n?[n,...ye.filter(l=>l!==n)]:ye;for(let l of a){let s=new Map,i=0;oe(r,l,0,m=>(m.length===1&&m[0]===""||(s.set(m.length,(s.get(m.length)??0)+1),i++),i>=st),{sample:!0});let f=1,c=0;for(let[m,w]of s)m>1&&(w>c||w===c&&m>f)&&(f=m,c=w);f>1&&(c>o.score||c===o.score&&f>o.width)&&(o={sep:l,score:c,width:f})}return o.sep}function at(e){if(!e)return".";try{return new Intl.NumberFormat(e).formatToParts(1.5).find(n=>n.type==="decimal")?.value===","?",":"."}catch{return"."}}async function lt(e,t){let n=B(t),r=x(e,n);n.signal?.throwIfAborted();let o=await F(e,n.limits,r);n.onProgress?.({phase:"read",done:o.length,total:o.length});let{text:a,encoding:l}=J(o,r);n.signal?.throwIfAborted();let s=0,i=typeof n.separator=="string"&&n.separator.length===1?n.separator:null,f=/^sep=(.)\r?\n/i.exec(a.slice(0,8));f&&(s=f[0].length,i??=f[1]),i??=ge(a,s,/\.tsv$/i.test(r)?" ":void 0);let c=G({file:r,limits:n.limits,locale:n.locale,hints:{decimal:i===";"?",":at(n.locale)}});c.note("ENCODING",{encoding:l}),c.note("SEPARATOR",{separator:i,name:rt[i]??`"${i}"`});let m=s,w={file:r,line:s>0?2:1,maxFields:n.limits.columns};for(;m<a.length;){let g=0;m=oe(a,i,m,d=>(c.row(d),++g>=j),w),n.onProgress?.({phase:"parse",done:m,total:a.length}),m<a.length&&(await z(),n.signal?.throwIfAborted())}return n.signal?.throwIfAborted(),c.finish(n.types)}var ye,rt,ot,st,we,D,H,Ae=_(()=>{L();re();ye=[",",";"," ","|"],rt={",":"commas",";":"semicolons"," ":"tabs","|":"vertical bars"},ot=65536,st=100,we=34,D=10,H=13});var be={};ae(be,{read:()=>ut});function Ne(e){if(Array.isArray(e)){let t=e.find(n=>n!=null);return t===void 0?{kind:"objects",rows:[]}:Array.isArray(t)&&e.every(n=>n===null||Array.isArray(n))?{kind:"arrays",rows:e}:S(t)&&e.every(n=>n===null||S(n))?{kind:"objects",rows:e}:null}return S(e)?Array.isArray(e.columns)&&Array.isArray(e.data)&&e.data.every(t=>Array.isArray(t))?{kind:"columnar",columns:e.columns,data:e.data}:Array.isArray(e.columns)&&Array.isArray(e.rows)?{kind:e.rows.every(t=>t===null||Array.isArray(t))?"header":"objects",columns:e.columns,rows:e.rows}:null:null}function ct(e){let t=Ne(e);if(t)return{shape:t,property:null};if(!S(e))return null;let n=null;for(let r of Object.keys(e)){let o=Ne(e[r]);if(o&&(o.kind!=="objects"||o.rows.length>0)){let a=o.rows?.length??o.data?.[0]?.length??0;(!n||a>n.size)&&(n={shape:o,property:r,size:a})}}return n}function Oe(e,t,n,r,o,a){for(let l of Object.keys(e)){let s=t+l,i=e[l];S(i)&&n<Te&&Object.keys(i).length>0?Oe(i,`${s}.`,n+1,r,o,a):r.has(s)||(n>0&&(a.nested??=s),o(),r.set(s,r.size))}}function _e(e,t,n,r,o){for(let a of Object.keys(e)){let l=t+a,s=e[a];if(S(s)&&n<Te&&Object.keys(s).length>0)_e(s,`${l}.`,n+1,r,o);else{let i=r.get(l);i!==void 0&&(o[i]=s)}}}async function ut(e,t){let n=B(t),r=x(e,n);n.signal?.throwIfAborted();let o=await F(e,n.limits,r);n.onProgress?.({phase:"read",done:o.length,total:o.length});let{text:a}=J(o,r),l;try{l=JSON.parse(a)}catch(d){throw N("INVALID_JSON",r,`this is no valid JSON (${String(d.message).slice(0,200)}).`)}n.signal?.throwIfAborted();let s=ct(l);if(!s)throw N("NO_TABLE",r,"no table found: the JSON must be an array of objects, an array of arrays, { columns, rows } or { columns, data }, or an object with one of these under a property.");let{shape:i,property:f}=s,c=G({file:r,limits:n.limits,locale:n.locale,hints:{textNumbers:!1}});f!==null&&c.note("JSON_PROPERTY",{property:f});let m=n.limits,w=0,g=async d=>{++w%j===0&&(n.onProgress?.({phase:"parse",done:w,total:d}),await z(),n.signal?.throwIfAborted())};if(i.kind==="columnar"){let d=i.data[0]?.length??0;if(i.columns.length!==i.data.length)throw N("NO_TABLE",r,`"columns" names ${i.columns.length} columns, but "data" holds ${i.data.length} arrays.`);if(!i.data.every(u=>u.length===d))throw N("NO_TABLE",r,'the arrays in "data" have different lengths.');A("columns",i.columns.length,m.columns,r,"columns"),A("rows",d,m.rows,r,"rows"),c.header(i.columns);for(let u=0;u<d;u++)c.row(i.data.map(p=>p[u])),await g(d)}else if(i.kind==="arrays"||i.kind==="header"){let d=i.rows;A("rows",d.length,m.rows+1,r,"rows");let u=0;for(i.kind==="header"?c.header(i.columns):(c.header(d[0]??[]),u=1);u<d.length;u++)c.row(d[u]??[]),await g(d.length)}else{let d=i.rows;A("rows",d.length,m.rows,r,"rows");let u=new Map;if(Array.isArray(i.columns))for(let h of i.columns)typeof h=="string"&&!u.has(h)&&u.set(h,u.size);let p=()=>A("columns",u.size+1,m.columns,r,"columns"),y={nested:null};for(let h of d)h&&Oe(h,"",0,u,p,y);y.nested&&c.note("JSON_FLATTENED",{example:y.nested}),c.header([...u.keys()]);for(let h of d){let b=new Array(u.size).fill(null);h&&_e(h,"",0,u,b),c.row(b),await g(d.length)}}return n.signal?.throwIfAborted(),c.finish(n.types)}var Te,S,xe=_(()=>{L();re();Te=4,S=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)});$();q();L();var W=1,ft=/^[a-z0-9][a-z0-9-]{0,63}$/,dt=/^\.[a-z0-9]{1,16}$/,mt=/^[a-z0-9][a-z0-9!#$&^_.+-]*\/[a-z0-9][a-z0-9!#$&^_.+-]*$/,De=["reader"];function X(e){let t=e,n=r=>{throw new E("INVALID_ARGUMENT",`plugin ${typeof t?.name=="string"?`"${t.name.slice(0,64)}" `:""}${r}`)};return(t===null||typeof t!="object"||Array.isArray(t))&&n("must be an object"),t.apiVersion!==W&&n(`uses plugin API version ${JSON.stringify(t.apiVersion)}; this pivotkit-core supports version ${W}. Use a version of the plugin made for API ${W}, or update pivotkit.`),De.includes(t.kind)||n(`has kind ${JSON.stringify(t.kind)}; API ${W} knows ${De.map(r=>`"${r}"`).join(", ")}`),(typeof t.name!="string"||!ft.test(t.name))&&n('needs a name of lower-case letters, digits and "-"'),(typeof t.label!="string"||t.label.trim()===""||t.label.length>100)&&n("needs a label of 1 to 100 characters"),(!Array.isArray(t.accept)||t.accept.length===0||!t.accept.every(r=>typeof r=="string"&&(dt.test(r)||mt.test(r))))&&n('needs accept: file name extensions (".xlsx") and media types ("text/csv"), in lower case'),typeof t.load!="function"&&n("needs load(): a function that imports the reader"),Object.freeze({apiVersion:t.apiVersion,kind:t.kind,name:t.name,label:t.label,accept:[...t.accept],load:t.load})}var pt=X({apiVersion:1,kind:"reader",name:"csv",label:"CSV or text",accept:[".csv",".tsv",".txt",".tab","text/csv","text/tab-separated-values","text/plain"],load:()=>Promise.resolve().then(()=>(Ae(),Ee))}),ht=X({apiVersion:1,kind:"reader",name:"json",label:"JSON",accept:[".json","application/json"],load:()=>Promise.resolve().then(()=>(xe(),be))}),yt=Object.freeze([pt,ht]);function wt(e,t=[]){for(let s of t)X(s);let n=[...t,...yt],r=typeof e?.name=="string"?e.name.toLowerCase():"",o=r.lastIndexOf("."),a=o===-1?"":r.slice(o);if(a){let s=n.find(i=>i.accept.includes(a));if(s)return s}let l=typeof e?.type=="string"?e.type.toLowerCase().split(";")[0].trim():"";return l?n.find(s=>s.accept.includes(l)):void 0}var se=new WeakMap;async function gt(e){let t=X(e),n=se.get(e);return n||(n=Promise.resolve(t.load()).then(r=>{let o=r,a=o?.default&&typeof o.read!="function"?o.default:o;if(!a||typeof a.read!="function")throw new E("INVALID_ARGUMENT",`plugin "${t.name}": its load() must give a module with read(file, options)`);if(a.sheets!==void 0&&typeof a.sheets!="function")throw new E("INVALID_ARGUMENT",`plugin "${t.name}": sheets must be a function when given`);return a}),n.catch(()=>se.delete(e)),se.set(e,n)),n}async function Se(e,t={}){let n=x(e,t),r=P(t);if(e&&typeof e=="object"&&typeof e.size=="number"&&e.size>r.fileBytes)throw C("fileBytes",e.size,r.fileBytes,n,"bytes");let o=t.reader??wt(e,t.plugins);if(!o)throw N("NO_READER",n,"no reader for this kind of file.");let a=await gt(o),l={...t};return delete l.plugins,delete l.reader,Et(await a.read(e,l),o.name)}function Et(e,t){let n=o=>{throw new E("INVALID_ARGUMENT",`plugin "${t}": read() must return a table of pivotkit-core/import (createTable().finish()); ${o}`)};(!e||typeof e!="object"||!Array.isArray(e.columns)||!Array.isArray(e.types)||!Array.isArray(e.data)||!Array.isArray(e.notes))&&n("it needs columns, types, data and notes");let r=e.data[0]?.length??0;return(e.types.length!==e.columns.length||e.data.length!==e.columns.length)&&n("columns, types and data differ in length"),e.columns.every(o=>typeof o=="string")||n("a column name is no string"),e.types.every(o=>U.includes(o))||n("a type is none of string, number, date, boolean"),e.data.every(o=>Array.isArray(o)&&o.length===r)||n("the columns differ in length"),e}var M=globalThis;M.onmessage=async e=>{let{file:t,options:n}=e.data??{};try{let r=await Se(t,{...n,plugins:[],onProgress:o=>M.postMessage({type:"progress",progress:o})});M.postMessage({type:"done",table:r})}catch(r){let o=r;M.postMessage({type:"error",error:{code:typeof o?.code=="string"?o.code:void 0,message:String(o?.message??o),details:o?.details&&typeof o.details=="object"?{...o.details}:{}}})}};M.postMessage({type:"ready"});
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as o,b as r,c as t,d as e}from"./chunks/chunk-BL6ROOK3.js";import"./chunks/chunk-CETTRMB6.js";import"./chunks/chunk-JGSNJX3N.js";import"./chunks/chunk-MB64GADT.js";import"./chunks/chunk-DCANE7XH.js";e();export{o as EVENTS,t as PivotReportElement,r as TAG,e as define};
1
+ import{a as o,b as r,c as t,d as e}from"./chunks/chunk-D2E6EFC7.js";import"./chunks/chunk-IBQE3N74.js";import"./chunks/chunk-WNTTPBZ5.js";import"./chunks/chunk-WXBFHMFX.js";import"./chunks/chunk-O2TTHYGT.js";import"./chunks/chunk-MB64GADT.js";import"./chunks/chunk-DCANE7XH.js";e();export{o as EVENTS,t as PivotReportElement,r as TAG,e as define};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pivotkit-element",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "The pivot report builder of pivotkit as the web component <pivot-report>, with its own React: for Angular, PHP and plain HTML pages without React.",
5
5
  "license": "MIT",
6
6
  "author": "eizedev <oss@eize.dev>",
@@ -62,8 +62,8 @@
62
62
  "@dnd-kit/core": "6.3.1",
63
63
  "@dnd-kit/sortable": "10.0.0",
64
64
  "echarts": "6.1.0",
65
- "pivotkit-core": "0.2.0",
66
- "pivotkit-react": "0.2.0",
65
+ "pivotkit-core": "0.4.0",
66
+ "pivotkit-react": "0.4.0",
67
67
  "react": "18.3.1",
68
68
  "react-dom": "18.3.1"
69
69
  },