@simai-studio/view 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +1 -1
  2. package/dist/package-receipt.json +97 -96
  3. package/dist/smart/view/component.json +10 -2
  4. package/dist/smart/view/component.json.gz +0 -0
  5. package/dist/smart/view/js/view.js +23 -6
  6. package/dist/smart/view/js/view.js.gz +0 -0
  7. package/dist/smart/view/js/view.min.js +1 -1
  8. package/dist/smart/view/js/view.min.js.gz +0 -0
  9. package/dist/smart/view/smart.manifest.json +10 -3
  10. package/dist/smart/view/smart.manifest.json.gz +0 -0
  11. package/dist/smart/view/static/default/open-record.html +11 -16
  12. package/dist/smart/view/static/default/open-record.html.gz +0 -0
  13. package/dist/smart/view/static/default/reference.html +11 -16
  14. package/dist/smart/view/static/default/reference.html.gz +0 -0
  15. package/dist/smart/view-properties/component.json +10 -2
  16. package/dist/smart/view-properties/component.json.gz +0 -0
  17. package/dist/smart/view-properties/css/view-properties.css +24 -19
  18. package/dist/smart/view-properties/css/view-properties.css.gz +0 -0
  19. package/dist/smart/view-properties/css/view-properties.min.css +1 -1
  20. package/dist/smart/view-properties/css/view-properties.min.css.gz +0 -0
  21. package/dist/smart/view-properties/js/view-properties.js +306 -171
  22. package/dist/smart/view-properties/js/view-properties.js.gz +0 -0
  23. package/dist/smart/view-properties/js/view-properties.min.js +92 -121
  24. package/dist/smart/view-properties/js/view-properties.min.js.gz +0 -0
  25. package/dist/smart/view-properties/lang/en.json +0 -7
  26. package/dist/smart/view-properties/lang/en.json.gz +0 -0
  27. package/dist/smart/view-properties/lang/ru.json +0 -7
  28. package/dist/smart/view-properties/lang/ru.json.gz +0 -0
  29. package/dist/smart/view-properties/smart.manifest.json +12 -9
  30. package/dist/smart/view-properties/smart.manifest.json.gz +0 -0
  31. package/dist/smart/view-properties/template/default.css +22 -19
  32. package/dist/smart/view-properties/template/default.css.gz +0 -0
  33. package/dist/smart/view-properties/template/default.js +8 -10
  34. package/dist/smart/view-properties/template/default.js.gz +0 -0
  35. package/dist/smart/view-table/component.json +10 -2
  36. package/dist/smart/view-table/component.json.gz +0 -0
  37. package/dist/smart/view-table/js/view-table.js +375 -88
  38. package/dist/smart/view-table/js/view-table.js.gz +0 -0
  39. package/dist/smart/view-table/js/view-table.min.js +56 -56
  40. package/dist/smart/view-table/js/view-table.min.js.gz +0 -0
  41. package/dist/smart/view-table/smart.manifest.json +11 -4
  42. package/dist/smart/view-table/smart.manifest.json.gz +0 -0
  43. package/dist/smart/view-table/template/default.js +1 -1
  44. package/dist/smart/view-table/template/default.js.gz +0 -0
  45. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- (()=>{"use strict";var e={"51250bf01ab0"(e,t,n){const s="sf-pref:",i=/^[\w.*:-]+(?:\/[\w.*:/-]+)?$/u;function r(){try{return globalThis.localStorage??null}catch{return null}}function a(e){return"string"==typeof e&&e.length>0&&e.length<=200&&i.test(e)}function o(e,t){try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}function l(e){return null==e?null:JSON.parse(JSON.stringify(e))}"undefined"!=typeof globalThis&&(globalThis.SF=globalThis.SF||{},globalThis.SF.Preferences||(globalThis.SF.Preferences=function(){const e={adapter:null,values:new Map},t=new Map,n=new Map;let i=!1;const c=()=>{if(i)return;const e=globalThis.document?.querySelector?.('script[type="application/json"][data-sf-preferences], script#sf-preferences[type="application/json"]');if(e){i=!0;try{f.preload(JSON.parse(e.textContent||"{}"))}catch{}}},u=(e,n)=>{for(const s of t.get(e)??[])try{s(l(n),e)}catch(t){console.error("SF.Preferences listener failed",e,t)}},d=e=>{const t=r();if(!t)return null;try{const n=t.getItem(s+e);return null===n?null:JSON.parse(n)}catch{return null}},h=(e,t)=>{const n=r();if(n)try{null===t?n.removeItem(s+e):n.setItem(s+e,JSON.stringify(t))}catch{}},p=t=>{clearTimeout(n.get(t)),n.delete(t);const s=e.adapter;if(!s)return;const i=e.values.has(t)?e.values.get(t):d(t);try{const e=null===i?s.remove?.(t):s.save?.(t,l(i));Promise.resolve(e).catch(e=>console.warn("SF.Preferences: the host did not keep",t,e))}catch(e){console.warn("SF.Preferences: the host did not keep",t,e)}},m=t=>{e.adapter&&(clearTimeout(n.get(t)),n.set(t,setTimeout(()=>p(t),400)))},f={read:t=>a(t)?(c(),e.values.has(t)?l(e.values.get(t)):l(d(t))):null,readMerged(...e){const t={};let n=!1;for(const s of e.flat()){const e=f.read(s);e&&"object"==typeof e&&!Array.isArray(e)&&(Object.assign(t,e),n=!0)}return n?t:null},write(t,n){if(!a(t))return!1;const s=l(n);return JSON.stringify(f.read(t))===JSON.stringify(s)||(e.values.has(t)&&e.values.set(t,s),h(t,s),m(t)),!0},remove:t=>!!a(t)&&(e.values.has(t)&&e.values.set(t,null),h(t,null),m(t),u(t,null),!0),subscribe:(e,n)=>a(e)&&"function"==typeof n?(t.has(e)||t.set(e,new Set),t.get(e).add(n),()=>t.get(e)?.delete(n)):()=>{},preload(t){if(t&&"object"==typeof t)for(const[n,s]of Object.entries(t)){if(!a(n))continue;const t=l(s),i=f.read(n);e.values.set(n,t),h(n,t),o(i,t)||u(n,t)}},useHost(t){if(!t||"function"!=typeof t.save)throw new TypeError("A preferences host saves: {save(key, value)}");return e.adapter=t,f},async load(t){const n=[].concat(t).filter(t=>a(t)&&!e.values.has(t));if(n.length&&"function"==typeof e.adapter?.load)try{f.preload(await e.adapter.load(n))}catch(e){console.warn("SF.Preferences: the host did not answer",n,e)}},get hosted(){return Boolean(e.adapter)},flush(){for(const e of[...n.keys()])p(e)}};return globalThis.addEventListener?.("storage",t=>{if(!t.key?.startsWith(s)||t.storageArea!==r())return;const n=t.key.slice(8);if(e.values.has(n))return;let i=null;try{i=null===t.newValue?null:JSON.parse(t.newValue)}catch{i=null}u(n,i)}),globalThis.addEventListener?.("pagehide",()=>f.flush()),c(),Object.freeze(f)}()));const c=globalThis.SF?.Preferences,u=c;n.d(t,["A",0,u])},"9ce1a42b2a85"(e,t,n){n.d(t,{AC:()=>a,MC:()=>d,SB:()=>u,cy:()=>l,d2:()=>o});const s=/^(\d{4}-\d{2}-\d{2})(?:[T ](\d{2}):(\d{2})((?::\d{2})(?:\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/u,i=/^\d{4}-\d{2}-\d{2}$/u;function r(e){return e&&"object"==typeof e&&!Array.isArray(e)&&"value"in e?e.value:e}function a(e){const t=r(e);if(null==t||""===t)return{raw:t??null,known:!0,date:"",time:"",rest:"",zone:""};const n="string"==typeof t?t.trim().match(s):null;return n?{raw:t,known:!0,date:n[1],time:n[2]?`${n[2]}:${n[3]}`:"",rest:n[4]||"",zone:n[5]||""}:{raw:t,known:!1,date:"",time:"",rest:"",zone:""}}function o(e){const t=String(e??"").trim().replace(/[_\s]/gu,"");if(""===t||":"===t)return"";const n=t.match(/^(\d{1,2})[:.]?(\d{2})$/u);if(!n)return null;const s=Number(n[1]),i=Number(n[2]);return s>23||i>59?null:`${String(s).padStart(2,"0")}:${n[2]}`}function l(e,t){const n=String(t?.date??"").trim(),s=o(t?.time);if(null===s)return{error:"timeInvalid"};if(!n&&!s)return{value:null};if(!i.test(n))return{error:n?"dateInvalid":"dateMissing"};if(!s)return{error:"timeMissing"};const r=e?.known?e:null;if(r&&r.date===n&&r.time===s)return{value:r.raw};return{value:`${n}T${s}${r&&r.time===s?r.rest:":00"}${r&&r.time?r.zone:""}`}}const c=/^(\d{2}):(\d{2})((?::\d{2})(?:\.\d+)?)?$/u;function u(e){const t=r(e);if(null==t||""===t)return{raw:t??null,known:!0,time:"",rest:""};const n="string"==typeof t?t.trim().match(c):null;return n&&null!==o(`${n[1]}:${n[2]}`)?{raw:t,known:!0,time:`${n[1]}:${n[2]}`,rest:n[3]||""}:{raw:t,known:!1,time:"",rest:""}}function d(e,t){const n=o(t);if(null===n)return{error:"timeInvalid"};if(!n)return{value:null};const s=e?.known?e:null;return s&&s.time===n?{value:s.raw}:{value:s?.rest?`${n}:00`:n}}},eb06ad68f8d3(e,t,n){n.d(t,{b:()=>I,j:()=>B});Object.freeze(["p","h2","h3","h4","strong","em","a","ul","ol","li","blockquote","br"]);const s=Object.freeze(["p","h2","h3","h4"]),i=Object.freeze(["https:","mailto:","tel:"]),r=Object.freeze(["html","paste"]),a=(Object.freeze(["pre","table"]),new Set(["script","style","template","head","title","meta","link","base","noscript","iframe","frame","frameset","noembed","noframes","object","embed","applet","svg","math","canvas","video","audio","img","picture","source","track","input","select","textarea","xmp","plaintext"])),o=new Set(["address","article","aside","body","caption","center","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h5","h6","header","hgroup","hr","html","legend","listing","main","menu","nav","optgroup","option","pre","section","summary","table","tbody","td","tfoot","th","thead","tr"]),l=new Set(["ul","ol"]),c=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),u=new Set(["script","style","textarea","title","xmp","iframe","noembed","noframes","noscript"]),d=new Set(["td","th","table","caption","button"]),h=/[\u0000-\u001f\u007f-\u009f]/gu,p=/[\u0000- \u007f-\u009f\u00a0\u1680\u2000-\u200b\u2028\u2029\u202f\u205f\u3000\ufeff]/gu;const m={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" ",shy:"­",hellip:"…",mdash:"—",ndash:"–",minus:"−",laquo:"«",raquo:"»",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",bull:"•",middot:"·",copy:"©",reg:"®",trade:"™",deg:"°",times:"×",divide:"÷",plusmn:"±",euro:"€",pound:"£",yen:"¥",cent:"¢",sect:"§",para:"¶",thinsp:" ",ensp:" ",emsp:" ",zwj:"‍",zwnj:"‌",larr:"←",rarr:"→",uarr:"↑",darr:"↓",numero:"№",prime:"′",Prime:"″"};function f(e){return String(e).replace(/&(#x[0-9a-f]+|#[0-9]+|[a-z][a-z0-9]*);?/giu,(e,t)=>{if("#"===t[0]){const e="x"===t[1]||"X"===t[1]?Number.parseInt(t.slice(2),16):Number.parseInt(t.slice(1),10);return!Number.isFinite(e)||e<=0||e>1114111||e>=55296&&e<=57343?"�":String.fromCodePoint(e)}return Object.hasOwn(m,t)&&e.endsWith(";")?m[t]:e})}function g(e){const t="string"==typeof e?e:"",n={type:"element",name:"#root",attrs:{},children:[]},i=[n],r=()=>i[i.length-1],a=e=>r().children.push(e),h=e=>{if(!e)return;const t=r().children.at(-1);"text"===t?.type?t.value+=e:a({type:"text",value:e})},p=(e,t=null)=>{for(let n=i.length-1;n>0;n-=1){const s=i[n].name;if(t&&t.has(s))return!1;if(s===e)return i.length=n,!0}return!1};let m=0;const g=t.length;for(;m<g;){const e=t.indexOf("<",m);if(e<0){h(f(t.slice(m)));break}if(e>m&&h(f(t.slice(m,e))),m=e,t.startsWith("\x3c!--",m)){const e=t.indexOf("--\x3e",m+4);m=e<0?g:e+3;continue}const n=t[m+1]??"";if("!"===n||"?"===n){const e=t.indexOf(">",m+2);m=e<0?g:e+1;continue}if("/"===n){const e=/^<\/([a-z][a-z0-9-]*)[^>]*>?/iu.exec(t.slice(m));if(!e){const e=t.indexOf(">",m+2);m=e<0?g:e+1;continue}m+=e[0].length;const n=e[1].toLowerCase();"br"===n?a({type:"element",name:"br",attrs:{},children:[]}):"p"!==n||p("p",d)?p(n):a({type:"element",name:"p",attrs:{},children:[]});continue}const r=/^<([a-z][a-z0-9-]*)/iu.exec(t.slice(m));if(!r){h("<"),m+=1;continue}m+=r[0].length;const b=r[1].toLowerCase(),y={};let v=!1;for(;m<g;){const e=/^[\s/]+/u.exec(t.slice(m));if(e){e[0].includes("/")&&">"===t[m+e[0].length]&&(v=!0),m+=e[0].length;continue}if(">"===t[m]){m+=1;break}const n=/^([^\s/>"'=][^\s/>"'=]*)(?:\s*=\s*(?:"([^"]*)"?|'([^']*)'?|([^\s>]*)))?/u.exec(t.slice(m));if(!n){m+=1;continue}m+=n[0].length;const s=n[1].toLowerCase();Object.hasOwn(y,s)||(y[s]=f(n[2]??n[3]??n[4]??""))}const w={type:"element",name:b,attrs:y,children:[]};if("li"===b&&p("li",l),(s.includes(b)||l.has(b)||"blockquote"===b||o.has(b))&&p("p",d),a(w),"plaintext"===b){m=g;break}if(u.has(b)){const e=new RegExp(`</${b}[\\s/>]`,"iu").exec(t.slice(m)),n=e?m+e.index:g;"textarea"===b||"title"===b?w.children.push({type:"text",value:f(t.slice(m,n))}):w.children.push({type:"text",value:t.slice(m,n)});const s=e?t.indexOf(">",n):-1;m=s<0?g:s+1;continue}c.has(b)||v||i.push(w)}return n}function b(e){const t=e=>{if(3===e.nodeType)return{type:"text",value:e.data};if(11===e.nodeType)return{type:"element",name:"#root",attrs:{},children:[...e.childNodes].map(t).filter(Boolean)};if(1!==e.nodeType)return null;if(e.namespaceURI&&"http://www.w3.org/1999/xhtml"!==e.namespaceURI)return null;const n=e.localName;if(a.has(n))return null;const s={},i=e.getAttribute("href");null!==i&&(s.href=i);const r=e.getAttribute("style");null!==r&&(s.style=r);return{type:"element",name:n,attrs:s,children:"template"===n?[]:[...e.childNodes].map(t).filter(Boolean)}},n=t(e);return n&&"element"===n.type?{...n,name:"#root"}:{type:"element",name:"#root",attrs:{},children:n?[n]:[]}}function y(e,t){const n={...t};"strong"!==e.name&&"b"!==e.name||(n.strong=!0),"em"!==e.name&&"i"!==e.name||(n.em=!0);const s=function(e){const t={};if(!e)return t;const n=/(?:^|;)\s*font-weight\s*:\s*([^;!]+)/iu.exec(e)?.[1]?.trim().toLowerCase();n&&("bold"===n||"bolder"===n||Number(n)>=600?t.strong=!0:("normal"===n||"lighter"===n||Number(n)<600)&&(t.strong=!1));const s=/(?:^|;)\s*font-style\s*:\s*([^;!]+)/iu.exec(e)?.[1]?.trim().toLowerCase();return s&&("italic"===s||s.startsWith("oblique")?t.em=!0:"normal"===s&&(t.em=!1)),t}(e.attrs?.style);return void 0!==s.strong&&(n.strong=s.strong),void 0!==s.em&&(n.em=s.em),n}const v=(e,t,n)=>({kind:e,value:t,strong:Boolean(n.marks.strong),em:Boolean(n.marks.em),href:n.href||null});class w{constructor(e){this.kind=e,this.blocks=[],this.run=[],this.types=["p"],this.starts=[0],this.needBreak=!1}inline(e){"item"===this.kind&&this.needBreak&&this.run.length>0&&("text"!==e.kind||e.value.trim())&&(this.run.push({kind:"br",strong:!1,em:!1,href:null}),this.needBreak=!1),this.run.push(e)}flush(){this.run.length&&("item"===this.kind?this.blocks.push({type:"inline",leaves:this.run}):this.blocks.push({type:this.types[this.types.length-1],leaves:this.run}),this.run=[])}open(e){"item"!==this.kind?(this.flush(),this.types.push(e),this.starts.push(this.blocks.length)):this.needBreak=!0}close(e=!1){if("item"===this.kind)return void(this.needBreak=!0);const t=this.starts[this.starts.length-1];e&&!this.run.length&&this.blocks.length===t&&this.blocks.push({type:this.types[this.types.length-1],leaves:[]}),this.flush(),this.types.length>1&&(this.types.pop(),this.starts.pop())}block(e){this.flush(),this.blocks.push(e),this.needBreak=!1}}function x(e,t,n){for(const s of e)$(s,t,n)}function $(e,t,n){if("text"===e.type)return void function(e,t,n){if(n.pre)return void e.replace(/\r\n?/gu,"\n").split("\n").forEach((e,s)=>{s>0&&t.inline(v("br","",n)),e&&t.inline(v("text",e.replace(/[\t\f]/gu," "),n))});const s=e.replace(/[\t\n\r\f ]+/gu," ");s&&(" "!==s||t.run.length)&&t.inline(v("text",s,n))}(e.value,t,n);const r=e.name;if(a.has(r))return;if("br"===r)return void t.inline(v("br","",n));const c={...n,marks:y(e,n.marks)};if("a"===r){const s=function(e){if("string"!=typeof e)return null;const t=e.trim();if(!t||t.length>2048)return null;const n=t.replace(p,"");if(!n)return null;if(n.startsWith("/")){if(/^\/[/\\]/u.test(n))return null;const e=t.replace(h,"");return/^\/[/\\]/u.test(e)?null:e}const s=/^([a-z][a-z0-9+.-]*):/iu.exec(n)?.[1]?.toLowerCase();if(!s||!i.includes(`${s}:`))return null;let r;try{r=new globalThis.URL(t.replace(h,""))}catch{return null}return r.protocol!==`${s}:`?null:"https:"!==r.protocol||r.hostname?"https:"!==r.protocol&&r.href.length<=r.protocol.length?null:r.href:null}(e.attrs?.href);return void x(e.children,t,s&&!n.href?{...c,href:s}:c)}if(s.includes(r))return t.open(r),x(e.children,t,c),void t.close(!0);if(l.has(r)){const n=T(e,c,r);return void(n.items.length&&t.block(n))}if("blockquote"===r){if("item"===t.kind)return t.open("p"),x(e.children,t,c),void t.close();const n=new w("flow");return x(e.children,n,c),n.flush(),void t.block({type:"blockquote",blocks:n.blocks})}if("li"===r)return t.open("p"),x(e.children,t,c),void t.close();if(!n.paste||"item"===t.kind||"pre"!==r&&"listing"!==r){if(!n.paste||"item"===t.kind||"table"!==r)return o.has(r)?(t.open("p"),x(e.children,t,"pre"===r||"listing"===r?{...c,pre:!0}:c),void t.close()):void x(e.children,t,c);t.block(function(e,t){const n={type:"table",caption:[],rows:[]},s=(e,s)=>{const i=[];for(const n of e.children){if("element"!==n.type||"td"!==n.name&&"th"!==n.name)continue;const e=new w("item");x(n.children,e,{...t,marks:y(n,t.marks)}),e.flush(),i.push({header:"th"===n.name,leaves:k(e.blocks)})}i.length&&n.rows.push({head:s,cells:i})},i=(e,t)=>{for(const n of e.children)"element"===n.type&&"tr"===n.name&&s(n,t)};for(const r of e.children)if("element"===r.type)if("caption"===r.name){const e=new w("item");x(r.children,e,t),e.flush(),n.caption=k(e.blocks)}else"thead"===r.name?i(r,!0):"tbody"===r.name||"tfoot"===r.name?i(r,!1):"tr"===r.name&&s(r,!1);return n}(e,c))}else t.block({type:"pre",text:S(e)})}function S(e){const t=e=>"text"===e.type?e.value:a.has(e.name)?"":"br"===e.name?"\n":e.children.map(t).join("");return e.children.map(t).join("").replace(/\r\n?/gu,"\n").replace(/\u00a0/gu," ").replace(/^\n/u,"").replace(/\s+$/u,"")}function k(e){const t=[],n=e=>{if("inline"===e.type)(s=e.leaves).length&&(t.length&&t.push({kind:"br",strong:!1,em:!1,href:null}),t.push(...s));else for(const t of e.items)t.children.forEach(n);var s};return e.forEach(n),t}function C(e,t){const n=new w("item");return x(e.children,n,t),n.flush(),{children:n.blocks}}function T(e,t,n){const s={type:n,items:[]};let i=null;const r=()=>{i&&(i.flush(),s.items.push({children:i.blocks}),i=null)};for(const n of e.children)if("element"!==n.type||"li"!==n.name){if("element"===n.type&&l.has(n.name)){r();const e=T(n,{...t,marks:y(n,t.marks)},n.name);if(!e.items.length)continue;const i=s.items.at(-1);i?i.children.push(e):s.items.push({children:[e]});continue}("text"!==n.type||n.value.trim())&&("element"===n.type&&a.has(n.name)||(i??=new w("item"),$(n,i,t)))}else r(),s.items.push(C(n,t));return r(),s}const _=" ",A=(e,t)=>e.strong===t.strong&&e.em===t.em&&e.href===t.href;function F(e,t){const n=[];for(const t of e){if("text"===t.kind&&!t.value)continue;const e=n.at(-1);"text"===t.kind&&"text"===e?.kind&&A(e,t)?e.value+=t.value:n.push({...t})}for(let e=0;e<n.length;e+=1){const t=n[e];if("text"!==t.kind)continue;t.value=t.value.replace(/ {2,}/gu,_);const s=n[e-1];t.value.startsWith(_)&&(!s||"br"===s.kind||"text"===s.kind&&s.value.endsWith(_))&&(t.value=t.value.slice(1));const i=n[e+1];!t.value.endsWith(_)||i&&"br"!==i.kind||(t.value=t.value.slice(0,-1))}let s=n.filter(e=>"br"===e.kind||e.value);if("value"===t){for(;"br"===s[0]?.kind;)s.shift();for(;"br"===s.at(-1)?.kind;)s.pop();"text"===s[0]?.kind&&(s[0].value=s[0].value.replace(/^[\s\u00a0]+/u,""));const e=s.at(-1);"text"===e?.kind&&(e.value=e.value.replace(/[\s\u00a0]+$/u,"")),s=s.filter(e=>"br"===e.kind||e.value)}const i=new Map;for(const e of s)e.href&&i.set(e.href,(i.get(e.href)||"")+("text"===e.kind?e.value:"x"));for(const e of s)e.href&&!i.get(e.href).trim()&&(e.href=null);const r=[];for(const e of s){const t=r.at(-1);"text"===e.kind&&"text"===t?.kind&&A(t,e)?t.value+=e.value:r.push(e)}return r}const z=e=>e.some(e=>"text"===e.kind&&""!==e.value.replace(/[\s\u00a0]+/gu,""));function R(e,t){const n=e.items.map(e=>function(e,t){const n=[];for(const s of e.children)if("inline"===s.type){const e=F(s.leaves,t);if(!e.length)continue;const i=n.at(-1);"inline"===i?.type?i.leaves=F([...i.leaves,{kind:"br",strong:!1,em:!1,href:null},...e],t):n.push({type:"inline",leaves:e})}else{const e=R(s,t);if(!e)continue;const i=n.at(-1);i&&i.type===e.type?i.items.push(...e.items):n.push(e)}if("value"===t){const e=n.filter(e=>"inline"!==e.type||z(e.leaves));return e.length?{children:e}:null}return n.length&&"inline"===n[0].type||n.unshift({type:"inline",leaves:[{kind:"br",strong:!1,em:!1,href:null}]}),{children:n}}(e,t)).filter(Boolean);return n.length?{type:e.type,items:n}:null}function E(e,t){const n=[];for(const s of e){let e=null;if("blockquote"===s.type){const n=E(s.blocks,t);n.length?e={type:"blockquote",blocks:n}:"editor"===t&&(e={type:"blockquote",blocks:[{type:"p",leaves:[{kind:"br",strong:!1,em:!1,href:null}]}]})}else if(l.has(s.type))e=R(s,t);else if("pre"===s.type)s.text.trim()&&(e={type:"pre",text:s.text});else if("table"===s.type){const t=s.rows.map(e=>({head:e.head,cells:e.cells.map(e=>({header:e.header,leaves:F(e.leaves,"value")}))})).filter(e=>e.cells.some(e=>z(e.leaves)));t.length&&(e={type:"table",caption:F(s.caption,"value"),rows:t})}else{const n=F(s.leaves,t);"value"===t?z(n)&&(e={type:s.type,leaves:n}):e={type:s.type,leaves:n.length?n:[{kind:"br",strong:!1,em:!1,href:null}]}}if(!e)continue;const i=n.at(-1);i&&l.has(e.type)&&i.type===e.type?i.items.push(...e.items):n.push(e)}return n}function O(e,{mode:t="value",profile:n="html"}={}){if(!r.includes(n))throw new TypeError(`rich_text_profile_unknown: ${n}`);const s=new w("flow");x(e.children??[],s,{marks:{},href:null,pre:!1,paste:"paste"===n}),s.flush();const i=E(s.blocks,t);return"editor"!==t||i.length?i:[{type:"p",leaves:[{kind:"br",strong:!1,em:!1,href:null}]}]}const P=e=>e.replace(/&/gu,"&amp;").replace(/"/gu,"&quot;").replace(/</gu,"&lt;").replace(/>/gu,"&gt;").replace(/\u00a0/gu,"&nbsp;");function M(e){const t=(e,n)=>{let s="",i=0;const r=["href","strong","em"][n];for(;i<e.length;){const a=r?e[i][r]:null;let o=i+1;for(;o<e.length&&r&&e[o][r]===a;)o+=1;const l=e.slice(i,o);s+=r?"href"===r&&a?`<a href="${P(a)}">${t(l,n+1)}</a>`:"href"!==r&&a?`<${r}>${t(l,n+1)}</${r}>`:t(l,n+1):l.map(e=>"br"===e.kind?"<br>":e.value.replace(/&/gu,"&amp;").replace(/</gu,"&lt;").replace(/>/gu,"&gt;").replace(/\u00a0/gu,"&nbsp;")).join(""),i=o}return s};return t(e,0)}function L(e){return`<${e.type}>${e.items.map(e=>`<li>${e.children.map(e=>"inline"===e.type?M(e.leaves):L(e)).join("")}</li>`).join("")}</${e.type}>`}function q(e){return e.map(e=>{if("blockquote"===e.type)return`<blockquote>${q(e.blocks)}</blockquote>`;if(l.has(e.type))return L(e);if("pre"===e.type){return`<p>${M(F(e.text.split("\n").flatMap((e,t)=>[...t?[{kind:"br",strong:!1,em:!1,href:null}]:[],{kind:"text",value:e.replace(/[\t\f]/gu," "),strong:!1,em:!1,href:null}]),"value"))}</p>`}if("table"===e.type){return[{leaves:e.caption},...e.rows.flatMap(e=>e.cells)].filter(e=>z(e.leaves)).map(e=>`<p>${M(e.leaves)}</p>`).join("")}return`<${e.type}>${M(e.leaves)}</${e.type}>`}).join("")}const j=e=>{const t=e&&"object"==typeof e&&!Array.isArray(e)&&"value"in e?e.value:e;return"string"==typeof t?t:""};function I(e){const t=j(e);return t?function(e,{mode:t="value",document:n}={}){let s;if(e&&"object"==typeof e&&"number"==typeof e.nodeType)s=b(e);else{const t="string"==typeof e?e:"",i=void 0===n?globalThis.document:n;if(t&&i?.createElement){const e=i.createElement("template");e.innerHTML=t,s=b(e.content)}else s=g(t)}return q(O(s,{mode:t}))}(t,{mode:"value"}):""}function B(e){const t=j(e);return t?function(e){const t=O(g(e),{mode:"value"}),n=e=>e.map(e=>"br"===e.kind?"\n":e.value).join(""),s=e=>e.items.map(e=>e.children.map(e=>"inline"===e.type?n(e.leaves):s(e)).join("\n")).join("\n"),i=e=>e.map(e=>"blockquote"===e.type?i(e.blocks):l.has(e.type)?s(e):n(e.leaves)).join("\n\n");return i(t)}(t).replace(/\s+/gu," ").trim():""}},e5483002f3ea(e,t,n){n.a(e,async(e,s)=>{try{n.d(t,{dV:()=>U,fT:()=>S});var i=n("2a080a730149"),r=n("073f05ff1a81"),a=n("5961360f41f4"),o=n("43090d1c8307"),l=n("fc654eb7fab0"),c=n("9ce1a42b2a85"),u=n("dd6973f77245"),d=n("eb06ad68f8d3"),h=e([i,r,o]);[i,r,o]=h.then?(await h)():h;function p(e){return String(e?.size||"").trim()||"1"}function m(e,t){const n=t.getFilterControlValue(e.key);return i.html`
1
+ (()=>{"use strict";var e={e577837dd70a(e,t,n){n.a(e,async(e,s)=>{try{n.d(t,{Yq:()=>l});var i=n("15b4e93ff6ed"),r=e([i]),a=r.then?(await r)():r;i=a[0];function o(e){return"short"===e||"medium"===e||"long"===e||"full"===e}function l(e,{date:t="medium",time:n=null,intl:s=null,gap:r="",...a}={}){const l=(0,i.ay)(e);if(!l)return r;let c=s;return c||(c={},o(t)&&(c.dateStyle=t),o(n)&&(c.timeStyle=n),c.dateStyle||c.timeStyle||(c.dateStyle="medium")),(0,i.Qz)("DateTimeFormat",(0,i.OE)(a),c).format(l)}s()}catch(c){s(c)}})},"15b4e93ff6ed"(e,t,n){n.a(e,async(e,s)=>{try{n.d(t,{OE:()=>o,Qz:()=>u,ay:()=>l});var i=n("43090d1c8307"),r=e([i]),a=r.then?(await r)():r;i=a[0];function o({locale:e,node:t}={}){return String(e||"").trim()||(0,i.pageLocale)(t)}function l(e){if(null==e||""===e)return null;const t=e instanceof Date?new Date(e.getTime()):new Date("string"==typeof e&&/^\d+$/u.test(e)?Number(e):e);return Number.isNaN(t.getTime())?null:t}function c(){const e="undefined"!=typeof globalThis?globalThis:{};return e.__sfFormat||(e.__sfFormat={formatters:new Map}),e.__sfFormat.formatters}function u(e,t,n){const s=`${e}|${t}|${JSON.stringify(n)}`,i=c();if(i.has(s))return i.get(s);const r=Intl[e];let a;try{a=new r(t||void 0,n)}catch{try{a=new r(void 0,n)}catch{a=new r(t||void 0,"NumberFormat"===e?{maximumFractionDigits:2}:{})}}return i.size>=256&&i.delete(i.keys().next().value),i.set(s,a),a}s()}catch(d){s(d)}})},"51250bf01ab0"(e,t,n){const s="sf-pref:",i=/^[\w.*:-]+(?:\/[\w.*:/-]+)?$/u;function r(){try{return globalThis.localStorage??null}catch{return null}}function a(e){return"string"==typeof e&&e.length>0&&e.length<=200&&i.test(e)}function o(e,t){try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}function l(e){return null==e?null:JSON.parse(JSON.stringify(e))}"undefined"!=typeof globalThis&&(globalThis.SF=globalThis.SF||{},globalThis.SF.Preferences||(globalThis.SF.Preferences=function(){const e={adapter:null,values:new Map},t=new Map,n=new Map;let i=!1;const c=()=>{if(i)return;const e=globalThis.document?.querySelector?.('script[type="application/json"][data-sf-preferences], script#sf-preferences[type="application/json"]');if(e){i=!0;try{f.preload(JSON.parse(e.textContent||"{}"))}catch{}}},u=(e,n)=>{for(const s of t.get(e)??[])try{s(l(n),e)}catch(t){console.error("SF.Preferences listener failed",e,t)}},d=e=>{const t=r();if(!t)return null;try{const n=t.getItem(s+e);return null===n?null:JSON.parse(n)}catch{return null}},h=(e,t)=>{const n=r();if(n)try{null===t?n.removeItem(s+e):n.setItem(s+e,JSON.stringify(t))}catch{}},p=t=>{clearTimeout(n.get(t)),n.delete(t);const s=e.adapter;if(!s)return;const i=e.values.has(t)?e.values.get(t):d(t);try{const e=null===i?s.remove?.(t):s.save?.(t,l(i));Promise.resolve(e).catch(e=>console.warn("SF.Preferences: the host did not keep",t,e))}catch(e){console.warn("SF.Preferences: the host did not keep",t,e)}},m=t=>{e.adapter&&(clearTimeout(n.get(t)),n.set(t,setTimeout(()=>p(t),400)))},f={read:t=>a(t)?(c(),e.values.has(t)?l(e.values.get(t)):l(d(t))):null,readMerged(...e){const t={};let n=!1;for(const s of e.flat()){const e=f.read(s);e&&"object"==typeof e&&!Array.isArray(e)&&(Object.assign(t,e),n=!0)}return n?t:null},write(t,n){if(!a(t))return!1;const s=l(n);return JSON.stringify(f.read(t))===JSON.stringify(s)||(e.values.has(t)&&e.values.set(t,s),h(t,s),m(t)),!0},remove:t=>!!a(t)&&(e.values.has(t)&&e.values.set(t,null),h(t,null),m(t),u(t,null),!0),subscribe:(e,n)=>a(e)&&"function"==typeof n?(t.has(e)||t.set(e,new Set),t.get(e).add(n),()=>t.get(e)?.delete(n)):()=>{},preload(t){if(t&&"object"==typeof t)for(const[n,s]of Object.entries(t)){if(!a(n))continue;const t=l(s),i=f.read(n);e.values.set(n,t),h(n,t),o(i,t)||u(n,t)}},useHost(t){if(!t||"function"!=typeof t.save)throw new TypeError("A preferences host saves: {save(key, value)}");return e.adapter=t,f},async load(t){const n=[].concat(t).filter(t=>a(t)&&!e.values.has(t));if(n.length&&"function"==typeof e.adapter?.load)try{f.preload(await e.adapter.load(n))}catch(e){console.warn("SF.Preferences: the host did not answer",n,e)}},get hosted(){return Boolean(e.adapter)},flush(){for(const e of[...n.keys()])p(e)}};return globalThis.addEventListener?.("storage",t=>{if(!t.key?.startsWith(s)||t.storageArea!==r())return;const n=t.key.slice(8);if(e.values.has(n))return;let i=null;try{i=null===t.newValue?null:JSON.parse(t.newValue)}catch{i=null}u(n,i)}),globalThis.addEventListener?.("pagehide",()=>f.flush()),c(),Object.freeze(f)}()));const c=globalThis.SF?.Preferences,u=c;n.d(t,["A",0,u])},"9ce1a42b2a85"(e,t,n){n.d(t,{AC:()=>a,MC:()=>d,SB:()=>u,cy:()=>l,d2:()=>o});const s=/^(\d{4}-\d{2}-\d{2})(?:[T ](\d{2}):(\d{2})((?::\d{2})(?:\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/u,i=/^\d{4}-\d{2}-\d{2}$/u;function r(e){return e&&"object"==typeof e&&!Array.isArray(e)&&"value"in e?e.value:e}function a(e){const t=r(e);if(null==t||""===t)return{raw:t??null,known:!0,date:"",time:"",rest:"",zone:""};const n="string"==typeof t?t.trim().match(s):null;return n?{raw:t,known:!0,date:n[1],time:n[2]?`${n[2]}:${n[3]}`:"",rest:n[4]||"",zone:n[5]||""}:{raw:t,known:!1,date:"",time:"",rest:"",zone:""}}function o(e){const t=String(e??"").trim().replace(/[_\s]/gu,"");if(""===t||":"===t)return"";const n=t.match(/^(\d{1,2})[:.]?(\d{2})$/u);if(!n)return null;const s=Number(n[1]),i=Number(n[2]);return s>23||i>59?null:`${String(s).padStart(2,"0")}:${n[2]}`}function l(e,t){const n=String(t?.date??"").trim(),s=o(t?.time);if(null===s)return{error:"timeInvalid"};if(!n&&!s)return{value:null};if(!i.test(n))return{error:n?"dateInvalid":"dateMissing"};if(!s)return{error:"timeMissing"};const r=e?.known?e:null;if(r&&r.date===n&&r.time===s)return{value:r.raw};return{value:`${n}T${s}${r&&r.time===s?r.rest:":00"}${r&&r.time?r.zone:""}`}}const c=/^(\d{2}):(\d{2})((?::\d{2})(?:\.\d+)?)?$/u;function u(e){const t=r(e);if(null==t||""===t)return{raw:t??null,known:!0,time:"",rest:""};const n="string"==typeof t?t.trim().match(c):null;return n&&null!==o(`${n[1]}:${n[2]}`)?{raw:t,known:!0,time:`${n[1]}:${n[2]}`,rest:n[3]||""}:{raw:t,known:!1,time:"",rest:""}}function d(e,t){const n=o(t);if(null===n)return{error:"timeInvalid"};if(!n)return{value:null};const s=e?.known?e:null;return s&&s.time===n?{value:s.raw}:{value:s?.rest?`${n}:00`:n}}},eb06ad68f8d3(e,t,n){n.d(t,{b:()=>I,j:()=>B});Object.freeze(["p","h2","h3","h4","strong","em","a","ul","ol","li","blockquote","br"]);const s=Object.freeze(["p","h2","h3","h4"]),i=Object.freeze(["https:","mailto:","tel:"]),r=Object.freeze(["html","paste"]),a=(Object.freeze(["pre","table"]),new Set(["script","style","template","head","title","meta","link","base","noscript","iframe","frame","frameset","noembed","noframes","object","embed","applet","svg","math","canvas","video","audio","img","picture","source","track","input","select","textarea","xmp","plaintext"])),o=new Set(["address","article","aside","body","caption","center","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h5","h6","header","hgroup","hr","html","legend","listing","main","menu","nav","optgroup","option","pre","section","summary","table","tbody","td","tfoot","th","thead","tr"]),l=new Set(["ul","ol"]),c=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),u=new Set(["script","style","textarea","title","xmp","iframe","noembed","noframes","noscript"]),d=new Set(["td","th","table","caption","button"]),h=/[\u0000-\u001f\u007f-\u009f]/gu,p=/[\u0000- \u007f-\u009f\u00a0\u1680\u2000-\u200b\u2028\u2029\u202f\u205f\u3000\ufeff]/gu;const m={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" ",shy:"­",hellip:"…",mdash:"—",ndash:"–",minus:"−",laquo:"«",raquo:"»",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",bull:"•",middot:"·",copy:"©",reg:"®",trade:"™",deg:"°",times:"×",divide:"÷",plusmn:"±",euro:"€",pound:"£",yen:"¥",cent:"¢",sect:"§",para:"¶",thinsp:" ",ensp:" ",emsp:" ",zwj:"‍",zwnj:"‌",larr:"←",rarr:"→",uarr:"↑",darr:"↓",numero:"№",prime:"′",Prime:"″"};function f(e){return String(e).replace(/&(#x[0-9a-f]+|#[0-9]+|[a-z][a-z0-9]*);?/giu,(e,t)=>{if("#"===t[0]){const e="x"===t[1]||"X"===t[1]?Number.parseInt(t.slice(2),16):Number.parseInt(t.slice(1),10);return!Number.isFinite(e)||e<=0||e>1114111||e>=55296&&e<=57343?"�":String.fromCodePoint(e)}return Object.hasOwn(m,t)&&e.endsWith(";")?m[t]:e})}function g(e){const t="string"==typeof e?e:"",n={type:"element",name:"#root",attrs:{},children:[]},i=[n],r=()=>i[i.length-1],a=e=>r().children.push(e),h=e=>{if(!e)return;const t=r().children.at(-1);"text"===t?.type?t.value+=e:a({type:"text",value:e})},p=(e,t=null)=>{for(let n=i.length-1;n>0;n-=1){const s=i[n].name;if(t&&t.has(s))return!1;if(s===e)return i.length=n,!0}return!1};let m=0;const g=t.length;for(;m<g;){const e=t.indexOf("<",m);if(e<0){h(f(t.slice(m)));break}if(e>m&&h(f(t.slice(m,e))),m=e,t.startsWith("\x3c!--",m)){const e=t.indexOf("--\x3e",m+4);m=e<0?g:e+3;continue}const n=t[m+1]??"";if("!"===n||"?"===n){const e=t.indexOf(">",m+2);m=e<0?g:e+1;continue}if("/"===n){const e=/^<\/([a-z][a-z0-9-]*)[^>]*>?/iu.exec(t.slice(m));if(!e){const e=t.indexOf(">",m+2);m=e<0?g:e+1;continue}m+=e[0].length;const n=e[1].toLowerCase();"br"===n?a({type:"element",name:"br",attrs:{},children:[]}):"p"!==n||p("p",d)?p(n):a({type:"element",name:"p",attrs:{},children:[]});continue}const r=/^<([a-z][a-z0-9-]*)/iu.exec(t.slice(m));if(!r){h("<"),m+=1;continue}m+=r[0].length;const b=r[1].toLowerCase(),y={};let v=!1;for(;m<g;){const e=/^[\s/]+/u.exec(t.slice(m));if(e){e[0].includes("/")&&">"===t[m+e[0].length]&&(v=!0),m+=e[0].length;continue}if(">"===t[m]){m+=1;break}const n=/^([^\s/>"'=][^\s/>"'=]*)(?:\s*=\s*(?:"([^"]*)"?|'([^']*)'?|([^\s>]*)))?/u.exec(t.slice(m));if(!n){m+=1;continue}m+=n[0].length;const s=n[1].toLowerCase();Object.hasOwn(y,s)||(y[s]=f(n[2]??n[3]??n[4]??""))}const w={type:"element",name:b,attrs:y,children:[]};if("li"===b&&p("li",l),(s.includes(b)||l.has(b)||"blockquote"===b||o.has(b))&&p("p",d),a(w),"plaintext"===b){m=g;break}if(u.has(b)){const e=new RegExp(`</${b}[\\s/>]`,"iu").exec(t.slice(m)),n=e?m+e.index:g;"textarea"===b||"title"===b?w.children.push({type:"text",value:f(t.slice(m,n))}):w.children.push({type:"text",value:t.slice(m,n)});const s=e?t.indexOf(">",n):-1;m=s<0?g:s+1;continue}c.has(b)||v||i.push(w)}return n}function b(e){const t=e=>{if(3===e.nodeType)return{type:"text",value:e.data};if(11===e.nodeType)return{type:"element",name:"#root",attrs:{},children:[...e.childNodes].map(t).filter(Boolean)};if(1!==e.nodeType)return null;if(e.namespaceURI&&"http://www.w3.org/1999/xhtml"!==e.namespaceURI)return null;const n=e.localName;if(a.has(n))return null;const s={},i=e.getAttribute("href");null!==i&&(s.href=i);const r=e.getAttribute("style");null!==r&&(s.style=r);return{type:"element",name:n,attrs:s,children:"template"===n?[]:[...e.childNodes].map(t).filter(Boolean)}},n=t(e);return n&&"element"===n.type?{...n,name:"#root"}:{type:"element",name:"#root",attrs:{},children:n?[n]:[]}}function y(e,t){const n={...t};"strong"!==e.name&&"b"!==e.name||(n.strong=!0),"em"!==e.name&&"i"!==e.name||(n.em=!0);const s=function(e){const t={};if(!e)return t;const n=/(?:^|;)\s*font-weight\s*:\s*([^;!]+)/iu.exec(e)?.[1]?.trim().toLowerCase();n&&("bold"===n||"bolder"===n||Number(n)>=600?t.strong=!0:("normal"===n||"lighter"===n||Number(n)<600)&&(t.strong=!1));const s=/(?:^|;)\s*font-style\s*:\s*([^;!]+)/iu.exec(e)?.[1]?.trim().toLowerCase();return s&&("italic"===s||s.startsWith("oblique")?t.em=!0:"normal"===s&&(t.em=!1)),t}(e.attrs?.style);return void 0!==s.strong&&(n.strong=s.strong),void 0!==s.em&&(n.em=s.em),n}const v=(e,t,n)=>({kind:e,value:t,strong:Boolean(n.marks.strong),em:Boolean(n.marks.em),href:n.href||null});class w{constructor(e){this.kind=e,this.blocks=[],this.run=[],this.types=["p"],this.starts=[0],this.needBreak=!1}inline(e){"item"===this.kind&&this.needBreak&&this.run.length>0&&("text"!==e.kind||e.value.trim())&&(this.run.push({kind:"br",strong:!1,em:!1,href:null}),this.needBreak=!1),this.run.push(e)}flush(){this.run.length&&("item"===this.kind?this.blocks.push({type:"inline",leaves:this.run}):this.blocks.push({type:this.types[this.types.length-1],leaves:this.run}),this.run=[])}open(e){"item"!==this.kind?(this.flush(),this.types.push(e),this.starts.push(this.blocks.length)):this.needBreak=!0}close(e=!1){if("item"===this.kind)return void(this.needBreak=!0);const t=this.starts[this.starts.length-1];e&&!this.run.length&&this.blocks.length===t&&this.blocks.push({type:this.types[this.types.length-1],leaves:[]}),this.flush(),this.types.length>1&&(this.types.pop(),this.starts.pop())}block(e){this.flush(),this.blocks.push(e),this.needBreak=!1}}function x(e,t,n){for(const s of e)$(s,t,n)}function $(e,t,n){if("text"===e.type)return void function(e,t,n){if(n.pre)return void e.replace(/\r\n?/gu,"\n").split("\n").forEach((e,s)=>{s>0&&t.inline(v("br","",n)),e&&t.inline(v("text",e.replace(/[\t\f]/gu," "),n))});const s=e.replace(/[\t\n\r\f ]+/gu," ");s&&(" "!==s||t.run.length)&&t.inline(v("text",s,n))}(e.value,t,n);const r=e.name;if(a.has(r))return;if("br"===r)return void t.inline(v("br","",n));const c={...n,marks:y(e,n.marks)};if("a"===r){const s=function(e){if("string"!=typeof e)return null;const t=e.trim();if(!t||t.length>2048)return null;const n=t.replace(p,"");if(!n)return null;if(n.startsWith("/")){if(/^\/[/\\]/u.test(n))return null;const e=t.replace(h,"");return/^\/[/\\]/u.test(e)?null:e}const s=/^([a-z][a-z0-9+.-]*):/iu.exec(n)?.[1]?.toLowerCase();if(!s||!i.includes(`${s}:`))return null;let r;try{r=new globalThis.URL(t.replace(h,""))}catch{return null}return r.protocol!==`${s}:`?null:"https:"!==r.protocol||r.hostname?"https:"!==r.protocol&&r.href.length<=r.protocol.length?null:r.href:null}(e.attrs?.href);return void x(e.children,t,s&&!n.href?{...c,href:s}:c)}if(s.includes(r))return t.open(r),x(e.children,t,c),void t.close(!0);if(l.has(r)){const n=T(e,c,r);return void(n.items.length&&t.block(n))}if("blockquote"===r){if("item"===t.kind)return t.open("p"),x(e.children,t,c),void t.close();const n=new w("flow");return x(e.children,n,c),n.flush(),void t.block({type:"blockquote",blocks:n.blocks})}if("li"===r)return t.open("p"),x(e.children,t,c),void t.close();if(!n.paste||"item"===t.kind||"pre"!==r&&"listing"!==r){if(!n.paste||"item"===t.kind||"table"!==r)return o.has(r)?(t.open("p"),x(e.children,t,"pre"===r||"listing"===r?{...c,pre:!0}:c),void t.close()):void x(e.children,t,c);t.block(function(e,t){const n={type:"table",caption:[],rows:[]},s=(e,s)=>{const i=[];for(const n of e.children){if("element"!==n.type||"td"!==n.name&&"th"!==n.name)continue;const e=new w("item");x(n.children,e,{...t,marks:y(n,t.marks)}),e.flush(),i.push({header:"th"===n.name,leaves:k(e.blocks)})}i.length&&n.rows.push({head:s,cells:i})},i=(e,t)=>{for(const n of e.children)"element"===n.type&&"tr"===n.name&&s(n,t)};for(const r of e.children)if("element"===r.type)if("caption"===r.name){const e=new w("item");x(r.children,e,t),e.flush(),n.caption=k(e.blocks)}else"thead"===r.name?i(r,!0):"tbody"===r.name||"tfoot"===r.name?i(r,!1):"tr"===r.name&&s(r,!1);return n}(e,c))}else t.block({type:"pre",text:S(e)})}function S(e){const t=e=>"text"===e.type?e.value:a.has(e.name)?"":"br"===e.name?"\n":e.children.map(t).join("");return e.children.map(t).join("").replace(/\r\n?/gu,"\n").replace(/\u00a0/gu," ").replace(/^\n/u,"").replace(/\s+$/u,"")}function k(e){const t=[],n=e=>{if("inline"===e.type)(s=e.leaves).length&&(t.length&&t.push({kind:"br",strong:!1,em:!1,href:null}),t.push(...s));else for(const t of e.items)t.children.forEach(n);var s};return e.forEach(n),t}function C(e,t){const n=new w("item");return x(e.children,n,t),n.flush(),{children:n.blocks}}function T(e,t,n){const s={type:n,items:[]};let i=null;const r=()=>{i&&(i.flush(),s.items.push({children:i.blocks}),i=null)};for(const n of e.children)if("element"!==n.type||"li"!==n.name){if("element"===n.type&&l.has(n.name)){r();const e=T(n,{...t,marks:y(n,t.marks)},n.name);if(!e.items.length)continue;const i=s.items.at(-1);i?i.children.push(e):s.items.push({children:[e]});continue}("text"!==n.type||n.value.trim())&&("element"===n.type&&a.has(n.name)||(i??=new w("item"),$(n,i,t)))}else r(),s.items.push(C(n,t));return r(),s}const _=" ",A=(e,t)=>e.strong===t.strong&&e.em===t.em&&e.href===t.href;function F(e,t){const n=[];for(const t of e){if("text"===t.kind&&!t.value)continue;const e=n.at(-1);"text"===t.kind&&"text"===e?.kind&&A(e,t)?e.value+=t.value:n.push({...t})}for(let e=0;e<n.length;e+=1){const t=n[e];if("text"!==t.kind)continue;t.value=t.value.replace(/ {2,}/gu,_);const s=n[e-1];t.value.startsWith(_)&&(!s||"br"===s.kind||"text"===s.kind&&s.value.endsWith(_))&&(t.value=t.value.slice(1));const i=n[e+1];!t.value.endsWith(_)||i&&"br"!==i.kind||(t.value=t.value.slice(0,-1))}let s=n.filter(e=>"br"===e.kind||e.value);if("value"===t){for(;"br"===s[0]?.kind;)s.shift();for(;"br"===s.at(-1)?.kind;)s.pop();"text"===s[0]?.kind&&(s[0].value=s[0].value.replace(/^[\s\u00a0]+/u,""));const e=s.at(-1);"text"===e?.kind&&(e.value=e.value.replace(/[\s\u00a0]+$/u,"")),s=s.filter(e=>"br"===e.kind||e.value)}const i=new Map;for(const e of s)e.href&&i.set(e.href,(i.get(e.href)||"")+("text"===e.kind?e.value:"x"));for(const e of s)e.href&&!i.get(e.href).trim()&&(e.href=null);const r=[];for(const e of s){const t=r.at(-1);"text"===e.kind&&"text"===t?.kind&&A(t,e)?t.value+=e.value:r.push(e)}return r}const z=e=>e.some(e=>"text"===e.kind&&""!==e.value.replace(/[\s\u00a0]+/gu,""));function R(e,t){const n=e.items.map(e=>function(e,t){const n=[];for(const s of e.children)if("inline"===s.type){const e=F(s.leaves,t);if(!e.length)continue;const i=n.at(-1);"inline"===i?.type?i.leaves=F([...i.leaves,{kind:"br",strong:!1,em:!1,href:null},...e],t):n.push({type:"inline",leaves:e})}else{const e=R(s,t);if(!e)continue;const i=n.at(-1);i&&i.type===e.type?i.items.push(...e.items):n.push(e)}if("value"===t){const e=n.filter(e=>"inline"!==e.type||z(e.leaves));return e.length?{children:e}:null}return n.length&&"inline"===n[0].type||n.unshift({type:"inline",leaves:[{kind:"br",strong:!1,em:!1,href:null}]}),{children:n}}(e,t)).filter(Boolean);return n.length?{type:e.type,items:n}:null}function E(e,t){const n=[];for(const s of e){let e=null;if("blockquote"===s.type){const n=E(s.blocks,t);n.length?e={type:"blockquote",blocks:n}:"editor"===t&&(e={type:"blockquote",blocks:[{type:"p",leaves:[{kind:"br",strong:!1,em:!1,href:null}]}]})}else if(l.has(s.type))e=R(s,t);else if("pre"===s.type)s.text.trim()&&(e={type:"pre",text:s.text});else if("table"===s.type){const t=s.rows.map(e=>({head:e.head,cells:e.cells.map(e=>({header:e.header,leaves:F(e.leaves,"value")}))})).filter(e=>e.cells.some(e=>z(e.leaves)));t.length&&(e={type:"table",caption:F(s.caption,"value"),rows:t})}else{const n=F(s.leaves,t);"value"===t?z(n)&&(e={type:s.type,leaves:n}):e={type:s.type,leaves:n.length?n:[{kind:"br",strong:!1,em:!1,href:null}]}}if(!e)continue;const i=n.at(-1);i&&l.has(e.type)&&i.type===e.type?i.items.push(...e.items):n.push(e)}return n}function O(e,{mode:t="value",profile:n="html"}={}){if(!r.includes(n))throw new TypeError(`rich_text_profile_unknown: ${n}`);const s=new w("flow");x(e.children??[],s,{marks:{},href:null,pre:!1,paste:"paste"===n}),s.flush();const i=E(s.blocks,t);return"editor"!==t||i.length?i:[{type:"p",leaves:[{kind:"br",strong:!1,em:!1,href:null}]}]}const P=e=>e.replace(/&/gu,"&amp;").replace(/"/gu,"&quot;").replace(/</gu,"&lt;").replace(/>/gu,"&gt;").replace(/\u00a0/gu,"&nbsp;");function M(e){const t=(e,n)=>{let s="",i=0;const r=["href","strong","em"][n];for(;i<e.length;){const a=r?e[i][r]:null;let o=i+1;for(;o<e.length&&r&&e[o][r]===a;)o+=1;const l=e.slice(i,o);s+=r?"href"===r&&a?`<a href="${P(a)}">${t(l,n+1)}</a>`:"href"!==r&&a?`<${r}>${t(l,n+1)}</${r}>`:t(l,n+1):l.map(e=>"br"===e.kind?"<br>":e.value.replace(/&/gu,"&amp;").replace(/</gu,"&lt;").replace(/>/gu,"&gt;").replace(/\u00a0/gu,"&nbsp;")).join(""),i=o}return s};return t(e,0)}function L(e){return`<${e.type}>${e.items.map(e=>`<li>${e.children.map(e=>"inline"===e.type?M(e.leaves):L(e)).join("")}</li>`).join("")}</${e.type}>`}function q(e){return e.map(e=>{if("blockquote"===e.type)return`<blockquote>${q(e.blocks)}</blockquote>`;if(l.has(e.type))return L(e);if("pre"===e.type){return`<p>${M(F(e.text.split("\n").flatMap((e,t)=>[...t?[{kind:"br",strong:!1,em:!1,href:null}]:[],{kind:"text",value:e.replace(/[\t\f]/gu," "),strong:!1,em:!1,href:null}]),"value"))}</p>`}if("table"===e.type){return[{leaves:e.caption},...e.rows.flatMap(e=>e.cells)].filter(e=>z(e.leaves)).map(e=>`<p>${M(e.leaves)}</p>`).join("")}return`<${e.type}>${M(e.leaves)}</${e.type}>`}).join("")}const j=e=>{const t=e&&"object"==typeof e&&!Array.isArray(e)&&"value"in e?e.value:e;return"string"==typeof t?t:""};function I(e){const t=j(e);return t?function(e,{mode:t="value",document:n}={}){let s;if(e&&"object"==typeof e&&"number"==typeof e.nodeType)s=b(e);else{const t="string"==typeof e?e:"",i=void 0===n?globalThis.document:n;if(t&&i?.createElement){const e=i.createElement("template");e.innerHTML=t,s=b(e.content)}else s=g(t)}return q(O(s,{mode:t}))}(t,{mode:"value"}):""}function B(e){const t=j(e);return t?function(e){const t=O(g(e),{mode:"value"}),n=e=>e.map(e=>"br"===e.kind?"\n":e.value).join(""),s=e=>e.items.map(e=>e.children.map(e=>"inline"===e.type?n(e.leaves):s(e)).join("\n")).join("\n"),i=e=>e.map(e=>"blockquote"===e.type?i(e.blocks):l.has(e.type)?s(e):n(e.leaves)).join("\n\n");return i(t)}(t).replace(/\s+/gu," ").trim():""}},e5483002f3ea(e,t,n){n.a(e,async(e,s)=>{try{n.d(t,{dV:()=>U,fT:()=>S});var i=n("2a080a730149"),r=n("073f05ff1a81"),a=n("5961360f41f4"),o=n("43090d1c8307"),l=n("fc654eb7fab0"),c=n("9ce1a42b2a85"),u=n("dd6973f77245"),d=n("eb06ad68f8d3"),h=e([i,r,o]);[i,r,o]=h.then?(await h)():h;function p(e){return String(e?.size||"").trim()||"1"}function m(e,t){const n=t.getFilterControlValue(e.key);return i.html`
2
2
  <sf-input
3
3
  size=${p(t)}
4
4
  appearance="filled"
@@ -169,7 +169,7 @@
169
169
  label=${e.label||e.key||""}
170
170
  @change=${t=>n.setFieldValue(e,t.detail?.value??"")}
171
171
  ></sf-input-color>
172
- `}function R(e,t){return t&&"object"==typeof t&&t.label?re(e)?E(t):{component:{type:"reference-link",props:{line:k,label:String(t.label),icon:_(t.mime),...t.href?{href:String(t.href)}:{}}}}:null}function E(e){const t=String(e.mime??e.mimeType??""),n=Boolean(e.href)&&/^image\//u.test(t);return{component:{type:"file-preview",props:{compact:!0,fileName:String(e.label),mimeType:t,icon:_(t),...e.href?{href:String(e.href)}:{},...n?{imageUrl:String(e.href),kind:"image"}:{kind:"icon"},actions:!1,downloadAction:!1,removeAction:!1}}}}function O(e,t){if(!Array.isArray(t)||!t.length)return null;if("badges"===String(e.variant??""))return P(e,t);const n=e.options||e.filter?.options||e.constraints?.options,s=e=>{const t=Array.isArray(n)?n.find(t=>String(t?.value)===String(e)):null;return String(t?.label??t?.text??e)};return t.map(e=>({component:{type:"tag",props:{line:k,kind:"default",text:s(e)}}}))}function P(e,t){const n=e.options||e.filter?.options||e.constraints?.options;return t.map(t=>{const s=t&&"object"==typeof t?t.value:t,i=Array.isArray(n)?n.find(e=>String(e?.value)===String(s)):null,r=i?(0,a.f)(i):null,o=t&&"object"==typeof t&&void 0!==t.text?String(t.text):String(i?.label??i?.text??s);return{component:{type:"badge",props:{line:k,text:o,appearance:e.badgeAppearance??C,...r?.scheme?{scheme:r.scheme}:{},...r?.rootStyle?{rootStyle:r.rootStyle}:{}}}}})}const M={string:ne,date:I,datetime:I,time:I,boolean:q,choices:O,file:R,color:A,include:le,choice:j,integer:B,number:B,user:V,record:K,relation:K,lookup:N,html:W};function L(e,t){return{yes:e.trueText??e.labels?.true??Me(t,"yes"),no:e.falseText??e.labels?.false??Me(t,"no")}}function q(e,t,n){if("boolean"!=typeof t)return null;const s=L(e,n);return t?s.yes:s.no}function j(e,t){const n=e.options||e.filter?.options||e.constraints?.options;if(!Array.isArray(n))return null;const s=n.find(e=>String(e?.value)===String(t));if(!s)return null;const i=(0,a.f)(s);return{component:{type:"badge",props:{line:k,text:s.label??s.text??String(t),appearance:e.badgeAppearance??C,...i?.scheme?{scheme:i.scheme}:{},...i?.rootStyle?{rootStyle:i.rootStyle}:{}}}}}function I(e,t,n){const s=n?.formatFieldValue?.(e,t);return"string"==typeof s&&""!==s?s:null}function B(e,t,n){const s=e.variant||e.filter?.variant,i=Number(Je(t));return"scale"===s&&Number.isFinite(i)?i<0||i>100?null:{component:{type:"progress-scale",props:{line:k,value:String(i)}}}:I(e,t,n)}function D(e){return{component:{type:"reference-link",props:{line:k,appearance:"plain",icon:"",label:String(e.label),...e.href?{href:String(e.href)}:{}}}}}function V(e,t){return t&&"object"==typeof t&&t.label?[{component:{type:"avatar",props:{line:k,text:t.avatarText||""}}},t.href?D(t):String(t.label)]:null}function K(e,t){return t&&"object"==typeof t&&t.label?D(t):null}function N(e,t){const n=qe(e,t);return n.length?n.map(e=>e.label).join(", "):null}function W(e,t){return(0,d.j)(t)||null}function U(e={},t,n){const s=e.propertyType||e.type||e.dataType,i=M[s];if(!i)return null;const r=i(e,t,n);return r??null}let H="1";const G={record:Le,relation:Le,user:Le,lookup:je,string:ce,text:de,html:he,integer:ge,number:ge,date:ve,datetime:xe,time:$e,boolean:Se,choice:Fe,choices:Ee,file:Ve,color:z,include:oe};function J(e){return`sf_field_${e.key||"value"}`}function Q(e,t,n){return i.html`
172
+ `}function R(e,t){return t&&"object"==typeof t&&t.label?re(e)?E(t):{component:{type:"reference-link",props:{line:k,label:String(t.label),icon:_(t.mime),...t.href?{href:String(t.href)}:{}}}}:null}function E(e){const t=String(e.mime??e.mimeType??""),n=Boolean(e.href)&&/^image\//u.test(t);return{component:{type:"file-preview",props:{compact:!0,fileName:String(e.label),mimeType:t,icon:_(t),...e.href?{href:String(e.href)}:{},...n?{imageUrl:String(e.href),kind:"image"}:{kind:"icon"},actions:!1,downloadAction:!1,removeAction:!1}}}}function O(e,t){if(!Array.isArray(t)||!t.length)return null;if("badges"===String(e.variant??""))return P(e,t);const n=e.options||e.filter?.options||e.constraints?.options,s=e=>{const t=Array.isArray(n)?n.find(t=>String(t?.value)===String(e)):null;return String(t?.label??t?.text??e)};return t.map(e=>({component:{type:"tag",props:{line:k,kind:"default",text:s(e)}}}))}function P(e,t){const n=e.options||e.filter?.options||e.constraints?.options;return t.map(t=>{const s=t&&"object"==typeof t?t.value:t,i=Array.isArray(n)?n.find(e=>String(e?.value)===String(s)):null,r=i?(0,a.f)(i):null,o=t&&"object"==typeof t&&void 0!==t.text?String(t.text):String(i?.label??i?.text??s);return{component:{type:"badge",props:{line:k,text:o,appearance:e.badgeAppearance??C,...r?.scheme?{scheme:r.scheme}:{},...r?.rootStyle?{rootStyle:r.rootStyle}:{}}}}})}const M={string:ne,date:I,datetime:I,time:I,boolean:q,choices:O,file:R,color:A,include:le,choice:j,integer:B,number:B,user:V,record:N,relation:N,lookup:K,html:W};function L(e,t){return{yes:e.trueText??e.labels?.true??Me(t,"yes"),no:e.falseText??e.labels?.false??Me(t,"no")}}function q(e,t,n){if("boolean"!=typeof t)return null;const s=L(e,n);return t?s.yes:s.no}function j(e,t){const n=e.options||e.filter?.options||e.constraints?.options;if(!Array.isArray(n))return null;const s=n.find(e=>String(e?.value)===String(t));if(!s)return null;const i=(0,a.f)(s);return{component:{type:"badge",props:{line:k,text:s.label??s.text??String(t),appearance:e.badgeAppearance??C,...i?.scheme?{scheme:i.scheme}:{},...i?.rootStyle?{rootStyle:i.rootStyle}:{}}}}}function I(e,t,n){const s=n?.formatFieldValue?.(e,t);return"string"==typeof s&&""!==s?s:null}function B(e,t,n){const s=e.variant||e.filter?.variant,i=Number(Je(t));return"scale"===s&&Number.isFinite(i)?i<0||i>100?null:{component:{type:"progress-scale",props:{line:k,value:String(i)}}}:I(e,t,n)}function D(e){return{component:{type:"reference-link",props:{line:k,appearance:"plain",icon:"",label:String(e.label),...e.href?{href:String(e.href)}:{}}}}}function V(e,t){return t&&"object"==typeof t&&t.label?[{component:{type:"avatar",props:{line:k,text:t.avatarText||""}}},t.href?D(t):String(t.label)]:null}function N(e,t){return t&&"object"==typeof t&&t.label?D(t):null}function K(e,t){const n=qe(e,t);return n.length?n.map(e=>e.label).join(", "):null}function W(e,t){return(0,d.j)(t)||null}function U(e={},t,n){const s=e.propertyType||e.type||e.dataType,i=M[s];if(!i)return null;const r=i(e,t,n);return r??null}let H="1";const G={record:Le,relation:Le,user:Le,lookup:je,string:ce,text:de,html:he,integer:ge,number:ge,date:ve,datetime:xe,time:$e,boolean:Se,choice:Fe,choices:Ee,file:Ve,color:z,include:oe};function J(e){return`sf_field_${e.key||"value"}`}function Q(e,t,n){return i.html`
173
173
  <sf-input-country
174
174
  size=${H}
175
175
  name=${J(e)}
@@ -525,7 +525,7 @@
525
525
  ></sf-file-upload>
526
526
  `:i.nothing}
527
527
  </div>
528
- `}const Ke=e=>"1/2"===e?.size?"1/2":"1",Ne=(e,t)=>"choice"===e&&_e(t);let We=!1;function Ue(e={},t,n,s={}){const i=e.propertyType||e.type||e.dataType,r=!0===s?.disabled;if((!0===e.readonly||r)&&lt[i]&&!Ne(i,e))return ct(e,t,n,s);const a=G[i];if(!a||!n?.setFieldValue)return null;const o=H,l=We;H=Ke(s),We=r;try{return a(e,t,n)}finally{H=o,We=l}}let He="1";function Ge(e){return Boolean(e)&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.text}function Je(e){return Ge(e)?e.value:e}function Qe(e,t,n){const s=n?.formatFieldValue?.(e,t);if("string"==typeof s)return s;if(Ge(t))return t.text;const i=Je(t);return null==i?"":String(i)}function Ye(e,t,n){const s=Qe(e,t,n);return s?i.html`<span class="sf-field-view">${s}</span>`:i.nothing}function Ze(e,t){const n=(0,d.b)(t);return n?i.html`<div class="sf-field-view sf-field-html">${(0,r.unsafeHTML)(n)}</div>`:i.nothing}function Xe(e,t,n){if(null==t||""===t)return i.nothing;const s=e.variant||e.filter?.variant,r=Number(Je(t));if("scale"===s&&Number.isFinite(r)&&r>=0&&r<=100)return i.html`<sf-progress-scale size="1" value=${String(r)}></sf-progress-scale>`;const a=Qe(e,t,n);return i.html`<span class="sf-field-view">${e.unit?`${a} ${e.unit}`:a}</span>`}function et(e,t,n){const s=Qe(e,t,n);return s?i.html`<span class="sf-field-view">${s}</span>`:i.nothing}function tt(e,t,n){if("boolean"!=typeof t)return i.nothing;const s=L(e,n);return i.html`<span class="sf-field-view">${t?s.yes:s.no}</span>`}function nt(e,t){const n=e.options||e.filter?.options||e.constraints?.options,s=Array.isArray(n)?n.find(e=>String(e?.value)===String(t)):null;if(!s)return i.nothing;const r=(0,a.f)(s);return i.html`
528
+ `}const Ne=e=>"1/2"===e?.size?"1/2":"1",Ke=(e,t)=>"choice"===e&&_e(t);let We=!1;function Ue(e={},t,n,s={}){const i=e.propertyType||e.type||e.dataType,r=!0===s?.disabled;if((!0===e.readonly||r)&&lt[i]&&!Ke(i,e))return ct(e,t,n,s);const a=G[i];if(!a||!n?.setFieldValue)return null;const o=H,l=We;H=Ne(s),We=r;try{return a(e,t,n)}finally{H=o,We=l}}let He="1";function Ge(e){return Boolean(e)&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.text}function Je(e){return Ge(e)?e.value:e}function Qe(e,t,n){const s=n?.formatFieldValue?.(e,t);if("string"==typeof s)return s;if(Ge(t))return t.text;const i=Je(t);return null==i?"":String(i)}function Ye(e,t,n){const s=Qe(e,t,n);return s?i.html`<span class="sf-field-view">${s}</span>`:i.nothing}function Ze(e,t){const n=(0,d.b)(t);return n?i.html`<div class="sf-field-view sf-field-html">${(0,r.unsafeHTML)(n)}</div>`:i.nothing}function Xe(e,t,n){if(null==t||""===t)return i.nothing;const s=e.variant||e.filter?.variant,r=Number(Je(t));if("scale"===s&&Number.isFinite(r)&&r>=0&&r<=100)return i.html`<sf-progress-scale size="1" value=${String(r)}></sf-progress-scale>`;const a=Qe(e,t,n);return i.html`<span class="sf-field-view">${e.unit?`${a} ${e.unit}`:a}</span>`}function et(e,t,n){const s=Qe(e,t,n);return s?i.html`<span class="sf-field-view">${s}</span>`:i.nothing}function tt(e,t,n){if("boolean"!=typeof t)return i.nothing;const s=L(e,n);return i.html`<span class="sf-field-view">${t?s.yes:s.no}</span>`}function nt(e,t){const n=e.options||e.filter?.options||e.constraints?.options,s=Array.isArray(n)?n.find(e=>String(e?.value)===String(t)):null;if(!s)return i.nothing;const r=(0,a.f)(s);return i.html`
529
529
  <sf-badge
530
530
  line=${He}
531
531
  appearance=${e.badgeAppearance??C}
@@ -571,11 +571,11 @@
571
571
  ></sf-file-preview>
572
572
  `)}
573
573
  </span>
574
- `}const lt={string:se,text:Ye,html:Ze,integer:Xe,number:Xe,date:et,datetime:et,time:et,boolean:tt,choice:nt,choices:st,user:it,record:rt,relation:rt,lookup:at,file:ot,color:F,include:ae};function ct(e={},t,n,s={}){const i=e.propertyType||e.type||e.dataType,r=lt[i];if(!r)return null;const a=He;He=Ke(s);try{return r(e,t,n)}finally{He=a}}"undefined"!=typeof window&&(window.SF=window.SF||{},window.SF.fieldRenderers={...window.SF.fieldRenderers||{},renderCellField:U,renderEditField:Ue,renderFilterField:S,renderViewField:ct,FILTER_RENDERERS:$,dateTime:{split:c.AC,compose:c.cy,normalizeTime:c.d2,splitTime:c.SB,composeTime:c.MC},registry:l.u.map(e=>{return{...e,modes:(t=e.type,(0,l.U)(t,{view:lt,edit:G,cell:M,filter:$}))};var t})},globalThis.document?.dispatchEvent?.(new CustomEvent("sf-field-renderers-ready"))),s()}catch(ut){s(ut)}})},dd6973f77245(e,t,n){n.d(t,{$:()=>o,C:()=>l});const s={0:"\\d",a:"\\p{L}","*":"[\\s\\S]"},i={0:e=>/\d/u.test(e),a:e=>/\p{L}/u.test(e),"*":()=>!0},r=e=>e.replace(/[\\^$.*+?()[\]{}|/]/gu,"\\$&");const a=new Map;function o(e){const t=e?.mask;return"string"==typeof t&&""!==t?t:null}function l(e,t,n="_"){const o=String(e??"");a.has(t)||a.set(t,function(e){let t="";const n=[];for(let a=0;a<e.length;a+=1){const o=e[a];"\\"===o?(a+=1,a<e.length&&(t+=r(e[a]),n.push({fixed:e[a]}))):"{"===o||"}"===o||"["===o||"]"===o||(s[o]?(t+=s[o],n.push({test:i[o]})):(t+=r(o),n.push({fixed:o})))}return{complete:new RegExp(`^${t}$`,"u"),tokens:n}}(t));const{complete:l,tokens:c}=a.get(t);return l.test(o)?"complete":0===function(e,t,n){let s=0,i=0;for(const r of e){for(;i<t.length&&void 0!==t[i].fixed&&t[i].fixed!==r;)i+=1;if(i>=t.length)break;const e=t[i];void 0!==e.fixed||r===n?i+=1:e.test(r)&&(s+=1,i+=1)}return s}(o,c,n)?"empty":"incomplete"}},fc654eb7fab0(e,t,n){n.d(t,{U:()=>i});const s=Object.freeze([{type:"string",label:{ru:"Строка",en:"String"},variants:[{id:"phone",label:{ru:"Телефон",en:"Phone"}},{id:"password",label:{ru:"Пароль",en:"Password"},writeOnly:!0}],params:["placeholder","mask","nullable","required","readonly"]},{type:"text",label:{ru:"Текст",en:"Text"},variants:[],params:["placeholder","required","readonly"]},{type:"html",label:{ru:"Форматированный текст",en:"Formatted text"},variants:[],params:["placeholder","required","readonly"]},{type:"integer",label:{ru:"Целое число",en:"Integer"},variants:[{id:"stepper",label:{ru:"Кнопками «−» и «+»",en:"With steppers"}}],params:["unit","min","max","step","required","readonly"]},{type:"number",label:{ru:"Число",en:"Number"},variants:[{id:"scale",label:{ru:"Шкала 0–100",en:"Scale 0–100"}},{id:"stepper",label:{ru:"Кнопками «−» и «+»",en:"With steppers"}}],params:["unit","min","max","step","precision","required","readonly"]},{type:"date",label:{ru:"Дата",en:"Date"},variants:[],params:["required","readonly"]},{type:"datetime",label:{ru:"Дата и время",en:"Date and time"},variants:[],params:["min","max","step","required","readonly"]},{type:"time",label:{ru:"Время",en:"Time"},variants:[],params:["min","max","step","required","readonly"]},{type:"boolean",label:{ru:"Да или нет",en:"Yes or no"},variants:[],params:["trueText","falseText","required","readonly"]},{type:"choice",label:{ru:"Одно из списка",en:"One of a list"},variants:[{id:"buttons",label:{ru:"Кнопками",en:"As buttons"}}],params:["options","badgeAppearance","size","required","readonly"]},{type:"choices",label:{ru:"Несколько из списка",en:"Several of a list"},variants:[{id:"badges",label:{ru:"Значками",en:"As badges"}},{id:"checklist",label:{ru:"Флажками",en:"As a checklist"}},{id:"select",label:{ru:"Выпадающим списком",en:"As a dropdown"}}],params:["options","badgeAppearance","required","readonly"]},{type:"user",label:{ru:"Пользователь",en:"User"},variants:[],params:["placeholder","searchPlaceholder","required","readonly"]},{type:"record",label:{ru:"Запись",en:"Record"},variants:[],params:["placeholder","searchPlaceholder","required","readonly"]},{type:"relation",label:{ru:"Связь",en:"Relation"},variants:[],params:["placeholder","searchPlaceholder","required","readonly"]},{type:"lookup",label:{ru:"Из справочника",en:"From a reference list"},variants:[],params:["options","multiple","placeholder","searchPlaceholder","required","readonly"]},{type:"file",label:{ru:"Файл",en:"File"},variants:[{id:"image",label:{ru:"Изображение",en:"Image"}},{id:"image-card",label:{ru:"Изображение карточкой",en:"Image card"}},{id:"image-list",label:{ru:"Изображения списком",en:"Image list"}}],params:["accept","multiple","formats","uploadText","uploadSupportingText","uploadHint","required","readonly"]},{type:"color",label:{ru:"Цвет",en:"Colour"},variants:[],params:["swatches","required","readonly"]},{type:"include",label:{ru:"Код",en:"Code"},variants:[],params:["language","required","readonly"]}]);function i(e,t){return{view:Boolean(t.view?.[e]),edit:Boolean(t.edit?.[e]),cell:t.cell?.[e]?"own":"text",filter:t.filter?.[e]?"own":"text"}}n.d(t,["u",0,s])},"926043d18700"(e,t,n){function s(e){const t=e.values().next().value,n=t?.value;if(!n)return;const s=n.parentNode;var i;return s?{gap:(i=s,parseFloat(getComputedStyle(i).rowGap)||0),item:n,parent:s}:void 0}function i(e){let t=e;for(;t;){if(t.nodeName.toLowerCase().startsWith("sf-"))return t.parentNode;t=t.parentNode}return null}n.d(t,{PA:()=>i,lF:()=>s})},"870b5dfddc25"(e,t,n){function s(e){if("undefined"==typeof SF||!SF.Loader)return;const t=SF.Loader,n=Number(t.dragObserverLockCount||0);t.dragObserverLockCount=e?n+1:Math.max(n-1,0),t.stopObserver=t.dragObserverLockCount>0}n.d(t,{J:()=>s})},"5961360f41f4"(e,t,n){n.d(t,{f:()=>c});const s=Object.freeze(["main","tonal","outline"]),i=Object.freeze(["neutral","primary","secondary","tertiary","info","success","warning","error","on-surface"]),r=Object.freeze({danger:"error"}),a=Object.freeze(["1/3","1/2","1"]);function o(e){const t=String(e??"").trim().toLowerCase(),n=r[t]??t;return i.includes(n)?n:""}Object.freeze(i.flatMap(e=>s.filter(t=>!("on-surface"===e&&"tonal"===t)).flatMap(t=>a.map(n=>Object.freeze({type:t,scheme:e,size:n})))));const l=/^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;function c(e={}){const t=e?.scheme??e?.color,n="string"==typeof t?t.trim():"",s=o(n);return s?{scheme:s,rootStyle:""}:l.test(n)?{scheme:"neutral",rootStyle:`--sf-badge--background-color: color-mix(in srgb, ${n} 24%, transparent); --sf-badge--color: var(--sf-on-surface)`}:{scheme:"neutral",rootStyle:""}}},"94d60d3691b5"(e,t,n){n.a(e,async(e,t)=>{try{var s=n("deb1a4d61565"),i=n("5b7d7695b41b"),r=n("17828be41e75"),a=n("c1f17ed5a348"),o=n("f8651e83c6c6"),l=n("678dc07d76bf"),c=n("32294b89604f"),u=n("9d9caaf4f796"),d=n("5961360f41f4"),h=n("e5483002f3ea"),p=n("2a080a730149"),m=n("8137feb490e0"),f=n("43090d1c8307"),g=n("926043d18700"),b=n("870b5dfddc25"),y=n("116963e5e31b"),v=n("51250bf01ab0"),w=e([s,i,u,h,p,m,f,y]);[s,i,u,h,p,m,f,y]=w.then?(await w)():w;var x=n.n(s),$=n.n(y);const S=()=>globalThis.SF?.Preferences||v.A,k=e=>`sf-table/${String(e).replace(/[^\w.:-]+/gu,"-")}`,C=new Set(["sf-badge","sf-tag","sf-avatar"]),T="sf-table/*",_=Object.freeze({density:"normal",stripes:!1,lines:!1,singleLine:!1,stickyHead:!0});function A(e){for(let t=e;t;t=t.parentElement??t.getRootNode?.()?.host??null){if(t===document.body||t===document.documentElement)return null;const e=getComputedStyle(t);if(/(auto|scroll|overlay)/u.test(e.overflowY)&&t.scrollHeight>t.clientHeight+1)return t}return null}const F=(e={})=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e.replace(/-([a-z0-9])/gu,(e,t)=>t.toUpperCase()),t])),z={en:F(l.runtime),ru:F(c.runtime)},R=new Set(["select","settings","actions"]),E=()=>globalThis.SF?.Position||$(),O=Object.freeze({outputs:Object.freeze({selection:"record-ids.v1"}),inputs:Object.freeze({context:"record-ids.v1"})}),P=1e3;function M(e){for(let t=0;t<e.length;t+=1){const n=e.charCodeAt(t);if(n<32||127===n)return!0}return!1}function L(e){if(!Array.isArray(e)||e.length>P||Array.from(e).some(e=>!("string"==typeof e&&e.length>0&&e.length<=256&&!M(e)||Number.isSafeInteger(e)))||new Set(Array.from(e,e=>`${typeof e}:${e}`)).size!==e.length)throw new TypeError("Record identities must be unique nonempty strings or safe integers");return Object.freeze([...e])}let q=0;const j=300,I=20,B=60,D=40,V=new Set(["text","textarea","markdown","html"]);function K(e){return"contents"===getComputedStyle(e).display?e.firstElementChild??e:e}function N(e){return 4*Math.ceil((Math.ceil(e)+1)/4)}const W=(0,i.elementFromManifest)(a,{base:x(),lang:{en:l,ru:c},source:"ru",aliases:o});function U(e,t){const n=new Map;return e.forEach((e,t)=>{null!=e?.id&&n.set(String(e.id),t)}),t.some((e,t)=>{if(null==e?.id)return!1;const s=n.get(String(e.id));return void 0!==s&&s!==t})}class H extends W{static get sfPorts(){return O}static get props(){return{templateName:{attribute:"template",default:"default"},ariaLabel:{attribute:"aria-label",default:"Data table"},current:{attribute:"current",default:""},selectable:{type:Boolean,default:!0},verticalScroll:{attribute:"vertical-scroll",default:"self",values:["self","page"]},layout:{default:"table",values:["auto","table","list"]},listBelow:{attribute:"list-below",type:Number,default:600},listFields:{attribute:"list-fields",type:Number,default:3},toolbar:{type:Boolean,default:!0},settings:{type:Boolean,default:!0},pagin:{type:Boolean,default:!1},actions:{type:Boolean,default:!0},rowActions:{attribute:"row-actions",type:Boolean,default:!0},dragRows:{attribute:"drag-rows",type:Boolean,default:!1},rowReorder:{attribute:"row-reorder",type:Boolean,default:!1},inlineEdit:{attribute:"inline-edit",type:Boolean,default:!1},rowActionsVisible:{attribute:"row-actions-visible",default:"hover"},creatable:{type:Boolean,default:!0},filterTemplates:{attribute:"filter-templates",type:Boolean,default:!0},settingsMenu:{attribute:"settings-menu",type:Boolean,default:!0},size:{default:"1",values:["1/2","1"]},filterText:{attribute:"filter-text",default:"Filter"},clearText:{attribute:"clear-text",default:"Clear"},searchPlaceholder:{attribute:"search-placeholder",default:"Search"},createText:{attribute:"create-text",default:"Create"},pinColumnLabel:{attribute:"pin-column-label",default:"Pin the column"},unpinColumnLabel:{attribute:"unpin-column-label",default:"Unpin the column"},paginationTotal:{attribute:"pagination-total",type:Number,default:10},paginationPageSize:{attribute:"pagination-page-size",type:Number,default:10},pageSizes:{attribute:"page-sizes",default:"10,20,30,40"},contextMenuColumns:{attribute:"context-menu-columns",type:Number,default:1},rememberWidths:{attribute:"remember-widths",type:Boolean,default:!1},preferencesKey:{attribute:"preferences-key",default:""},tableSettingsKey:{attribute:"table-settings-key",default:""},dataState:{attribute:"data-state",default:"auto",values:["auto","loading","populated","empty","error"]},loadingText:{attribute:"loading-text",default:"Loading"},emptyText:{attribute:"empty-text",default:"No data"},errorText:{attribute:"error-text",default:"The data could not be loaded"},retryText:{attribute:"retry-text",default:"Try again"},columnMoveLabel:{attribute:"column-move-label",default:"Move the column"},filterApplyText:{attribute:"filter-apply-text",default:"Apply"},columnSearchPlaceholder:{attribute:"column-search-placeholder",default:"Search the fields"},columnSearchEmptyText:{attribute:"column-search-empty-text",default:"No field matches"}}}get contextMenuColumns(){const e=this.getNumberAttr?.("context-menu-columns",1)??1;return Number.isFinite(e)&&e>0?e:1}get tableSettingsKey(){return this.getAttribute?.("table-settings-key")||""}constructor(){super(),this._emptyContext=null,this.rowPointerDown=e=>this.handleRowPointerDown(e),this._windowRange=null,this._windowed=!1,this._rowHeight=0,this.addEventListener("sf-empty-state-action",e=>{const t=e.detail?.id;"retry"===t?(e.stopPropagation(),this.requestRetry()):"create"===t?(e.stopPropagation(),this.requestCreateIntent()):"reset-query"===t&&(e.stopPropagation(),this.resetQuery(this._emptyContext?.reset??"both"))}),this._portalContainer=null,this._instanceId="sf-table-"+ ++q,this._selectionPortKey="[]",this._routeContext=null,this._querySequence=0,this._pendingQuerySequence=null,this._abandonedQuery=!1,this._filterOptionPages=new Map,this._contextViewportBound=!1,this.contextKeyEvent=this.contextKeyEvent.bind(this),this.contextViewportEvent=this.contextViewportEvent.bind(this),this.ACTIONS_SETTINGS_ROW=[{name:this.text("editActionText"),id:"edit",component:{type:"button-icon",props:{kind:"icon",size:"1",appearance:"link",scheme:"on-surface",icon:"edit",ariaLabel:this.text("editActionText"),value:"edit"}}},{name:this.text("viewActionText"),id:"view",component:{type:"button-icon",props:{kind:"icon",size:"1",appearance:"link",scheme:"on-surface",icon:"visibility",ariaLabel:this.text("viewActionText"),value:"view"}}},{name:this.text("deleteActionText"),id:"delete",danger:!0,component:{type:"button-icon",props:{kind:"icon",size:"1",appearance:"link",scheme:"on-surface",status:"error",icon:"delete",ariaLabel:this.text("deleteActionText"),value:"delete"}}}],this.TABLE_ACTIONS_COLUMN={key:"actions",label:this.text("actionsColumnLabel"),system:!0},this.TABLE_SETTINGS_COLUMN={key:"settings",label:"settings",system:!0,width:"calc(var(--sf-text-height-1) + (var(--sf-ui-1--space-y-tightness-default) * 2) + var(--sf-b6))",component:{type:"button-icon",props:{size:"1",appearance:"link",scheme:"on-surface",icon:"settings",ariaLabel:this.text("settingsColumnLabel"),value:"settings","@click":e=>{const t=this.state.contextMenu?.open&&"table-settings"===this.state.contextMenu?.menu;t&&e.timeStamp-(this._settingsOpenedAt??0)>200?this.closeContextMenu():t||(this._settingsOpenedAt=e.timeStamp,this.openContextMenu(e,{menu:"table-settings"}))}}}},this.contextEvent=this.contextEvent.bind(this),this.hoverEvents=this.hoverEvents.bind(this),this.outEvent=this.outEvent.bind(this),this._contextEventBound=!1,this._hoverEventBound=!1,this._columnResizeEventBound=!1,this._headerSortableRow=null,this._headerSortableDetach=null,this._columnResizeState=null,this.searchChange=this.scheduleSearchChange.bind(this),this._searchDebounceTimer=null,this._searchPendingProps=null,this._searchHoldKey="",this.refs={contextMenu:this.createRef(),items:new Map,templateForm:this.createRef(),renameInput:this.createRef(),table:this.createRef(),scroll:this.createRef(),rail:this.createRef(),resizeGuide:this.createRef()},this._currentRowId=null,this._checkboxMeasureToken=0,this._responsiveWidth=0,this._responsiveObserver=null,this._filterTemplatesLoaded=!1,this.tempSettings=null,this.state={settingsChecked:!1,bulkActions:[],createItems:[],toolbarActions:[],columnSettingsQuery:"",sort:{key:null,direction:null},saveInputValue:"",search:{searchActive:!1,value:""},contextMenu:{open:!1},actions:this.getActions().map(e=>Object.assign(e,{visible:!0})),actionActive:this.getProp("actions"),columnSettings:{},selectIndeterminate:!1,filterDataDirty:!1,filter:{selectedTemplateKey:"default",fields:[],templates:[],edit:{rename:""}}},this.TABLE_SELECT_COLUMN={key:"select",label:"select",system:!0,width:"calc(var(--sf-text-height-1) + var(--sf-b6) + calc(var(--sf-px) * 2))",component:{type:"checkbox",props:{position:"end",rootClass:"content-main-between",size:this.size,"@change":e=>{const t=Boolean(e.target.checked);this._selectionAnchorId=null,this.set({selectIndeterminate:!1,settingsChecked:t}),this.updateRows(e=>({...e,select:this.getDefaultRowCell(this.TABLE_SELECT_COLUMN,{...e,selected:t,checked:t})}),"select-all")},indeterminate:this.state.selectIndeterminate,checked:this.state.settingsChecked,ariaLabel:this.text("selectAllLabel")}},rowComponent:{type:"checkbox",props:{position:"end",rootClass:"content-main-between",size:this.size}}}}get rows(){return this.getTableData().rows||[]}set rows(e){this.setRows(Array.isArray(e)?e:[])}get columns(){return this.getTableData().columns||[]}set columns(e){this.setColumns(Array.isArray(e)?e:[])}get tableData(){return this.getTableData()}set tableData(e){this.setTableData(e&&"object"==typeof e?e:{})}get tableSettings(){return this.getColumnSettings()}set tableSettings(e){this.setTableSettings(e&&"object"==typeof e?e:{})}get bulkActions(){return this.state?.bulkActions??[]}set bulkActions(e){this.setBulkActions(e)}get createItems(){return this.state?.createItems??[]}set createItems(e){this.setCreateItems(e)}get toolbarActions(){return this.getToolbarActions()}set toolbarActions(e){this.setToolbarActions(e)}get filterFields(){return this.getFilterFields()}set filterFields(e){this.setFilterFields(e)}get activeFilterFields(){return this.getActiveFilterFieldKeys()}set activeFilterFields(e){this.setActiveFilterFields(e)}get templates(){return this.getFilterTemplates()}set templates(e){this.setTemplates(e)}get sort(){const{key:e,direction:t}=this.state?.sort??{};return e&&t?[{key:e,direction:t}]:[]}set sort(e){const t=Array.isArray(e)?e[0]:e,n=t?.key??t?.field??null,s=t?.direction??t?.dir??null;n&&["asc","desc"].includes(s)?this.setSort(n,s):this.setSort(null,null)}get current(){return this._currentRowId??""}set current(e){const t=null==e?"":String(e);this._currentRowId=t||null,(this.getAttribute("current")??"")!==t?t?this.setAttribute("current",t):this.removeAttribute("current"):this.requestComponentUpdate("current")}attributeChangedCallback(e,t,n){"current"===e&&t!==n&&(this._currentRowId=n||null),super.attributeChangedCallback?.(e,t,n)}get selected(){return this._currentRowId??void 0}get selection(){return this.getSelectedRecordIds()}isActionParameters(e,t){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype&&t.some(t=>Object.hasOwn(e,t))}focusRowAction({id:e}={}){return null==e||""===e?{outcome:"refused",reason:"empty"}:(this.focusRow(String(e),{reveal:!0}),{outcome:"applied"})}sfAliasAdapters(){return{"sf-table-action-intent":e=>Object.freeze({action_id:e.action,record_ids:e.ids}),"sf-port-output":e=>Object.freeze({port:"selection",value:e.ids}),onSearchEnd:e=>e.search}}getActions(){return this.getProp("actions")?this.ACTIONS_SETTINGS_ROW.map(e=>{const{name:t,id:n}=e;return{name:t,id:n}}):[]}isSearchHoldKey(e=""){return"Backspace"===e||"Delete"===e}clearSearchDebounce(){this._searchDebounceTimer&&(clearTimeout(this._searchDebounceTimer),this._searchDebounceTimer=null)}scheduleSearchChange(e={}){return this._searchPendingProps=e,this.clearSearchDebounce(),this._searchHoldKey||(this._searchDebounceTimer=setTimeout(()=>{const e=this._searchPendingProps||{};this._searchPendingProps=null,this._searchDebounceTimer=null,this.updateSearchState(e)},500)),this}handleSearchKeyDown(e){return this.isSearchHoldKey(e?.key)?(this._searchHoldKey=e.key,this.clearSearchDebounce(),this):this}handleSearchKeyUp(e){return this._searchHoldKey&&e?.key===this._searchHoldKey?(this._searchHoldKey="",this._searchPendingProps&&this.scheduleSearchChange(this._searchPendingProps),this):this}updateSearchState(e={},t=!0){const n=this.state.search||{};let s=!1;for(const[t,i]of Object.entries(e))if(!Object.is(n[t],i)){s=!0;break}return s?(this.set(t=>({search:{...t.search,...e}})),t?(this.emitTableEvent("search-change",{search:this.state.search.value}),this):this):this}emitTableEvent(e,t={},n={}){return this.sfEmit(e,t,n)}requestActionIntent(e,t,n={}){if(this.isActionParameters?.(e,["action-id","actionId"])&&({actionId:e,recordIds:t}={actionId:e["action-id"]??e.actionId,recordIds:e["record-ids"]??e.recordIds}),"string"!=typeof e||!e.trim()||!Array.isArray(t)||0===t.length||Array.from(t).some(e=>!("string"==typeof e&&e.length>0||Number.isSafeInteger(e))))throw new TypeError("Action intent requires an opaque action ID and nonempty typed record IDs");const s=Object.freeze([...t]),i=this.getTableData().rows||[],r={};for(const e of s){const t=i.find(t=>t?.id===e)?.revision;null!=t&&(r[e]=t)}const a=n?.scope??(1===s.length?"entry":"selection");return this.emitTableEvent("apply",Object.freeze({action:e,scope:a,ids:s,revisions:Object.freeze(r)})),{outcome:"applied"}}getSelectedRecordIds(){return this.getTableData().rows.filter(e=>!0===e.select?.component?.props?.checked).map(e=>e.id)}setBulkActions(e=[]){if(!Array.isArray(e)||Array.from(e).some(e=>!e||"object"!=typeof e||"string"!=typeof e.id||!e.id.trim()||"string"!=typeof e.name||!e.name.trim()||Object.keys(e).some(e=>"id"!==e&&"name"!==e)))throw new TypeError("Bulk actions require opaque id and name only");return this.set({bulkActions:e.map(({id:e,name:t})=>({id:e,name:t}))})}renderBulkActions(){if(!this.state.bulkActions?.length)return p.nothing;const e=this.getSelectedRecordIds();return p.html`<div class="flex flex-wrap gap-1/3">
575
- ${this.state.bulkActions.map(t=>p.html`<sf-button
574
+ `}const lt={string:se,text:Ye,html:Ze,integer:Xe,number:Xe,date:et,datetime:et,time:et,boolean:tt,choice:nt,choices:st,user:it,record:rt,relation:rt,lookup:at,file:ot,color:F,include:ae};function ct(e={},t,n,s={}){const i=e.propertyType||e.type||e.dataType,r=lt[i];if(!r)return null;const a=He;He=Ne(s);try{return r(e,t,n)}finally{He=a}}"undefined"!=typeof window&&(window.SF=window.SF||{},window.SF.fieldRenderers={...window.SF.fieldRenderers||{},renderCellField:U,renderEditField:Ue,renderFilterField:S,renderViewField:ct,FILTER_RENDERERS:$,dateTime:{split:c.AC,compose:c.cy,normalizeTime:c.d2,splitTime:c.SB,composeTime:c.MC},registry:l.u.map(e=>{return{...e,modes:(t=e.type,(0,l.U)(t,{view:lt,edit:G,cell:M,filter:$}))};var t})},globalThis.document?.dispatchEvent?.(new CustomEvent("sf-field-renderers-ready"))),s()}catch(ut){s(ut)}})},dd6973f77245(e,t,n){n.d(t,{$:()=>o,C:()=>l});const s={0:"\\d",a:"\\p{L}","*":"[\\s\\S]"},i={0:e=>/\d/u.test(e),a:e=>/\p{L}/u.test(e),"*":()=>!0},r=e=>e.replace(/[\\^$.*+?()[\]{}|/]/gu,"\\$&");const a=new Map;function o(e){const t=e?.mask;return"string"==typeof t&&""!==t?t:null}function l(e,t,n="_"){const o=String(e??"");a.has(t)||a.set(t,function(e){let t="";const n=[];for(let a=0;a<e.length;a+=1){const o=e[a];"\\"===o?(a+=1,a<e.length&&(t+=r(e[a]),n.push({fixed:e[a]}))):"{"===o||"}"===o||"["===o||"]"===o||(s[o]?(t+=s[o],n.push({test:i[o]})):(t+=r(o),n.push({fixed:o})))}return{complete:new RegExp(`^${t}$`,"u"),tokens:n}}(t));const{complete:l,tokens:c}=a.get(t);return l.test(o)?"complete":0===function(e,t,n){let s=0,i=0;for(const r of e){for(;i<t.length&&void 0!==t[i].fixed&&t[i].fixed!==r;)i+=1;if(i>=t.length)break;const e=t[i];void 0!==e.fixed||r===n?i+=1:e.test(r)&&(s+=1,i+=1)}return s}(o,c,n)?"empty":"incomplete"}},fc654eb7fab0(e,t,n){n.d(t,{U:()=>i});const s=Object.freeze([{type:"string",label:{ru:"Строка",en:"String"},variants:[{id:"phone",label:{ru:"Телефон",en:"Phone"}},{id:"password",label:{ru:"Пароль",en:"Password"},writeOnly:!0}],params:["placeholder","mask","nullable","required","readonly"]},{type:"text",label:{ru:"Текст",en:"Text"},variants:[],params:["placeholder","required","readonly"]},{type:"html",label:{ru:"Форматированный текст",en:"Formatted text"},variants:[],params:["placeholder","required","readonly"]},{type:"integer",label:{ru:"Целое число",en:"Integer"},variants:[{id:"stepper",label:{ru:"Кнопками «−» и «+»",en:"With steppers"}}],params:["unit","min","max","step","required","readonly"]},{type:"number",label:{ru:"Число",en:"Number"},variants:[{id:"scale",label:{ru:"Шкала 0–100",en:"Scale 0–100"}},{id:"stepper",label:{ru:"Кнопками «−» и «+»",en:"With steppers"}}],params:["unit","min","max","step","precision","required","readonly"]},{type:"date",label:{ru:"Дата",en:"Date"},variants:[],params:["required","readonly"]},{type:"datetime",label:{ru:"Дата и время",en:"Date and time"},variants:[],params:["min","max","step","required","readonly"]},{type:"time",label:{ru:"Время",en:"Time"},variants:[],params:["min","max","step","required","readonly"]},{type:"boolean",label:{ru:"Да или нет",en:"Yes or no"},variants:[],params:["trueText","falseText","required","readonly"]},{type:"choice",label:{ru:"Одно из списка",en:"One of a list"},variants:[{id:"buttons",label:{ru:"Кнопками",en:"As buttons"}}],params:["options","badgeAppearance","size","required","readonly"]},{type:"choices",label:{ru:"Несколько из списка",en:"Several of a list"},variants:[{id:"badges",label:{ru:"Значками",en:"As badges"}},{id:"checklist",label:{ru:"Флажками",en:"As a checklist"}},{id:"select",label:{ru:"Выпадающим списком",en:"As a dropdown"}}],params:["options","badgeAppearance","required","readonly"]},{type:"user",label:{ru:"Пользователь",en:"User"},variants:[],params:["placeholder","searchPlaceholder","required","readonly"]},{type:"record",label:{ru:"Запись",en:"Record"},variants:[],params:["placeholder","searchPlaceholder","required","readonly"]},{type:"relation",label:{ru:"Связь",en:"Relation"},variants:[],params:["placeholder","searchPlaceholder","required","readonly"]},{type:"lookup",label:{ru:"Из справочника",en:"From a reference list"},variants:[],params:["options","multiple","placeholder","searchPlaceholder","required","readonly"]},{type:"file",label:{ru:"Файл",en:"File"},variants:[{id:"image",label:{ru:"Изображение",en:"Image"}},{id:"image-card",label:{ru:"Изображение карточкой",en:"Image card"}},{id:"image-list",label:{ru:"Изображения списком",en:"Image list"}}],params:["accept","multiple","formats","uploadText","uploadSupportingText","uploadHint","required","readonly"]},{type:"color",label:{ru:"Цвет",en:"Colour"},variants:[],params:["swatches","required","readonly"]},{type:"include",label:{ru:"Код",en:"Code"},variants:[],params:["language","required","readonly"]}]);function i(e,t){return{view:Boolean(t.view?.[e]),edit:Boolean(t.edit?.[e]),cell:t.cell?.[e]?"own":"text",filter:t.filter?.[e]?"own":"text"}}n.d(t,["u",0,s])},"926043d18700"(e,t,n){function s(e){const t=e.values().next().value,n=t?.value;if(!n)return;const s=n.parentNode;var i;return s?{gap:(i=s,parseFloat(getComputedStyle(i).rowGap)||0),item:n,parent:s}:void 0}function i(e){let t=e;for(;t;){if(t.nodeName.toLowerCase().startsWith("sf-"))return t.parentNode;t=t.parentNode}return null}n.d(t,{PA:()=>i,lF:()=>s})},"870b5dfddc25"(e,t,n){function s(e){if("undefined"==typeof SF||!SF.Loader)return;const t=SF.Loader,n=Number(t.dragObserverLockCount||0);t.dragObserverLockCount=e?n+1:Math.max(n-1,0),t.stopObserver=t.dragObserverLockCount>0}n.d(t,{J:()=>s})},"5961360f41f4"(e,t,n){n.d(t,{f:()=>c});const s=Object.freeze(["main","tonal","outline"]),i=Object.freeze(["neutral","primary","secondary","tertiary","info","success","warning","error","on-surface"]),r=Object.freeze({danger:"error"}),a=Object.freeze(["1/3","1/2","1"]);function o(e){const t=String(e??"").trim().toLowerCase(),n=r[t]??t;return i.includes(n)?n:""}Object.freeze(i.flatMap(e=>s.filter(t=>!("on-surface"===e&&"tonal"===t)).flatMap(t=>a.map(n=>Object.freeze({type:t,scheme:e,size:n})))));const l=/^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;function c(e={}){const t=e?.scheme??e?.color,n="string"==typeof t?t.trim():"",s=o(n);return s?{scheme:s,rootStyle:""}:l.test(n)?{scheme:"neutral",rootStyle:`--sf-badge--background-color: color-mix(in srgb, ${n} 24%, transparent); --sf-badge--color: var(--sf-on-surface)`}:{scheme:"neutral",rootStyle:""}}},"94d60d3691b5"(e,t,n){n.a(e,async(e,t)=>{try{var s=n("deb1a4d61565"),i=n("5b7d7695b41b"),r=n("17828be41e75"),a=n("c1f17ed5a348"),o=n("f8651e83c6c6"),l=n("678dc07d76bf"),c=n("32294b89604f"),u=n("9d9caaf4f796"),d=n("5961360f41f4"),h=n("e5483002f3ea"),p=n("eb06ad68f8d3"),m=n("2f31b00ad99a"),f=n("2a080a730149"),g=n("8137feb490e0"),b=n("43090d1c8307"),y=n("926043d18700"),v=n("870b5dfddc25"),w=n("116963e5e31b"),x=n("51250bf01ab0"),$=e([s,i,u,h,m,f,g,b,w]);[s,i,u,h,m,f,g,b,w]=$.then?(await $)():$;var S=n.n(s),k=n.n(w);const C=()=>globalThis.SF?.Preferences||x.A,T=e=>`sf-table/${String(e).replace(/[^\w.:-]+/gu,"-")}`,_=new Set(["sf-badge","sf-tag","sf-avatar"]),A="sf-table/*",F=Object.freeze({density:"normal",stripes:!1,lines:!1,singleLine:!1,stickyHead:!0});function z(e){for(let t=e;t;t=t.parentElement??t.getRootNode?.()?.host??null){if(t===document.body||t===document.documentElement)return null;const e=getComputedStyle(t);if(/(auto|scroll|overlay)/u.test(e.overflowY)&&t.scrollHeight>t.clientHeight+1)return t}return null}const R=(e={})=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e.replace(/-([a-z0-9])/gu,(e,t)=>t.toUpperCase()),t])),E={en:R(l.runtime),ru:R(c.runtime)},O=new Set(["select","settings","actions"]),P=()=>globalThis.SF?.Position||k(),M=Object.freeze({outputs:Object.freeze({selection:"record-ids.v1"}),inputs:Object.freeze({context:"record-ids.v1"})}),L=1e3;function q(e){for(let t=0;t<e.length;t+=1){const n=e.charCodeAt(t);if(n<32||127===n)return!0}return!1}function j(e){if(!Array.isArray(e)||e.length>L||Array.from(e).some(e=>!("string"==typeof e&&e.length>0&&e.length<=256&&!q(e)||Number.isSafeInteger(e)))||new Set(Array.from(e,e=>`${typeof e}:${e}`)).size!==e.length)throw new TypeError("Record identities must be unique nonempty strings or safe integers");return Object.freeze([...e])}let I=0;const B=300,D=20,V=60,N=40,K=new Set(["text","textarea","markdown","html"]);function W(e){return"contents"===getComputedStyle(e).display?e.firstElementChild??e:e}function U(e){return 4*Math.ceil((Math.ceil(e)+1)/4)}const H=(0,i.elementFromManifest)(a,{base:S(),lang:{en:l,ru:c},source:"ru",aliases:o});function G(e,t){const n=new Map;return e.forEach((e,t)=>{null!=e?.id&&n.set(String(e.id),t)}),t.some((e,t)=>{if(null==e?.id)return!1;const s=n.get(String(e.id));return void 0!==s&&s!==t})}class J extends H{static get sfPorts(){return M}static get props(){return{templateName:{attribute:"template",default:"default"},ariaLabel:{attribute:"aria-label",default:"Data table"},current:{attribute:"current",default:""},selectable:{type:Boolean,default:!0},verticalScroll:{attribute:"vertical-scroll",default:"self",values:["self","page"]},layout:{default:"table",values:["auto","table","list"]},listBelow:{attribute:"list-below",type:Number,default:600},listFields:{attribute:"list-fields",type:Number,default:3},toolbar:{type:Boolean,default:!0},settings:{type:Boolean,default:!0},pagin:{type:Boolean,default:!1},actions:{type:Boolean,default:!0},rowActions:{attribute:"row-actions",type:Boolean,default:!0},dragRows:{attribute:"drag-rows",type:Boolean,default:!1},rowReorder:{attribute:"row-reorder",type:Boolean,default:!1},inlineEdit:{attribute:"inline-edit",type:Boolean,default:!1},rowActionsVisible:{attribute:"row-actions-visible",default:"hover"},creatable:{type:Boolean,default:!0},filterTemplates:{attribute:"filter-templates",type:Boolean,default:!0},settingsMenu:{attribute:"settings-menu",type:Boolean,default:!0},size:{default:"1",values:["1/2","1"]},filterText:{attribute:"filter-text",default:"Filter"},clearText:{attribute:"clear-text",default:"Clear"},searchPlaceholder:{attribute:"search-placeholder",default:"Search"},createText:{attribute:"create-text",default:"Create"},pinColumnLabel:{attribute:"pin-column-label",default:"Pin the column"},unpinColumnLabel:{attribute:"unpin-column-label",default:"Unpin the column"},paginationTotal:{attribute:"pagination-total",type:Number,default:10},paginationPageSize:{attribute:"pagination-page-size",type:Number,default:10},pageSizes:{attribute:"page-sizes",default:"10,20,30,40"},contextMenuColumns:{attribute:"context-menu-columns",type:Number,default:1},rememberWidths:{attribute:"remember-widths",type:Boolean,default:!1},preferencesKey:{attribute:"preferences-key",default:""},tableSettingsKey:{attribute:"table-settings-key",default:""},dataState:{attribute:"data-state",default:"auto",values:["auto","loading","populated","empty","error"]},loadingText:{attribute:"loading-text",default:"Loading"},emptyText:{attribute:"empty-text",default:"No data"},errorText:{attribute:"error-text",default:"The data could not be loaded"},retryText:{attribute:"retry-text",default:"Try again"},columnMoveLabel:{attribute:"column-move-label",default:"Move the column"},filterApplyText:{attribute:"filter-apply-text",default:"Apply"},columnSearchPlaceholder:{attribute:"column-search-placeholder",default:"Search the fields"},columnSearchEmptyText:{attribute:"column-search-empty-text",default:"No field matches"}}}get contextMenuColumns(){const e=this.getNumberAttr?.("context-menu-columns",1)??1;return Number.isFinite(e)&&e>0?e:1}get tableSettingsKey(){return this.getAttribute?.("table-settings-key")||""}constructor(){super(),this._emptyContext=null,this.rowPointerDown=e=>this.handleRowPointerDown(e),this._windowRange=null,this._windowed=!1,this._rowHeight=0,this.addEventListener("sf-empty-state-action",e=>{const t=e.detail?.id;"retry"===t?(e.stopPropagation(),this.requestRetry()):"create"===t?(e.stopPropagation(),this.requestCreateIntent()):"reset-query"===t&&(e.stopPropagation(),this.resetQuery(this._emptyContext?.reset??"both"))}),this._portalContainer=null,this._instanceId="sf-table-"+ ++I,this._selectionPortKey="[]",this._routeContext=null,this._querySequence=0,this._pendingQuerySequence=null,this._abandonedQuery=!1,this._filterOptionPages=new Map,this._contextViewportBound=!1,this.contextKeyEvent=this.contextKeyEvent.bind(this),this.contextViewportEvent=this.contextViewportEvent.bind(this),this.ACTIONS_SETTINGS_ROW=[{name:this.text("editActionText"),id:"edit",component:{type:"button-icon",props:{kind:"icon",size:"1",appearance:"link",scheme:"on-surface",icon:"edit",ariaLabel:this.text("editActionText"),value:"edit"}}},{name:this.text("viewActionText"),id:"view",component:{type:"button-icon",props:{kind:"icon",size:"1",appearance:"link",scheme:"on-surface",icon:"visibility",ariaLabel:this.text("viewActionText"),value:"view"}}},{name:this.text("deleteActionText"),id:"delete",danger:!0,component:{type:"button-icon",props:{kind:"icon",size:"1",appearance:"link",scheme:"on-surface",status:"error",icon:"delete",ariaLabel:this.text("deleteActionText"),value:"delete"}}}],this.TABLE_ACTIONS_COLUMN={key:"actions",label:this.text("actionsColumnLabel"),system:!0},this.TABLE_SETTINGS_COLUMN={key:"settings",label:"settings",system:!0,width:"calc(var(--sf-text-height-1) + (var(--sf-ui-1--space-y-tightness-default) * 2) + var(--sf-b6))",component:{type:"button-icon",props:{size:"1",appearance:"link",scheme:"on-surface",icon:"settings",ariaLabel:this.text("settingsColumnLabel"),value:"settings","@click":e=>{const t=this.state.contextMenu?.open&&"table-settings"===this.state.contextMenu?.menu;t&&e.timeStamp-(this._settingsOpenedAt??0)>200?this.closeContextMenu():t||(this._settingsOpenedAt=e.timeStamp,this.openContextMenu(e,{menu:"table-settings"}))}}}},this.contextEvent=this.contextEvent.bind(this),this.hoverEvents=this.hoverEvents.bind(this),this.outEvent=this.outEvent.bind(this),this._contextEventBound=!1,this._hoverEventBound=!1,this._columnResizeEventBound=!1,this._headerSortableRow=null,this._headerSortableDetach=null,this._columnResizeState=null,this.searchChange=this.scheduleSearchChange.bind(this),this._searchDebounceTimer=null,this._searchPendingProps=null,this._searchHoldKey="",this.refs={contextMenu:this.createRef(),items:new Map,templateForm:this.createRef(),renameInput:this.createRef(),table:this.createRef(),scroll:this.createRef(),rail:this.createRef(),resizeGuide:this.createRef()},this._currentRowId=null,this._checkboxMeasureToken=0,this._responsiveWidth=0,this._responsiveObserver=null,this._filterTemplatesLoaded=!1,this.tempSettings=null,this.state={settingsChecked:!1,bulkActions:[],createItems:[],toolbarActions:[],columnSettingsQuery:"",sort:{key:null,direction:null},saveInputValue:"",search:{searchActive:!1,value:""},contextMenu:{open:!1},actions:this.getActions().map(e=>Object.assign(e,{visible:!0})),actionActive:this.getProp("actions"),columnSettings:{},selectIndeterminate:!1,filterDataDirty:!1,filter:{selectedTemplateKey:"default",fields:[],templates:[],edit:{rename:""}}},this.TABLE_SELECT_COLUMN={key:"select",label:"select",system:!0,width:"calc(var(--sf-text-height-1) + var(--sf-b6) + calc(var(--sf-px) * 2))",component:{type:"checkbox",props:{position:"end",rootClass:"content-main-between",size:this.size,"@change":e=>{const t=Boolean(e.target.checked);this._selectionAnchorId=null,this.set({selectIndeterminate:!1,settingsChecked:t}),this.updateRows(e=>({...e,select:this.getDefaultRowCell(this.TABLE_SELECT_COLUMN,{...e,selected:t,checked:t})}),"select-all")},indeterminate:this.state.selectIndeterminate,checked:this.state.settingsChecked,ariaLabel:this.text("selectAllLabel")}},rowComponent:{type:"checkbox",props:{position:"end",rootClass:"content-main-between",size:this.size}}}}get rows(){return this.getTableData().rows||[]}set rows(e){this.setRows(Array.isArray(e)?e:[])}get columns(){return this.getTableData().columns||[]}set columns(e){this.setColumns(Array.isArray(e)?e:[])}get tableData(){return this.getTableData()}set tableData(e){this.setTableData(e&&"object"==typeof e?e:{})}get tableSettings(){return this.getColumnSettings()}set tableSettings(e){this.setTableSettings(e&&"object"==typeof e?e:{})}get bulkActions(){return this.state?.bulkActions??[]}set bulkActions(e){this.setBulkActions(e)}get createItems(){return this.state?.createItems??[]}set createItems(e){this.setCreateItems(e)}get toolbarActions(){return this.getToolbarActions()}set toolbarActions(e){this.setToolbarActions(e)}get filterFields(){return this.getFilterFields()}set filterFields(e){this.setFilterFields(e)}get activeFilterFields(){return this.getActiveFilterFieldKeys()}set activeFilterFields(e){this.setActiveFilterFields(e)}get templates(){return this.getFilterTemplates()}set templates(e){this.setTemplates(e)}get sort(){const{key:e,direction:t}=this.state?.sort??{};return e&&t?[{key:e,direction:t}]:[]}set sort(e){const t=Array.isArray(e)?e[0]:e,n=t?.key??t?.field??null,s=t?.direction??t?.dir??null;n&&["asc","desc"].includes(s)?this.setSort(n,s):this.setSort(null,null)}get current(){return this._currentRowId??""}set current(e){const t=null==e?"":String(e);this._currentRowId=t||null,(this.getAttribute("current")??"")!==t?t?this.setAttribute("current",t):this.removeAttribute("current"):this.requestComponentUpdate("current")}attributeChangedCallback(e,t,n){"current"===e&&t!==n&&(this._currentRowId=n||null),super.attributeChangedCallback?.(e,t,n)}get selected(){return this._currentRowId??void 0}get selection(){return this.getSelectedRecordIds()}isActionParameters(e,t){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype&&t.some(t=>Object.hasOwn(e,t))}focusRowAction({id:e}={}){return null==e||""===e?{outcome:"refused",reason:"empty"}:(this.focusRow(String(e),{reveal:!0}),{outcome:"applied"})}sfAliasAdapters(){return{"sf-table-action-intent":e=>Object.freeze({action_id:e.action,record_ids:e.ids}),"sf-port-output":e=>Object.freeze({port:"selection",value:e.ids}),onSearchEnd:e=>e.search}}getActions(){return this.getProp("actions")?this.ACTIONS_SETTINGS_ROW.map(e=>{const{name:t,id:n}=e;return{name:t,id:n}}):[]}isSearchHoldKey(e=""){return"Backspace"===e||"Delete"===e}clearSearchDebounce(){this._searchDebounceTimer&&(clearTimeout(this._searchDebounceTimer),this._searchDebounceTimer=null)}scheduleSearchChange(e={}){return this._searchPendingProps=e,this.clearSearchDebounce(),this._searchHoldKey||(this._searchDebounceTimer=setTimeout(()=>{const e=this._searchPendingProps||{};this._searchPendingProps=null,this._searchDebounceTimer=null,this.updateSearchState(e)},500)),this}handleSearchKeyDown(e){return this.isSearchHoldKey(e?.key)?(this._searchHoldKey=e.key,this.clearSearchDebounce(),this):this}handleSearchKeyUp(e){return this._searchHoldKey&&e?.key===this._searchHoldKey?(this._searchHoldKey="",this._searchPendingProps&&this.scheduleSearchChange(this._searchPendingProps),this):this}updateSearchState(e={},t=!0){const n=this.state.search||{};let s=!1;for(const[t,i]of Object.entries(e))if(!Object.is(n[t],i)){s=!0;break}return s?(this.set(t=>({search:{...t.search,...e}})),t?(this.emitTableEvent("search-change",{search:this.state.search.value}),this):this):this}emitTableEvent(e,t={},n={}){return this.sfEmit(e,t,n)}requestActionIntent(e,t,n={}){if(this.isActionParameters?.(e,["action-id","actionId"])&&({actionId:e,recordIds:t}={actionId:e["action-id"]??e.actionId,recordIds:e["record-ids"]??e.recordIds}),"string"!=typeof e||!e.trim()||!Array.isArray(t)||0===t.length||Array.from(t).some(e=>!("string"==typeof e&&e.length>0||Number.isSafeInteger(e))))throw new TypeError("Action intent requires an opaque action ID and nonempty typed record IDs");const s=Object.freeze([...t]),i=this.getTableData().rows||[],r={};for(const e of s){const t=i.find(t=>t?.id===e)?.revision;null!=t&&(r[e]=t)}const a=n?.scope??(1===s.length?"entry":"selection");return this.emitTableEvent("apply",Object.freeze({action:e,scope:a,ids:s,revisions:Object.freeze(r)})),{outcome:"applied"}}getSelectedRecordIds(){return this.getTableData().rows.filter(e=>!0===e.select?.component?.props?.checked).map(e=>e.id)}setBulkActions(e=[]){if(!Array.isArray(e)||Array.from(e).some(e=>!e||"object"!=typeof e||"string"!=typeof e.id||!e.id.trim()||"string"!=typeof e.name||!e.name.trim()||Object.keys(e).some(e=>"id"!==e&&"name"!==e)))throw new TypeError("Bulk actions require opaque id and name only");return this.set({bulkActions:e.map(({id:e,name:t})=>({id:e,name:t}))})}renderBulkActions(){if(!this.state.bulkActions?.length)return f.nothing;const e=this.getSelectedRecordIds();return f.html`<div class="flex flex-wrap gap-1/3">
575
+ ${this.state.bulkActions.map(t=>f.html`<sf-button
576
576
  text=${t.name} ?disabled=${0===e.length}
577
577
  @click=${()=>{const e=this.getSelectedRecordIds();e.length&&this.requestActionIntent(t.id,e,{scope:"selection"})}}></sf-button>`)}
578
- </div>`}setCreateItems(e=[]){if(!Array.isArray(e)||Array.from(e).some(e=>!e||"object"!=typeof e||"string"!=typeof e.id||!e.id.trim()||"string"!=typeof e.name||!e.name.trim()||Object.keys(e).some(e=>"id"!==e&&"name"!==e)))throw new TypeError("Create items require opaque id and name only");return this.set({createItems:e.map(({id:e,name:t})=>({id:e,name:t}))})}requestCreateIntent(e=null){if(this.isActionParameters?.(e,["item-id","itemId"])&&(e=e["item-id"]??e.itemId??null),null!==e&&!this.state.createItems.some(t=>t.id===e))throw new TypeError(`sf-view-table has no create item ${String(e)}`);return this.emitTableEvent("create",Object.freeze({item:e})),{outcome:"applied"}}setToolbarActions(e=[]){if(!Array.isArray(e)||Array.from(e).some(e=>!e||"object"!=typeof e||"string"!=typeof e.id||!e.id.trim()||"string"!=typeof e.label||!e.label.trim()||null!=e.icon&&"string"!=typeof e.icon||null!=e.href&&!this.isSameSiteHref(e.href)||Object.keys(e).some(e=>!["id","label","icon","href"].includes(e))))throw new TypeError("Toolbar actions require id and label, and an optional icon and same-site href");return this.set({toolbarActions:e.map(({id:e,label:t,icon:n,href:s})=>({id:e,label:t,...n?{icon:n}:{},...s?{href:s}:{}}))})}getToolbarActions(){return(this.state.toolbarActions||[]).map(e=>({...e}))}isSameSiteHref(e=""){const t=String(e??"").trim();if(!t||t.startsWith("//"))return!1;try{return new URL(t,document.baseURI).origin===new URL(document.baseURI).origin}catch{return!1}}requestToolbarAction(e){const t=this.getToolbarActions().find(t=>t.id===e);if(!t)throw new TypeError(`sf-view-table has no toolbar action ${String(e)}`);return this.emitTableEvent("toolbar-action",Object.freeze({action:t.id,href:t.href??null}),{cancelable:!0})&&t.href&&this.isSameSiteHref(t.href)&&window.location.assign(t.href),this}renderToolbarActionsContextMenu(e){const{x:t,y:n}=e,s=this.getToolbarActions(),i=s.map(e=>({id:String(e.id),text:e.label,...e.icon?{icon:e.icon}:{}}));return p.html`
578
+ </div>`}setCreateItems(e=[]){if(!Array.isArray(e)||Array.from(e).some(e=>!e||"object"!=typeof e||"string"!=typeof e.id||!e.id.trim()||"string"!=typeof e.name||!e.name.trim()||Object.keys(e).some(e=>"id"!==e&&"name"!==e)))throw new TypeError("Create items require opaque id and name only");return this.set({createItems:e.map(({id:e,name:t})=>({id:e,name:t}))})}requestCreateIntent(e=null){if(this.isActionParameters?.(e,["item-id","itemId"])&&(e=e["item-id"]??e.itemId??null),null!==e&&!this.state.createItems.some(t=>t.id===e))throw new TypeError(`sf-view-table has no create item ${String(e)}`);return this.emitTableEvent("create",Object.freeze({item:e})),{outcome:"applied"}}setToolbarActions(e=[]){if(!Array.isArray(e)||Array.from(e).some(e=>!e||"object"!=typeof e||"string"!=typeof e.id||!e.id.trim()||"string"!=typeof e.label||!e.label.trim()||null!=e.icon&&"string"!=typeof e.icon||null!=e.href&&!this.isSameSiteHref(e.href)||Object.keys(e).some(e=>!["id","label","icon","href"].includes(e))))throw new TypeError("Toolbar actions require id and label, and an optional icon and same-site href");return this.set({toolbarActions:e.map(({id:e,label:t,icon:n,href:s})=>({id:e,label:t,...n?{icon:n}:{},...s?{href:s}:{}}))})}getToolbarActions(){return(this.state.toolbarActions||[]).map(e=>({...e}))}isSameSiteHref(e=""){const t=String(e??"").trim();if(!t||t.startsWith("//"))return!1;try{return new URL(t,document.baseURI).origin===new URL(document.baseURI).origin}catch{return!1}}requestToolbarAction(e){const t=this.getToolbarActions().find(t=>t.id===e);if(!t)throw new TypeError(`sf-view-table has no toolbar action ${String(e)}`);return this.emitTableEvent("toolbar-action",Object.freeze({action:t.id,href:t.href??null}),{cancelable:!0})&&t.href&&this.isSameSiteHref(t.href)&&window.location.assign(t.href),this}renderToolbarActionsContextMenu(e){const{x:t,y:n}=e,s=this.getToolbarActions(),i=s.map(e=>({id:String(e.id),text:e.label,...e.icon?{icon:e.icon}:{}}));return f.html`
579
579
  <sf-menu-context
580
580
  size=${"1/2"===this.size?"1/2":"1"}
581
581
  :key=${t+n}
@@ -590,7 +590,7 @@
590
590
  .entries=${i}
591
591
  @sf-menu-context-select=${e=>{const t=s.find(t=>String(t.id)===e.detail?.id);this.closeContextMenu(),t&&this.requestToolbarAction(t.id)}}
592
592
  ></sf-menu-context>
593
- `}renderListSortContextMenu(e){const{x:t,y:n}=e,s=this.state.sort||{},i=(e,t)=>{this.closeContextMenu(),this.setSort(e,t),this.emitTableEvent("sort-change",Object.freeze({key:e,direction:t}))},r=new Map,a=(e,t,n)=>{const i=`${t??""}:${n??""}`;return r.set(i,[t,n]),{id:i,text:e,kind:"radio",checked:s.key===t&&s.direction===n}},o=this.getColumns().filter(e=>e?.sortable&&!e.system&&!["select","settings","actions"].includes(e.key)),l=[a(this.text("sortNone"),null,null),...o.flatMap(e=>[a(`${e.label??e.key}, ${this.text("sortAscending")}`,e.key,"asc"),a(`${e.label??e.key}, ${this.text("sortDescending")}`,e.key,"desc")])];return p.html`
593
+ `}renderListSortContextMenu(e){const{x:t,y:n}=e,s=this.state.sort||{},i=(e,t)=>{this.closeContextMenu(),this.setSort(e,t),this.emitTableEvent("sort-change",Object.freeze({key:e,direction:t}))},r=new Map,a=(e,t,n)=>{const i=`${t??""}:${n??""}`;return r.set(i,[t,n]),{id:i,text:e,kind:"radio",checked:s.key===t&&s.direction===n}},o=this.getColumns().filter(e=>e?.sortable&&!e.system&&!["select","settings","actions"].includes(e.key)),l=[a(this.text("sortNone"),null,null),...o.flatMap(e=>[a(`${e.label??e.key}, ${this.text("sortAscending")}`,e.key,"asc"),a(`${e.label??e.key}, ${this.text("sortDescending")}`,e.key,"desc")])];return f.html`
594
594
  <sf-menu-context
595
595
  size=${"1/2"===this.size?"1/2":"1"}
596
596
  :key=${t+n}
@@ -605,7 +605,7 @@
605
605
  .entries=${l}
606
606
  @sf-menu-context-select=${e=>{const t=r.get(e.detail?.id);t&&i(...t)}}
607
607
  ></sf-menu-context>
608
- `}renderCreateContextMenu(e){const{x:t,y:n}=e,s=this.state.createItems,i=s.map(e=>({id:String(e.id),text:e.name}));return p.html`
608
+ `}renderCreateContextMenu(e){const{x:t,y:n}=e,s=this.state.createItems,i=s.map(e=>({id:String(e.id),text:e.name}));return f.html`
609
609
  <sf-menu-context
610
610
  size=${"1/2"===this.size?"1/2":"1"}
611
611
  :key=${t+n}
@@ -620,7 +620,7 @@
620
620
  .entries=${i}
621
621
  @sf-menu-context-select=${e=>{const t=s.find(t=>String(t.id)===e.detail?.id);this.closeContextMenu(),t&&this.requestCreateIntent(t.id)}}
622
622
  ></sf-menu-context>
623
- `}getSort(){return{...this.state.sort}}setSort(e=null,t=null){if(this.isActionParameters?.(e,["key","direction"])&&({key:e=null,direction:t=null}=e),null===e||null===t)return this.set({sort:{key:null,direction:null}}),{outcome:"applied"};if("string"!=typeof e||!e||!["asc","desc"].includes(t))throw new TypeError("Sort requires a column key and direction asc or desc");return this.set({sort:{key:e,direction:t}}),{outcome:"applied"}}toggleSort(e){const t=this.state.sort||{},n=t.key!==e?"asc":"asc"===t.direction?"desc":"desc"===t.direction?null:"asc";return this.setSort(n?e:null,n),this.emitTableEvent("sort-change",Object.freeze({key:e,direction:n}))}suppressNextHeaderClick(){this._suppressHeaderClick=!0,setTimeout(()=>{this._suppressHeaderClick=!1},0)}handleHeaderSortClick(e,t={}){if(!0!==t.sortable||t.system||this._suppressHeaderClick)return;const n=e.composedPath?.()[0]||e.target;n instanceof Element&&n.closest(".sf-table-column-resizer")||this.toggleSort(t.key)}syncSelectionPort(){if(!this._isMounted)return this;const e=this.getSelectedRecordIds(),t=JSON.stringify(e.map(e=>[typeof e,e]));return t===this._selectionPortKey||(this._selectionPortKey=t,this.emitTableEvent("select",Object.freeze({ids:Object.freeze([...e])}))),this}applyRowSelection(e,t,{range:n=!1}={}){const s=this.getTableData().rows,i=(e,t)=>String(e?.id??"")===String(t??""),r=s.findIndex(t=>i(t,e));if(r<0)return this;const a=n&&null!=this._selectionAnchorId?s.findIndex(e=>i(e,this._selectionAnchorId)):-1,o=a<0?r:Math.min(a,r),l=a<0?r:Math.max(a,r);return this.set({settingsChecked:!1}),this.updateRows((e,n)=>n<o||n>l?e:{...e,selected:t,checked:t,select:this.getDefaultRowCell(this.TABLE_SELECT_COLUMN,{...e,selected:t,checked:t})},n&&a>=0?"select-range":"select-row"),this._selectionAnchorId=e,this.syncSelectAllState()}syncSelectAllState(){const e=this.getSelectedRecordIds().length,t=this.getTableData().rows.length;return this.set({settingsChecked:t>0&&e===t,selectIndeterminate:e>0&&e<t})}handleRowPointerDown(e){return this._selectRangeModifier=!0===e?.shiftKey,(!0===e?.shiftKey||e?.detail>1)&&e.preventDefault?.(),this}isRowControlTarget(e){return e instanceof Element&&Boolean(e.closest('td[data-key="select"], td[data-key="settings"], a[href], button, input, select, textarea, [role="button"], [role="link"], sf-checkbox, sf-dropdown, sf-button, sf-button-icon'))}handleRowClick(e,t,n=-1){return this.focusRow(this.getRowKey(t,n)),this.openReferenceFromCell(e,t),this}openReferenceFromCell(e,t){if(e.defaultPrevented||e.button>0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;const n=e.target?.closest?.("a[href]"),s=n?.closest?.("td[data-key]");if(!n||!s||!this.contains(s))return;const i=s.dataset.key,r=t?.[i],a=n.getAttribute("href");if(!a||a.startsWith("#")||"_blank"===n.target||n.hasAttribute("download"))return;this.emitTableEvent("reference-open",{recordId:t?.id??null,field:i,value:r??null,href:a},{cancelable:!0})||e.preventDefault()}getRowKey(e,t=-1){const n=e?.id??e?.value;return null!=n&&""!==String(n)?String(n):t>=0?`index:${t}`:""}actionsShownFor(e){if("always"===this.getAttribute("row-actions-visible"))return!0;const t=String(e?.id??e?.value??"");return!t||(t===this._pointerRowKey||t===this._focusRowKey||String(this._currentRowId??"")===t)}setActionsRow(e,t){const n="focus"===e?"_focusRowKey":"_pointerRowKey",s=t?String(t):null;this[n]!==s&&(this[n]=s,this._layoutUnchanged=!0,this.requestComponentUpdate("row-actions"))}bindRowActionsEvents(e){if(!e||this._rowActionsTable===e)return;this._rowActionsAbort?.abort(),this._rowActionsAbort=new AbortController,this._rowActionsTable=e;const{signal:t}=this._rowActionsAbort,n=e=>e?.closest?.("tbody tr[data-row-id]")?.dataset.rowId??null;e.addEventListener("pointerover",e=>this.setActionsRow("pointer",n(e.target)),{signal:t}),e.addEventListener("dragstart",e=>{const t=n(e.target);if(!t||!this.hasAttribute("drag-rows")||!e.dataTransfer)return;const s=this.getSelectedRecordIds?.()??[],i=s.map(String).includes(t)?s.map(String):[t],r=this.getAttribute("preferences-key")||this.getAttribute("table-settings-key")||this.id||null;e.dataTransfer.setData("application/x-sf-records+json",JSON.stringify({ids:i,source:r})),e.dataTransfer.setData("text/plain",i.join(", ")),e.dataTransfer.effectAllowed="copyMove",this.emitTableEvent("rows-drag",Object.freeze({ids:i,source:r}))},{signal:t});const s=()=>"true"===this.getAttribute("row-reorder"),i=(t,n)=>{for(const t of e.querySelectorAll("tbody tr[data-sf-drop-before], tbody tr[data-sf-drop-after]"))t.removeAttribute("data-sf-drop-before"),t.removeAttribute("data-sf-drop-after");t&&t.setAttribute(n?"data-sf-drop-after":"data-sf-drop-before","")},r=e=>{const t=e.target?.closest?.("tbody tr[data-row-id]");if(!t)return null;const n=t.getBoundingClientRect();return{row:t,after:e.clientY>n.top+n.height/2}};e.addEventListener("dragstart",e=>{const t=n(e.target);t&&s()&&e.dataTransfer&&(this._reorderDrag=[t],e.dataTransfer.setData("application/x-sf-row-order",t),e.dataTransfer.effectAllowed="move")},{signal:t}),e.addEventListener("dragover",e=>{if(!this._reorderDrag||!s())return;const t=r(e);t&&(e.preventDefault(),e.dataTransfer.dropEffect="move",i(t.row,t.after))},{signal:t}),e.addEventListener("drop",t=>{if(!this._reorderDrag||!s())return;const n=r(t);i(null);const a=this._reorderDrag;if(this._reorderDrag=null,!n)return;t.preventDefault();const o=[...e.querySelectorAll("tbody tr[data-row-id]")].map(e=>e.dataset.rowId),l=o.indexOf(n.row.dataset.rowId)+(n.after?1:0),c=o.slice(l).filter(e=>!a.includes(e))[0]??null,u=o.filter(e=>!a.includes(e)),d=null===c?u.length:u.indexOf(c),h=[...u.slice(0,d),...a,...u.slice(d)];h.join("\0")!==o.join("\0")&&this.emitTableEvent("move",Object.freeze({ids:[...a],before:c,order:h}))},{signal:t}),e.addEventListener("dragend",()=>{this._reorderDrag=null,i(null)},{signal:t}),e.addEventListener("pointerleave",()=>this.setActionsRow("pointer",null),{signal:t}),e.addEventListener("focusin",e=>this.setActionsRow("focus",n(e.target)),{signal:t}),e.addEventListener("focusout",t=>{e.contains(t.relatedTarget)||this.setActionsRow("focus",null)},{signal:t})}isCurrentRow(e,t=-1){const n=this.getRowKey(e,t);return""!==n&&String(this._currentRowId??"")===n}windowSlice(e=[]){const t=e.length;if(t<j||this.isList)return this._windowed=!1,this._windowCount=t,null;this._windowed=!0,this._windowCount=t;const n=this._rowHeight||D,s=this.clampWindow(this._windowRange??{first:0,last:B-1},t);return this._windowRange=s,{first:s.first,last:s.last,before:s.first*n,after:Math.max(0,t-1-s.last)*n}}clampWindow({first:e=0,last:t=0}={},n=0){const s=Math.max(0,n-1),i=Math.min(Math.max(0,Math.floor(e)),s);return{first:i,last:Math.min(Math.max(i,Math.floor(t)),s)}}windowRowCount(){return this._windowed?String((this._windowCount??0)+1):null}seenRows(e){const t=this.refs.table?.value?.tBodies?.[0];if(!t||!e)return null;const n=t.getBoundingClientRect();let s=0,i=globalThis.innerHeight||document.documentElement.clientHeight||0;const r=this.refs.scroll?.value;if(r){const e=r.getBoundingClientRect();s=Math.max(s,e.top),i=Math.min(i,e.bottom)}const a=this._rowHeight||D,o=e-1,l=Math.min(o,Math.max(0,Math.floor((s-n.top)/a)));return{first:l,last:Math.min(o,Math.max(l,Math.ceil((i-n.top)/a)))}}syncWindow(){if(!this._windowed)return!1;const e=this.refs.table?.value,t=e?.querySelectorAll?.("tbody tr[data-row-id]")??[];let n=!1;if(t.length){const e=t[0].getBoundingClientRect(),s=(t[t.length-1].getBoundingClientRect().bottom-e.top)/t.length;s>0&&Math.abs(s-(this._rowHeight||0))>.5&&(this._rowHeight=s,n=!0)}const s=this._windowCount??0,i=this.seenRows(s);if(!i)return!1;const r=this._windowRange??{first:0,last:B-1},a=r.first>0?r.first+I/2:0,o=r.last<s-1?r.last-I/2:s-1;if((i.first<a||i.last>o)&&(this._windowRange=this.clampWindow({first:i.first-I,last:i.last+I},s),n=!0),!n)return!1;this._windowOnly=!0,this.requestComponentUpdate("window");const{first:l,last:c}=this._windowRange;return this._reportedWindow!==`${l}-${c}`&&(this._reportedWindow=`${l}-${c}`,this.emitTableEvent("window",{first:l,last:c})),!0}bindWindowScroll(){if(this._windowScrollAbort)return;this._windowScrollAbort=new AbortController;const e=this._windowScrollAbort.signal,t=()=>{this._windowed&&!this._windowFrame&&(this._windowFrame=requestAnimationFrame(()=>{this._windowFrame=0,this.isConnected&&this.syncWindow()}))};document.addEventListener("scroll",t,{capture:!0,passive:!0,signal:e}),globalThis.addEventListener?.("resize",t,{passive:!0,signal:e})}unbindWindowScroll(){this._windowScrollAbort?.abort(),this._windowScrollAbort=null,this._windowFrame&&cancelAnimationFrame(this._windowFrame),this._windowFrame=0}rowMarkupCell(e,t){const n=t?.key;if(!n||!e)return null;const i="1/2"===this.size?"1/2":"1";if("select"===n){const t=e.select?.component;return"checkbox"!==t?.type||"function"!=typeof t.props?.["@change"]?null:{kind:"box",size:i,checked:!0===t.props.checked,value:String(t.props.value??e.id??""),label:t.props.ariaLabel??"",change:t.props["@change"]}}if("settings"===n){const t=e.settings?.component;return"sf-button-icon"!==(0,s.canonicalTag)(`sf-${String(t?.type??"").replace(/^sf-/u,"")}`)||"menu"!==t.props?.icon||"function"!=typeof t.props?.["@click"]?null:{kind:"menu",size:i,label:t.props.ariaLabel??this.text("menuLabel"),click:t.props["@click"]}}if(t.system||t.component||"link"===t.renderer||"title"===t.role)return null;if(this.isTree()||e.path||this.cellEditable(e,t))return null;const r=e[n];if(null==r)return{kind:"empty"};if("string"!=typeof r&&"number"!=typeof r&&"boolean"!=typeof r)return null;if(V.has(t.propertyType??t.property_type??t.type)&&"boolean"!=typeof r){const e=String(r);return{kind:"text",className:"sf-table-cell-clip",text:e,title:e}}const a=this.getTypedCellValue(t,r);if(null!=a)return"string"!=typeof a&&"number"!=typeof a?null:{kind:"text",className:"sf-table-cell-bare",text:String(a)};if("boolean"==typeof r)return null;const o=String(r);return{kind:"text",className:"sf-table-cell-text",text:o,title:o.length>80?o:null}}keyboardRows(){return(this.getTableData().rows||[]).filter(e=>e&&!e.__tree?.more)}focusRow(e,{reveal:t=!1}={}){if(e&&"object"==typeof e)return this.focusRowAction(e);if(null==e||""===e)return this;this._currentRowId=String(e);const n=this.refs.table?.value;if(!n)return this;const s=`tbody tr[data-row-id="${String(e).replace(/"/gu,'\\"')}"]`;for(const e of n.querySelectorAll("tbody tr[data-current]"))e.removeAttribute("data-current");const i=n.querySelector(s);if(!i&&this._windowed){const t=this.getTableData().rows||[],n=t.findIndex((t,n)=>this.getRowKey(t,n)===String(e));return n>=0&&(this._windowRange=this.clampWindow({first:n-I,last:n+I},t.length),this._pendingFocusRow=String(e),this._windowOnly=!0,this.requestComponentUpdate("window")),this}return i?.setAttribute("data-current",""),t&&i?.scrollIntoView?.({block:"nearest",behavior:"instant"}),i?.focus?.({preventScroll:!0}),this}canOpenRow(e){return Array.isArray(e?.actions)&&e.actions.includes("view")}handleRowOpen(e,t){if(this.isRowControlTarget(e?.target)||!this.canOpenRow(t))return this;const n=t?.id;return null==n?this:this.requestActionIntent("view",[n])}isTree(){const e=this.getTableData?.().rows??[];return this._treeMemo?.rows!==e&&(this._treeMemo={rows:e,tree:e.some(e=>e?.__tree)}),this._treeMemo.tree}treeColumnKey(e=this.getColumns()){if(!this.isTree())return null;const t=e.filter(e=>e?.key&&!["select","settings","actions"].includes(e.key)&&!e.system);return(t.find(e=>"title"===e.role)??t[0])?.key??null}toggleTreeRow(e){return this.isActionParameters?.(e,["row"])&&!e.__tree&&(e=e.row),e?.__tree?.hasChildren?(this.emitTableEvent("expand",Object.freeze({id:e.id,expanded:!0===e.__tree.expanded})),{outcome:"applied"}):{outcome:"refused",reason:"no-children"}}requestTreeMore(e){return this.isActionParameters?.(e,["row"])&&!e.__tree&&(e=e.row),e?.__tree?.more?(this.emitTableEvent("load-more",Object.freeze({direction:"after",parent:e.__tree.parent,cursor:e.__tree.cursor??null})),{outcome:"applied"}):{outcome:"refused",reason:"no-more"}}handleRowKeydown(e,t){if(e?.target!==e?.currentTarget)return this;if(t?.__tree?.hasChildren&&("ArrowRight"===e.key||"ArrowLeft"===e.key)){const n=!0===t.__tree.expanded;if("ArrowRight"===e.key!==n)return e.preventDefault?.(),this.toggleTreeRow(t)}if("Enter"===e.key)return this.handleRowOpen({target:e.currentTarget},t);if(["ArrowDown","ArrowUp","Home","End"].includes(e.key)&&!e.altKey&&!e.metaKey&&!e.ctrlKey){const n=this.keyboardRows(),s=n.findIndex(e=>String(e?.id??e?.value)===String(t?.id??t?.value)),i={ArrowDown:s+1,ArrowUp:s-1,Home:0,End:n.length-1}[e.key];return s>=0&&i>=0&&i<n.length&&i!==s&&(e.preventDefault?.(),this.focusRow(this.getRowKey(n[i],i),{reveal:!0})),this}if(" "===e.key||"Spacebar"===e.key){e.preventDefault?.();const n=!0!==t?.select?.component?.props?.checked;return this.applyRowSelection(t?.id,n,{range:!0===e.shiftKey})}return this}clearSelection(){return this._selectionAnchorId=null,this.set({settingsChecked:!1,selectIndeterminate:!1}),this.getSelectedRecordIds().length?(this.updateRows(e=>({...e,selected:!1,checked:!1,select:this.getDefaultRowCell(this.TABLE_SELECT_COLUMN,{...e,selected:!1,checked:!1})}),"select-clear"),{outcome:"applied"}):{outcome:"applied"}}sfPortInput(e,t,n={}){if(!Object.hasOwn(O.inputs,e))throw new TypeError(`sf-view-table has no input port ${String(e)}`);const s=L(t),i=Number.isSafeInteger(n?.sequence)&&n.sequence>this._querySequence?n.sequence:this._querySequence+1;this._routeContext=Object.freeze({record_ids:s}),this._querySequence=i,this.clearSelection(),this.requestContextQuery(i)}requestContextQuery(e){return this._pendingQuerySequence=e,this._abandonedQuery=!1,this.setDataState("loading"),this.emitTableEvent("query",Object.freeze({reason:"context",context:this._routeContext,sequence:e}))}onConnected(){if(super.onConnected(),!this._lateLayoutAbort){this._lateLayoutAbort=new AbortController;const e=this._lateLayoutAbort.signal,t=()=>{this._lateLayoutFrame||(this._lateLayoutFrame=requestAnimationFrame(()=>{this._lateLayoutFrame=0,this.isConnected&&this.measureContentWidths()&&this.widthsChanged()}))};document.fonts?.addEventListener?.("loadingdone",t,{signal:e}),document.fonts?.ready?.then?.(()=>{e.aborted||t()}),document.addEventListener("load",e=>{"link"===e.target?.localName&&/stylesheet/u.test(e.target.rel)&&t()},{capture:!0,signal:e})}"undefined"==typeof ResizeObserver||this._responsiveObserver||(this._responsiveObserver=new ResizeObserver(([e])=>{const t=Math.floor(e.contentRect.width);t>0&&t!==this._responsiveWidth&&(this._responsiveWidth=t,this.requestComponentUpdate("responsive-columns")),this.measurePinnedColumns()}),this._observeResponsiveBox()),this._abandonedQuery&&this._routeContext&&(this._querySequence+=1,this.requestContextQuery(this._querySequence))}applyQueryResult(e,t){return this.isActionParameters?.(e,["sequence","rows"])&&({sequence:e,rows:t}=e),Number.isSafeInteger(e)&&e===this._pendingQuerySequence&&Array.isArray(t)?(this._pendingQuerySequence=null,this.setRows(t),this.setDataState("auto"),{outcome:"applied"}):{outcome:"refused",reason:"stale"}}getQueryContext(){return this._routeContext}getItemRef(e){return this.refs.items.has(e)||this.refs.items.set(e,this.createRef()),this.refs.items.get(e)}setIndeterminate(){return this.state.data.rows.filter(e=>e.select.component.props.checked).length}getTableData(){const e=this.state?.data;return e&&"object"==typeof e?e:{columns:[],rows:[]}}isContextMenuEvent(e){const t=e?.target;if(!(t instanceof Node))return!1;const n=this._portalContainer;if(n instanceof Node&&(n===t||n.contains(t)))return!0;const s=this.refs?.contextMenu?.value;return s instanceof Node&&(!(s!==t&&!s.contains(t))||(e.composedPath?.().includes(s)||!1))}contextEvent(e){this.isContextMenuEvent(e)||(this.tempSettings=null,this.closeContextMenu(!1))}splitItemsByColumns(e=[],t=1){const n=Array.isArray(e)?e:[],s=Math.max(1,Number(t)||1),i=Math.ceil(n.length/s);return i?Array.from({length:s},(e,t)=>n.slice(t*i,(t+1)*i)).filter(e=>e.length):[]}getPendingFilterState(e=this.state?.filter||{}){const t=this.tempSettings?.filter||{},n=Object.prototype.hasOwnProperty.call(t,"selectedTemplateKey");return{...e,...t,selectedTemplateKey:n?t.selectedTemplateKey:e.selectedTemplateKey,templates:t.templates||e.templates||[]}}getSortedFilterTemplates(e=this.state?.filter||{}){return this.getFilterTemplates(e).map((e,t)=>({...e,sourceIndex:t,order:"number"==typeof e.order?e.order:t})).sort((e,t)=>Boolean(e.pinned)!==Boolean(t.pinned)?e.pinned?-1:1:e.order!==t.order?e.order-t.order:e.sourceIndex-t.sourceIndex)}changeTempFilterTemplateSettings(e,t={}){if(!e)return;const n=this.getPendingFilterState(),s=this.getFilterTemplates(n).map(n=>{for(const[s,i]of Object.entries(t))n[s]=e===n.key?i:!i;return n});this.tempSettings={...this.tempSettings||{},filter:{...this.tempSettings?.filter||{},selectedTemplateKey:n.selectedTemplateKey,templates:s}},this.requestComponentUpdate("temp-filter-template")}patchTempFilterTemplateSettings(e,t={}){if(!e)return;const n=this.getPendingFilterState(),s=this.getFilterTemplates(n).map(n=>n.key===e?{...n,..."function"==typeof t?t(n):t}:n);this.tempSettings={...this.tempSettings||{},filter:{...this.tempSettings?.filter||{},selectedTemplateKey:n.selectedTemplateKey,templates:s}},this.requestComponentUpdate("temp-filter-template")}selectTempFilterTemplate(e){if(!e)return;const t=this.getPendingFilterState(),n=this.getFilterTemplates(t).map(t=>({...t,selected:t.key===e}));this.tempSettings={...this.tempSettings||{},filter:{...this.tempSettings?.filter||{},selectedTemplateKey:e,templates:n}},this.requestComponentUpdate("temp-filter-template")}normalizeFilterTemplate(e={},t=0){const n=e.key||`filter_template_${t+1}`,s=e.data&&"object"==typeof e.data?e.data:{};return{...e,key:n,label:e.label||s.template_name||n,data:{...s,values:{...s.values||{}},tags:{...s.tags||{}}}}}getFilterTemplates(e=this.state?.filter||{}){const t=(e.templates||[]).map((e,t)=>this.normalizeFilterTemplate(e,t));return t.length?t:[this.normalizeFilterTemplate({key:e.selectedTemplateKey||"default",label:this.text("defaultTemplateText"),selected:!0,order:0,data:{}})]}getFilterTemplateByKey(e,t=this.state?.filter||{}){return e&&t&&this.getFilterTemplates(t).find(t=>t.key===e)||null}getSelectedFilterTemplate(e=this.state?.filter||{}){const t=this.getFilterTemplates(e);if(Object.prototype.hasOwnProperty.call(e,"selectedTemplateKey")&&""===e.selectedTemplateKey)return null;const n=e.selectedTemplateKey||t.find(e=>e.selected)?.key||t[0]?.key||"";return this.getFilterTemplateByKey(n,{...e,templates:t})||t[0]||null}getCurrentFilterValues(e=this.state?.filter||{}){const t=this.getSelectedFilterTemplate(e);return{...t?.data?.values||{}}}getCurrentFilterTags(e=this.state?.filter||{}){const t=this.getSelectedFilterTemplate(e);return{...t?.data?.tags||{}}}normalizeFilterDataForCompare(e){return Array.isArray(e)?e.map(e=>this.normalizeFilterDataForCompare(e)):e&&"object"==typeof e?Object.keys(e).sort().reduce((t,n)=>({...t,[n]:this.normalizeFilterDataForCompare(e[n])}),{}):e}isSameFilterData(e,t){return JSON.stringify(this.normalizeFilterDataForCompare(e||{}))===JSON.stringify(this.normalizeFilterDataForCompare(t||{}))}getMergedFilterDraftData(e=this.state?.filter||{},t=this.tempSettings?.filter||{}){const n=this.getPendingFilterState({...e,selectedTemplateKey:Object.prototype.hasOwnProperty.call(t,"selectedTemplateKey")?t.selectedTemplateKey:e.selectedTemplateKey,templates:t.templates||e.templates||[]}),s=this.getCurrentFilterTags(n),i=this.getCurrentFilterValues(n),r=t.replaceTags?{...t.tags||{}}:{...s,...t.tags||{}},a=t.replaceValues?{...t.values||{}}:{...i,...t.values||{}};return Object.entries(t.values||{}).forEach(([e,t])=>{this.isEmptyFilterEntry(t)&&(delete a[e],delete r[e])}),{filter:n,tags:r,values:a}}hasPendingFilterDataChanges(e=this.state?.filter||{}){const t=this.tempSettings?.filter;if(!t||!Object.prototype.hasOwnProperty.call(t,"tags")&&!Object.prototype.hasOwnProperty.call(t,"values")&&!t.replaceTags&&!t.replaceValues)return!1;const n=this.getMergedFilterDraftData(e,t);return!this.isSameFilterData(this.getCurrentFilterTags(n.filter),n.tags)||!this.isSameFilterData(this.getCurrentFilterValues(n.filter),n.values)}countPendingFilterConditionChanges(e=this.state?.filter||{}){const t=this.tempSettings?.filter;if(!t)return 0;const n=this.getMergedFilterDraftData(e,t),s={tags:this.getCurrentFilterTags(n.filter),values:this.getCurrentFilterValues(n.filter)},i=(e,t)=>this.isSameFilterData(e,t),r=new Set([...Object.keys(s.tags||{}),...Object.keys(n.tags||{}),...Object.keys(s.values||{}),...Object.keys(n.values||{})]);let a=0;for(const e of r){Boolean((s.tags||{})[e]?.active)===Boolean((n.tags||{})[e]?.active)?i((s.values||{})[e],(n.values||{})[e])||(a+=1):a+=1}return a}hasUnsavedFilterDataChanges(){return Boolean(this.state?.filterDataDirty&&this.getSelectedFilterTemplate(this.state?.filter||{}))}saveCurrentFilterTemplateData(){const e=this.getSelectedFilterTemplate(this.state?.filter||{});return e?this.set({filterDataDirty:!1},()=>{this.dispatchFilterTemplateSave(e.key,this.state.filter,this.getFilterTemplateByKey(e.key))}):this}mergeObjectDeep(e={},t={}){return Object.entries(t||{}).reduce((e,[t,n])=>{const s=e[t],i=n&&"object"==typeof n&&!Array.isArray(n)&&s&&"object"==typeof s&&!Array.isArray(s);return{...e,[t]:i?this.mergeObjectDeep(s,n):n}},{...e||{}})}patchFilterTemplateByKey(e,t=this.state.filter,n={}){if(!e||!t)return{filter:t,template:null};let s=null;return{filter:{...t,templates:this.getFilterTemplates(t).map(t=>{if(e!==t.key)return t;const i="function"==typeof n?n(t):n;return s=this.mergeObjectDeep(t,i),s})},template:s}}createFilterTemplatePatchState(e,t={}){const n={filter:e};return Object.prototype.hasOwnProperty.call(t,"saveInputValue")&&(n.saveInputValue=t.saveInputValue),n}getActiveFilterFieldKeys(e=this.state?.filter||{}){const t=this.getCurrentFilterTags(e),n=this.getFilterFields().map(e=>e?.key),s=Object.keys(t).filter(e=>t[e]?.active);return[...n.filter(e=>s.includes(e)),...s.filter(e=>!n.includes(e))]}setActiveFilterFields(e=[],t=this.state?.filter||{}){if(!Array.isArray(e)||e.some(e=>"string"!=typeof e||!e.trim()))throw new TypeError("Filter field keys must be nonempty strings");const n=this.getSelectedFilterTemplate(t);if(!n?.key)return this;const s=this.getFilterFields(),i=this.getCurrentFilterTags(t),r={};for(const e of Object.keys(i))r[e]={...i[e],active:!1};for(const t of e){const e=s.find(e=>e?.key===t);r[t]={...i[t]||{},active:!0,label:e?.label??i[t]?.label??t,control:e?.filter?.control||e?.type||e?.dataType||i[t]?.control||"text"}}const a=this.patchFilterTemplateByKey(n.key,t,e=>({...e,data:{...e.data||{},tags:r}}));return this.set({filter:a.filter})}withFilterFieldSettings(e,t=this.state?.filter||{}){if(Array.isArray(e))return e.map(e=>this.withFilterFieldSettings(e,t));if(!e||"object"!=typeof e)return e;const n=Array.isArray(e.data?.tags)?[]:Object.keys(e.data?.tags||{}).filter(t=>e.data.tags[t]?.active);return{...e,settings:{...e.settings||{},filter_fields:n.length?n:this.getActiveFilterFieldKeys(t)}}}dispatchFilterTemplateSave(e,t,n=null){const s=this.withFilterFieldSettings(n||this.getFilterTemplateByKey(e,t),t);return this.emitTableEvent("template-save",s),this}getChangedFilterTemplates(e={},t={},n=[]){const s=new Map(this.getFilterTemplates(e).map(e=>[e.key,e]));return this.getFilterTemplates(t).filter(e=>{const t=s.get(e.key);return!t||n.some(n=>!Object.is(t[n],e[n]))})}dispatchFilterTemplatesSave(e=[]){const t=e.filter(e=>e?.key);if(!t.length)return this;const n=this.withFilterFieldSettings(1===t.length?t[0]:t);return this.emitTableEvent("template-save",n),this}saveFilterTemplatePatch(e,t={},n={},s=this.state.filter){if(!e||!s)return this;const i=this.patchFilterTemplateByKey(e,s,t),r={...i.filter,...n.filterPatch||{}};return this.set(()=>this.createFilterTemplatePatchState(r,n),()=>{!1!==n.dispatch&&this.dispatchFilterTemplateSave(e,r,i.template)})}setDefaultFilterTemplate(e){return e?this.set(t=>{const n=t.filter||{};return{filter:{...n,templates:this.getFilterTemplates(n).map(t=>({...t,default:t.key===e}))}}}):this}patchFilterTemplateData(e={},t={}){const n={...e};delete n.tags,delete n.values;const s=this.getFilterTemplates(n),i=this.getSelectedFilterTemplate({...n,templates:s});if(!i)return{...n,templates:s};const r=Object.prototype.hasOwnProperty.call(t,"values")?t.values||{}:i.data?.values||{},a=Object.prototype.hasOwnProperty.call(t,"tags")?t.tags||{}:i.data?.tags||{},o=s.map(e=>e.key===i.key?{...e,data:{...e.data||{},...t.data||{},values:r,tags:a}}:e);return{...n,selectedTemplateKey:i.key,templates:o}}getFilterPayload(e=this.state?.filter||{}){const t=this.getSelectedFilterTemplate(e);return{...t?.data||{},templateKey:t?.key||"",templateLabel:t?.label||"",values:this.getCurrentFilterValues(e),tags:this.getCurrentFilterTags(e)}}selectFilterTemplate(e){return e&&this.state?.filter?.selectedTemplateKey!==e?(this.set(t=>{const n={...t.filter||{},selectedTemplateKey:e,templates:(t.filter?.templates||[]).map(t=>({...t,selected:t.key===e}))},s=this.getFilterTemplateByKey(e,n)||n.templates[0]||null;return{filter:n,saveInputValue:s?.label||""}}),this):this}static reorderedKeys(e,t,n){const s=[...e.querySelectorAll("[data-sf-sortable-item]")].filter(t=>t.closest("sf-sortable")===e).map(e=>e.getAttribute("data-sf-sortable-item")).filter(e=>e!==t);return s.splice(Math.max(0,Math.min(n,s.length)),0,t),s}onFilterTemplateIntent(e){const t=e.target,{item:n,index:s}=e.detail??{};if(!(t instanceof Element&&n))return;const i=H.reorderedKeys(t,n,s),r="pinned"===t.getAttribute("data-group")?"pinned":"normal",a={pinned:new Map,normal:new Map};i.forEach((e,t)=>a[r].set(e,t)),this.syncFilterTemplateOrder(a)}onColumnSettingsIntent(e){const t=e.target,{item:n,index:s}=e.detail??{};if(!(t instanceof Element&&n))return;const i="pinned"===t.getAttribute("data-group"),r=H.reorderedKeys(t,n,s),a=r.indexOf(n),o=this.getColumnItems().filter(e=>e?.key&&!e.system),l=o.filter(e=>this.isColumnPinned(e)===i).map(e=>e.key).filter(e=>e!==n),c=r[a+1],u=r[a-1];let d=void 0!==c?l.indexOf(c):-1;-1===d&&(d=void 0!==u?l.indexOf(u)+1:l.length),l.splice(-1===d?l.length:d,0,n);const h=o.filter(e=>this.isColumnPinned(e)!==i).map(e=>e.key);(i?[...l,...h]:[...h,...l]).forEach((e,t)=>this.patchTempColumnSettings(e,{order:10*(t+1)})),this.requestComponentUpdate("column-order"),this.commitColumnSettings("column-order")}syncFilterTemplateOrder(e){const t=this.getPendingFilterState(),n=this.getFilterTemplates(t).map((t,n)=>{const s=t.pinned?"pinned":"normal",i=e[s].get(t.key);return"number"!=typeof i?t:{...t,order:i,sourceIndex:n}});this.tempSettings={...this.tempSettings||{},filter:{...this.tempSettings?.filter||{},selectedTemplateKey:t.selectedTemplateKey,templates:n.sort((e,t)=>Boolean(e.pinned)!==Boolean(t.pinned)?e.pinned?-1:1:e.order!==t.order?e.order-t.order:e.sourceIndex-t.sourceIndex)}},this.requestComponentUpdate("temp-filter-template-order")}get columnsAreCramped(){if(this._layoutReads?.has("cramped"))return this._layoutReads.get("cramped");const e=this.readColumnsAreCramped();return this._layoutReads?.set("cramped",e),e}readColumnsAreCramped(){const e=this.refs.scroll?.value?.clientWidth||this._responsiveWidth;if(!e)return!1;const t=(this.getColumns?.()??[]).filter(e=>this.columnTakesFloor(e));if(!t.length)return!1;const n=this.querySelector(".sf-table")??this,s=globalThis.getComputedStyle?.(n)?.getPropertyValue("--sf-table--column-min-inline-size")?.trim();if(!s)return!1;const i=Number.parseFloat(globalThis.getComputedStyle?.(document.documentElement)?.fontSize)||16,r=s.endsWith("rem")?Number.parseFloat(s)*i:Number.parseFloat(s);if(!Number.isFinite(r)||r<=0)return!1;return e-[...this.querySelectorAll("thead th")].filter(e=>!t.some(t=>t.key===e.dataset.key)).reduce((e,t)=>e+("actions"===t.dataset.key?Math.min(t.getBoundingClientRect().width,r):t.getBoundingClientRect().width),0)<t.length*r}get isList(){const e=this.getProp?.("layout")??"table";if("list"===e)return!0;if("table"===e)return!1;const t=Number(this.getProp?.("listBelow"))||600;return this._responsiveWidth>0&&this._responsiveWidth<t}get actionsColumnWidth(){const e=(this.ACTIONS_SETTINGS_ROW??[]).filter(e=>!1!==e?.inline).length;return e?`calc(${e} * (var(--sf-text-height-1) + var(--sf-ui-1--space-y-tightness-default) * 2) + ${e-1} * var(--sf-space-1\\/3) + var(--sf-b6))`:""}measureContentWidths(){const e=this.refs.table?.value;if(!(e instanceof HTMLTableElement&&e.isConnected))return!1;if(this._columnResizeState||this.columnDragActive)return!1;if(e.querySelector("tbody[data-state]")||e.querySelector("tbody[data-busy]")||!e.querySelector("tbody tr td"))return!1;const t=new Map;let n=0;const s=this.columnWidthCap(),i=e.parentElement?.clientWidth??0,r=new Map;for(const t of e.querySelectorAll("thead th[data-key]"))R.has(t.dataset.key)&&r.set(t,Math.ceil(t.getBoundingClientRect().width));if(e.classList.add("sf-table-measuring"),"auto"!==getComputedStyle(e).tableLayout)return e.classList.remove("sf-table-measuring"),!1;try{n=e.getBoundingClientRect().width;for(const n of e.querySelectorAll("thead th[data-key]")){const e=n.dataset.key;R.has(e)||t.set(e,N(n.getBoundingClientRect().width))}}finally{e.classList.remove("sf-table-measuring")}let a=0;for(const n of e.querySelectorAll("thead th[data-key]")){const e=n.dataset.key;a+=R.has(e)?r.get(n)??0:Math.min(t.get(e)??0,s)}const o=a!==(this._contentInlineSize??0);this._contentInlineSize=a;const l=i>0&&n>0&&n<i,c=l!==Boolean(this._contentSurplus);this._contentSurplus=l,this.remeasureWhenDrawn(e);const u=this._contentWidths??new Map,d=t.size!==u.size||[...t].some(([e,t])=>Math.abs((u.get(e)??0)-t)>2);return d&&(this._contentWidths=t),d||c||o}fitCellValues(){const e=new Set;for(const t of this.querySelectorAll("tbody .sf-table-cell-values > :not(.sf-table-cell-more)"))!t.localName.includes("-")||customElements.get(t.localName)&&K(t).getBoundingClientRect().width||e.add(t.localName);if(e.size&&(this._fitRetries??0)<3){this._fitRetries=(this._fitRetries??0)+1;const t=this._fitToken=(this._fitToken??0)+1;Promise.all([...e].map(e=>customElements.whenDefined(e))).then(()=>new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e)))).then(()=>{t===this._fitToken&&this.isConnected&&this.fitCellValues()})}else e.size||(this._fitRetries=0);const t=[];for(const e of this.querySelectorAll("tbody .sf-table-cell-values")){const n=e.querySelector(":scope > .sf-table-cell-more"),s=[...e.children].filter(e=>e!==n),i=s.map(e=>K(e));t.push({box:e,more:n,items:s,valueBoxes:i})}for(const{more:e,valueBoxes:n}of t){for(const e of n)e.classList.remove("sf-table-cell-folded");e&&(e.hidden=!0,e.removeAttribute("title"))}const n=t.filter(({box:e,more:t})=>t&&e.scrollWidth>e.clientWidth+1);for(const{box:e,more:t,items:s,valueBoxes:i}of n){t.hidden=!1,t.textContent=`+${s.length}`;const n=[];for(let r=s.length-1;r>0&&e.scrollWidth>e.clientWidth+1;r-=1)i[r].classList.add("sf-table-cell-folded"),n.unshift(s[r]),t.textContent=`+${n.length}`;n.length?t.title=n.map(e=>e.textContent.trim()).filter(Boolean).join(", "):t.hidden=!0}}measureWhenCellsDrawn(){const e=this.refs.table?.value;if(!(e instanceof HTMLTableElement)||this._columnResizeState||this.columnDragActive)return!1;if(e.querySelector("tbody[data-state]")||e.querySelector("tbody[data-busy]"))return!1;const t=[];for(const n of e.querySelectorAll("tbody td *"))if(n.localName.includes("-")){if(!customElements.get(n.localName)||"function"!=typeof n.whenRendered)return!1;if(n.hasAttribute("data-sf-style-pending"))return!1;!0!==n.isRendered&&t.push(n)}if(!t.length)return!1;const n=this._cellsDrawnToken=(this._cellsDrawnToken??0)+1,s=new Promise(e=>requestAnimationFrame(e));return Promise.race([Promise.all(t.map(e=>e.whenRendered())),s]).catch(()=>{}).then(()=>{n===this._cellsDrawnToken&&this.isConnected&&(this.measureContentWidths()&&this.applyColumnWidths(),this._contentRetries=0,this.fitCellValues(),this.measurePinnedColumns(),this.hasAttribute("data-sf-page-scroll")&&this.syncRail())}),!0}remeasureWhenDrawn(e){const t=new Set;for(const n of e.querySelectorAll("tbody td *"))n.localName.includes("-")&&(customElements.get(n.localName)&&n.childElementCount||t.add(n.localName));if(!t.size)return void(this._remeasureTries=0);if((this._remeasureTries??0)>=3)return;this._remeasureTries=(this._remeasureTries??0)+1;const n=this._remeasureToken=(this._remeasureToken??0)+1,s=[...e.querySelectorAll("tbody td *")].filter(e=>t.has(e.localName)&&"function"==typeof e.whenRendered);[...t].every(e=>customElements.get(e))&&s.length?Promise.all(s.map(e=>!0===e.isRendered?null:e.whenRendered())).then(()=>{n===this._remeasureToken&&this.isConnected&&this.measureContentWidths()&&this.widthsChanged()}):Promise.all([...t].map(e=>customElements.whenDefined(e))).then(()=>new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e)))).then(()=>{n===this._remeasureToken&&this.isConnected&&this.measureContentWidths()&&this.widthsChanged()})}widthsChanged(){this.applyColumnWidths(),this.fitCellValues(),this.measurePinnedColumns(),this.hasAttribute("data-sf-page-scroll")&&this.syncRail()}applyColumnWidths(){const e=this.refs.table?.value;if(!(e instanceof HTMLTableElement))return;const t=new Map((this.getColumns?.()??[]).map(e=>[String(e?.key),e])),n=[...e.querySelectorAll(":scope > colgroup > col[data-key]")],s=this.readingLayout(()=>n.map(e=>{const n=t.get(e.dataset.key);return n?(0,u.Y5)(this,n):null}));n.forEach((e,t)=>{const n=s[t];null!==n&&(e.getAttribute("style")??"")!==n&&(n?e.setAttribute("style",n):e.removeAttribute("style"))}),e.classList.toggle("sf-table-content-sized",this.hasContentWidths),e.classList.toggle("w-max",!this.hasContentWidths),this.hasContentWidths&&this._contentInlineSize?e.style.setProperty("--sf-table--content-inline-size",`${this._contentInlineSize}px`):e.style.removeProperty("--sf-table--content-inline-size")}contentWidth(e){const t=this._contentWidths?.get(e?.key);return t?e?.key===this.spareRoomColumnKey()?"":`${Math.min(t,this.columnWidthCap())}px`:""}spareRoomColumnKey(){const e=this.getColumns?.()??[];for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n?.key&&!R.has(n.key))return n.colWidth??n.width??n.size?null:n.key}return null}get hasContentWidths(){return Boolean(this._contentWidths?.size)}readingLayout(e){if(this._layoutReads)return e();this._layoutReads=new Map;try{return e()}finally{this._layoutReads=null}}columnWidthCap(){if(this._layoutReads?.has("cap"))return this._layoutReads.get("cap");const e=this.readColumnWidthCap();return this._layoutReads?.set("cap",e),e}readColumnWidthCap(){const e=getComputedStyle(this).getPropertyValue("--sf-table--column-max-inline-size").trim(),t=Number.parseFloat(getComputedStyle(document.documentElement).fontSize)||16,n=Number.parseFloat(e);return!Number.isFinite(n)||n<=0?320:e.endsWith("rem")?n*t:n}columnTakesFloor(e){return!(!e?.key||R.has(e.key))&&!(e.colWidth??e.width??e.size??e.min_width??e.minWidth)}getSystemColumns(){const e=[],t=this.getPropsContext();return t.selectable&&e.push(this.getSelectColumn()),t.settings&&e.push(this.TABLE_SETTINGS_COLUMN),t.actions&&t.rowActions&&this.state.actionActive&&e.push(this.TABLE_ACTIONS_COLUMN),e}setTemplates(e){const t=Object.values(e||{}).map((e,t)=>this.normalizeFilterTemplate(e,t));return this.set(e=>{const n=e.filter||{},s=new Map;this.getFilterTemplates(n).forEach(e=>{s.set(e.key,e)}),t.forEach(e=>{s.set(e.key,{...s.get(e.key)||{},...e})});const i=Array.from(s.values()),r=Object.prototype.hasOwnProperty.call(n,"selectedTemplateKey"),a=i.find(e=>!0===e.default),o=t.find(e=>e?.selected)?.key,l=a?.key||i[0]?.key||"",c=this._filterTemplatesLoaded?o??(r?n.selectedTemplateKey:l):o??l,u={...n,selectedTemplateKey:c,templates:i.map(e=>({...e,selected:e.key===c}))},d=""===c?null:this.getFilterTemplateByKey(c,{...u,templates:i})||i[0]||null;return this._filterTemplatesLoaded=!0,{filter:u,saveInputValue:d?.label||""}})}getInstanceId(){return this.id||this._instanceId}getColumnResizerId(e){return`${this.getInstanceId()}--column-resizer--${e}`}getTableSettingsKey(){return this.tableSettingsKey||this.getAttribute?.("table-settings-key")||this.id||this.getInstanceId()}normalizeTableSettings(e={},t=this.getTableSettingsKey()){const n=!e?.tableSettings||"object"!=typeof e.tableSettings||Array.isArray(e.tableSettings)||e.tableSettings.columnSettings?null:e.tableSettings,s=e?.item||n?.[t]||e?.tableSettings||e?.settings||e||{},i=s?.columnSettings||e?.columnSettings||{};return{...s,columnSettings:i&&"object"==typeof i&&!Array.isArray(i)?i:{}}}setTableSettings(e={},t="table-settings-load",n=this.getTableSettingsKey()){const s=this.normalizeTableSettings(e,n);return this.setColumnSettings(s.columnSettings,t,!1)}getContextMenuLabel(e={}){switch(e.menu||e.type){case"filter-favorites":return this.text("contextSaveTemplateLabel");case"filter-settings":return this.text("contextFilterSettingsLabel");case"filter-template-actions":return`${this.text("contextTemplateActionsLabel")}: ${e.template?.label||e.template?.key||""}`.trim();case"tag-settings":{const t=e.fieldKey||"",n=this.getFilterField(t),s=n?.label||this.getCurrentFilterTags()?.[t]?.label||t;return`${this.text("contextFieldFilterLabel")}: ${s||this.text("fieldWordText")}`}case"row-settings":return this.text("contextRowActionsLabel");case"create":return this.text("contextCreateOptionsLabel");case"list-sort":return this.text("sortLabel");case"toolbar-actions":return this.text("contextViewActionsLabel");default:return this.text("contextTableSettingsLabel")}}renderFilterFavoritesContextMenu(e){const{x:t,y:n,position:s}=e,i=this.getSelectedFilterTemplate();return p.html`
623
+ `}getSort(){return{...this.state.sort}}setSort(e=null,t=null){if(this.isActionParameters?.(e,["key","direction"])&&({key:e=null,direction:t=null}=e),null===e||null===t)return this.set({sort:{key:null,direction:null}}),{outcome:"applied"};if("string"!=typeof e||!e||!["asc","desc"].includes(t))throw new TypeError("Sort requires a column key and direction asc or desc");return this.set({sort:{key:e,direction:t}}),{outcome:"applied"}}toggleSort(e){const t=this.state.sort||{},n=t.key!==e?"asc":"asc"===t.direction?"desc":"desc"===t.direction?null:"asc";return this.setSort(n?e:null,n),this.emitTableEvent("sort-change",Object.freeze({key:e,direction:n}))}suppressNextHeaderClick(){this._suppressHeaderClick=!0,setTimeout(()=>{this._suppressHeaderClick=!1},0)}handleHeaderSortClick(e,t={}){if(!0!==t.sortable||t.system||this._suppressHeaderClick)return;const n=e.composedPath?.()[0]||e.target;n instanceof Element&&n.closest(".sf-table-column-resizer")||this.toggleSort(t.key)}syncSelectionPort(){if(!this._isMounted)return this;const e=this.getSelectedRecordIds(),t=JSON.stringify(e.map(e=>[typeof e,e]));return t===this._selectionPortKey||(this._selectionPortKey=t,this.emitTableEvent("select",Object.freeze({ids:Object.freeze([...e])}))),this}applyRowSelection(e,t,{range:n=!1}={}){const s=this.getTableData().rows,i=(e,t)=>String(e?.id??"")===String(t??""),r=s.findIndex(t=>i(t,e));if(r<0)return this;const a=n&&null!=this._selectionAnchorId?s.findIndex(e=>i(e,this._selectionAnchorId)):-1,o=a<0?r:Math.min(a,r),l=a<0?r:Math.max(a,r);return this.set({settingsChecked:!1}),this.updateRows((e,n)=>n<o||n>l?e:{...e,selected:t,checked:t,select:this.getDefaultRowCell(this.TABLE_SELECT_COLUMN,{...e,selected:t,checked:t})},n&&a>=0?"select-range":"select-row"),this._selectionAnchorId=e,this.syncSelectAllState()}syncSelectAllState(){const e=this.getSelectedRecordIds().length,t=this.getTableData().rows.length;return this.set({settingsChecked:t>0&&e===t,selectIndeterminate:e>0&&e<t})}handleRowPointerDown(e){return this._selectRangeModifier=!0===e?.shiftKey,(!0===e?.shiftKey||e?.detail>1)&&e.preventDefault?.(),this}isRowControlTarget(e){return e instanceof Element&&Boolean(e.closest('td[data-key="select"], td[data-key="settings"], a[href], button, input, select, textarea, [role="button"], [role="link"], sf-checkbox, sf-dropdown, sf-button, sf-button-icon'))}handleRowClick(e,t,n=-1){return this.focusRow(this.getRowKey(t,n)),this.openReferenceFromCell(e,t),this}openReferenceFromCell(e,t){if(e.defaultPrevented||e.button>0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;const n=e.target?.closest?.("a[href]"),s=n?.closest?.("td[data-key]");if(!n||!s||!this.contains(s))return;const i=s.dataset.key,r=t?.[i],a=n.getAttribute("href");if(!a||a.startsWith("#")||"_blank"===n.target||n.hasAttribute("download"))return;this.emitTableEvent("reference-open",{recordId:t?.id??null,field:i,value:r??null,href:a},{cancelable:!0})||e.preventDefault()}getRowKey(e,t=-1){const n=e?.id??e?.value;return null!=n&&""!==String(n)?String(n):t>=0?`index:${t}`:""}actionsShownFor(e){if("always"===this.getAttribute("row-actions-visible"))return!0;const t=String(e?.id??e?.value??"");return!t||(t===this._pointerRowKey||t===this._focusRowKey||String(this._currentRowId??"")===t)}setActionsRow(e,t){const n="focus"===e?"_focusRowKey":"_pointerRowKey",s=t?String(t):null;this[n]!==s&&(this[n]=s,this._layoutUnchanged=!0,this.requestComponentUpdate("row-actions"))}bindRowActionsEvents(e){if(!e||this._rowActionsTable===e)return;this._rowActionsAbort?.abort(),this._rowActionsAbort=new AbortController,this._rowActionsTable=e;const{signal:t}=this._rowActionsAbort,n=e=>e?.closest?.("tbody tr[data-row-id]")?.dataset.rowId??null;e.addEventListener("pointerover",e=>this.setActionsRow("pointer",n(e.target)),{signal:t}),e.addEventListener("dragstart",e=>{const t=n(e.target);if(!t||!this.hasAttribute("drag-rows")||!e.dataTransfer)return;const s=this.getSelectedRecordIds?.()??[],i=s.map(String).includes(t)?s.map(String):[t],r=this.getAttribute("preferences-key")||this.getAttribute("table-settings-key")||this.id||null;e.dataTransfer.setData("application/x-sf-records+json",JSON.stringify({ids:i,source:r})),e.dataTransfer.setData("text/plain",i.join(", ")),e.dataTransfer.effectAllowed="copyMove",this.emitTableEvent("rows-drag",Object.freeze({ids:i,source:r}))},{signal:t});const s=()=>"true"===this.getAttribute("row-reorder"),i=(t,n)=>{for(const t of e.querySelectorAll("tbody tr[data-sf-drop-before], tbody tr[data-sf-drop-after]"))t.removeAttribute("data-sf-drop-before"),t.removeAttribute("data-sf-drop-after");t&&t.setAttribute(n?"data-sf-drop-after":"data-sf-drop-before","")},r=e=>{const t=e.target?.closest?.("tbody tr[data-row-id]");if(!t)return null;const n=t.getBoundingClientRect();return{row:t,after:e.clientY>n.top+n.height/2}};e.addEventListener("dragstart",e=>{const t=n(e.target);t&&s()&&e.dataTransfer&&(this._reorderDrag=[t],e.dataTransfer.setData("application/x-sf-row-order",t),e.dataTransfer.effectAllowed="move")},{signal:t}),e.addEventListener("dragover",e=>{if(!this._reorderDrag||!s())return;const t=r(e);t&&(e.preventDefault(),e.dataTransfer.dropEffect="move",i(t.row,t.after))},{signal:t}),e.addEventListener("drop",t=>{if(!this._reorderDrag||!s())return;const n=r(t);i(null);const a=this._reorderDrag;if(this._reorderDrag=null,!n)return;t.preventDefault();const o=[...e.querySelectorAll("tbody tr[data-row-id]")].map(e=>e.dataset.rowId),l=o.indexOf(n.row.dataset.rowId)+(n.after?1:0),c=o.slice(l).filter(e=>!a.includes(e))[0]??null,u=o.filter(e=>!a.includes(e)),d=null===c?u.length:u.indexOf(c),h=[...u.slice(0,d),...a,...u.slice(d)];h.join("\0")!==o.join("\0")&&this.emitTableEvent("move",Object.freeze({ids:[...a],before:c,order:h}))},{signal:t}),e.addEventListener("dragend",()=>{this._reorderDrag=null,i(null)},{signal:t}),e.addEventListener("pointerleave",()=>this.setActionsRow("pointer",null),{signal:t}),e.addEventListener("focusin",e=>this.setActionsRow("focus",n(e.target)),{signal:t}),e.addEventListener("focusout",t=>{e.contains(t.relatedTarget)||this.setActionsRow("focus",null)},{signal:t})}isCurrentRow(e,t=-1){const n=this.getRowKey(e,t);return""!==n&&String(this._currentRowId??"")===n}windowSlice(e=[]){const t=e.length;if(t<B||this.isList)return this._windowed=!1,this._windowCount=t,null;this._windowed=!0,this._windowCount=t;const n=this._rowHeight||N,s=this.clampWindow(this._windowRange??{first:0,last:V-1},t);return this._windowRange=s,{first:s.first,last:s.last,before:s.first*n,after:Math.max(0,t-1-s.last)*n}}clampWindow({first:e=0,last:t=0}={},n=0){const s=Math.max(0,n-1),i=Math.min(Math.max(0,Math.floor(e)),s);return{first:i,last:Math.min(Math.max(i,Math.floor(t)),s)}}windowRowCount(){return this._windowed?String((this._windowCount??0)+1):null}seenRows(e){const t=this.refs.table?.value?.tBodies?.[0];if(!t||!e)return null;const n=t.getBoundingClientRect();let s=0,i=globalThis.innerHeight||document.documentElement.clientHeight||0;const r=this.refs.scroll?.value;if(r){const e=r.getBoundingClientRect();s=Math.max(s,e.top),i=Math.min(i,e.bottom)}const a=this._rowHeight||N,o=e-1,l=Math.min(o,Math.max(0,Math.floor((s-n.top)/a)));return{first:l,last:Math.min(o,Math.max(l,Math.ceil((i-n.top)/a)))}}syncWindow(){if(!this._windowed)return!1;const e=this.refs.table?.value,t=e?.querySelectorAll?.("tbody tr[data-row-id]")??[];let n=!1;if(t.length){const e=t[0].getBoundingClientRect(),s=(t[t.length-1].getBoundingClientRect().bottom-e.top)/t.length;s>0&&Math.abs(s-(this._rowHeight||0))>.5&&(this._rowHeight=s,n=!0)}const s=this._windowCount??0,i=this.seenRows(s);if(!i)return!1;const r=this._windowRange??{first:0,last:V-1},a=r.first>0?r.first+D/2:0,o=r.last<s-1?r.last-D/2:s-1;if((i.first<a||i.last>o)&&(this._windowRange=this.clampWindow({first:i.first-D,last:i.last+D},s),n=!0),!n)return!1;this._windowOnly=!0,this.requestComponentUpdate("window");const{first:l,last:c}=this._windowRange;return this._reportedWindow!==`${l}-${c}`&&(this._reportedWindow=`${l}-${c}`,this.emitTableEvent("window",{first:l,last:c})),!0}bindWindowScroll(){if(this._windowScrollAbort)return;this._windowScrollAbort=new AbortController;const e=this._windowScrollAbort.signal,t=()=>{this._windowed&&!this._windowFrame&&(this._windowFrame=requestAnimationFrame(()=>{this._windowFrame=0,this.isConnected&&this.syncWindow()}))};document.addEventListener("scroll",t,{capture:!0,passive:!0,signal:e}),globalThis.addEventListener?.("resize",t,{passive:!0,signal:e})}unbindWindowScroll(){this._windowScrollAbort?.abort(),this._windowScrollAbort=null,this._windowFrame&&cancelAnimationFrame(this._windowFrame),this._windowFrame=0}rowMarkupCell(e,t){const n=t?.key;if(!n||!e)return null;const i="1/2"===this.size?"1/2":"1";if("select"===n){const t=e.select?.component;return"checkbox"!==t?.type||"function"!=typeof t.props?.["@change"]?null:{kind:"box",size:i,checked:!0===t.props.checked,value:String(t.props.value??e.id??""),label:t.props.ariaLabel??"",change:t.props["@change"]}}if("settings"===n){const t=e.settings?.component;return"sf-button-icon"!==(0,s.canonicalTag)(`sf-${String(t?.type??"").replace(/^sf-/u,"")}`)||"menu"!==t.props?.icon||"function"!=typeof t.props?.["@click"]?null:{kind:"menu",size:i,label:t.props.ariaLabel??this.text("menuLabel"),click:t.props["@click"]}}if(t.system||t.component||"link"===t.renderer||"title"===t.role)return null;if(this.isTree()||e.path||this.cellEditable(e,t))return null;const r=e[n];if(null==r)return{kind:"empty"};if("string"!=typeof r&&"number"!=typeof r&&"boolean"!=typeof r)return null;if(K.has(t.propertyType??t.property_type??t.type)&&"boolean"!=typeof r){const e=this.cellText(t,r);return{kind:"text",className:"sf-table-cell-clip",text:e,title:e}}const a=this.getTypedCellValue(t,r);if(null!=a)return"string"!=typeof a&&"number"!=typeof a?null:{kind:"text",className:"sf-table-cell-bare",text:String(a)};if("boolean"==typeof r)return null;const o=String(r);return{kind:"text",className:"sf-table-cell-text",text:o,title:o.length>80?o:null}}keyboardRows(){return(this.getTableData().rows||[]).filter(e=>e&&!e.__tree?.more)}focusRow(e,{reveal:t=!1}={}){if(e&&"object"==typeof e)return this.focusRowAction(e);if(null==e||""===e)return this;this._currentRowId=String(e);const n=this.refs.table?.value;if(!n)return this;const s=`tbody tr[data-row-id="${String(e).replace(/"/gu,'\\"')}"]`;for(const e of n.querySelectorAll("tbody tr[data-current]"))e.removeAttribute("data-current");const i=n.querySelector(s);if(!i&&this._windowed){const t=this.getTableData().rows||[],n=t.findIndex((t,n)=>this.getRowKey(t,n)===String(e));return n>=0&&(this._windowRange=this.clampWindow({first:n-D,last:n+D},t.length),this._pendingFocusRow=String(e),this._windowOnly=!0,this.requestComponentUpdate("window")),this}return i?.setAttribute("data-current",""),t&&i?.scrollIntoView?.({block:"nearest",behavior:"instant"}),i?.focus?.({preventScroll:!0}),this}canOpenRow(e){return Array.isArray(e?.actions)&&e.actions.includes("view")}handleRowOpen(e,t){if(this.isRowControlTarget(e?.target)||!this.canOpenRow(t))return this;const n=t?.id;return null==n?this:this.requestActionIntent("view",[n])}isTree(){const e=this.getTableData?.().rows??[];return this._treeMemo?.rows!==e&&(this._treeMemo={rows:e,tree:e.some(e=>e?.__tree)}),this._treeMemo.tree}treeColumnKey(e=this.getColumns()){if(!this.isTree())return null;const t=e.filter(e=>e?.key&&!["select","settings","actions"].includes(e.key)&&!e.system);return(t.find(e=>"title"===e.role)??t[0])?.key??null}toggleTreeRow(e){return this.isActionParameters?.(e,["row"])&&!e.__tree&&(e=e.row),e?.__tree?.hasChildren?(this.emitTableEvent("expand",Object.freeze({id:e.id,expanded:!0===e.__tree.expanded})),{outcome:"applied"}):{outcome:"refused",reason:"no-children"}}requestTreeMore(e){return this.isActionParameters?.(e,["row"])&&!e.__tree&&(e=e.row),e?.__tree?.more?(this.emitTableEvent("load-more",Object.freeze({direction:"after",parent:e.__tree.parent,cursor:e.__tree.cursor??null})),{outcome:"applied"}):{outcome:"refused",reason:"no-more"}}handleRowKeydown(e,t){if(e?.target!==e?.currentTarget)return this;if(t?.__tree?.hasChildren&&("ArrowRight"===e.key||"ArrowLeft"===e.key)){const n=!0===t.__tree.expanded;if("ArrowRight"===e.key!==n)return e.preventDefault?.(),this.toggleTreeRow(t)}if("Enter"===e.key)return this.handleRowOpen({target:e.currentTarget},t);if(["ArrowDown","ArrowUp","Home","End"].includes(e.key)&&!e.altKey&&!e.metaKey&&!e.ctrlKey){const n=this.keyboardRows(),s=n.findIndex(e=>String(e?.id??e?.value)===String(t?.id??t?.value)),i={ArrowDown:s+1,ArrowUp:s-1,Home:0,End:n.length-1}[e.key];return s>=0&&i>=0&&i<n.length&&i!==s&&(e.preventDefault?.(),this.focusRow(this.getRowKey(n[i],i),{reveal:!0})),this}if(" "===e.key||"Spacebar"===e.key){e.preventDefault?.();const n=!0!==t?.select?.component?.props?.checked;return this.applyRowSelection(t?.id,n,{range:!0===e.shiftKey})}return this}clearSelection(){return this._selectionAnchorId=null,this.set({settingsChecked:!1,selectIndeterminate:!1}),this.getSelectedRecordIds().length?(this.updateRows(e=>({...e,selected:!1,checked:!1,select:this.getDefaultRowCell(this.TABLE_SELECT_COLUMN,{...e,selected:!1,checked:!1})}),"select-clear"),{outcome:"applied"}):{outcome:"applied"}}sfPortInput(e,t,n={}){if(!Object.hasOwn(M.inputs,e))throw new TypeError(`sf-view-table has no input port ${String(e)}`);const s=j(t),i=Number.isSafeInteger(n?.sequence)&&n.sequence>this._querySequence?n.sequence:this._querySequence+1;this._routeContext=Object.freeze({record_ids:s}),this._querySequence=i,this.clearSelection(),this.requestContextQuery(i)}requestContextQuery(e){return this._pendingQuerySequence=e,this._abandonedQuery=!1,this.setDataState("loading"),this.emitTableEvent("query",Object.freeze({reason:"context",context:this._routeContext,sequence:e}))}onConnected(){if(super.onConnected(),!this._lateLayoutAbort){this._lateLayoutAbort=new AbortController;const e=this._lateLayoutAbort.signal,t=()=>{this._lateLayoutFrame||(this._lateLayoutFrame=requestAnimationFrame(()=>{this._lateLayoutFrame=0,this.isConnected&&this.measureContentWidths()&&this.widthsChanged()}))};document.fonts?.addEventListener?.("loadingdone",t,{signal:e}),document.fonts?.ready?.then?.(()=>{e.aborted||t()}),document.addEventListener("load",e=>{"link"===e.target?.localName&&/stylesheet/u.test(e.target.rel)&&t()},{capture:!0,signal:e})}"undefined"==typeof ResizeObserver||this._responsiveObserver||(this._responsiveObserver=new ResizeObserver(([e])=>{const t=Math.floor(e.contentRect.width);t>0&&t!==this._responsiveWidth&&(this._responsiveWidth=t,this.requestComponentUpdate("responsive-columns")),this.measurePinnedColumns()}),this._observeResponsiveBox()),this._abandonedQuery&&this._routeContext&&(this._querySequence+=1,this.requestContextQuery(this._querySequence))}applyQueryResult(e,t){return this.isActionParameters?.(e,["sequence","rows"])&&({sequence:e,rows:t}=e),Number.isSafeInteger(e)&&e===this._pendingQuerySequence&&Array.isArray(t)?(this._pendingQuerySequence=null,this.setRows(t),this.setDataState("auto"),{outcome:"applied"}):{outcome:"refused",reason:"stale"}}getQueryContext(){return this._routeContext}getItemRef(e){return this.refs.items.has(e)||this.refs.items.set(e,this.createRef()),this.refs.items.get(e)}setIndeterminate(){return this.state.data.rows.filter(e=>e.select.component.props.checked).length}getTableData(){const e=this.state?.data;return e&&"object"==typeof e?e:{columns:[],rows:[]}}isContextMenuEvent(e){const t=e?.target;if(!(t instanceof Node))return!1;const n=this._portalContainer;if(n instanceof Node&&(n===t||n.contains(t)))return!0;const s=this.refs?.contextMenu?.value;return s instanceof Node&&(!(s!==t&&!s.contains(t))||(e.composedPath?.().includes(s)||!1))}contextEvent(e){this.isContextMenuEvent(e)||(this.tempSettings=null,this.closeContextMenu(!1))}splitItemsByColumns(e=[],t=1){const n=Array.isArray(e)?e:[],s=Math.max(1,Number(t)||1),i=Math.ceil(n.length/s);return i?Array.from({length:s},(e,t)=>n.slice(t*i,(t+1)*i)).filter(e=>e.length):[]}getPendingFilterState(e=this.state?.filter||{}){const t=this.tempSettings?.filter||{},n=Object.prototype.hasOwnProperty.call(t,"selectedTemplateKey");return{...e,...t,selectedTemplateKey:n?t.selectedTemplateKey:e.selectedTemplateKey,templates:t.templates||e.templates||[]}}getSortedFilterTemplates(e=this.state?.filter||{}){return this.getFilterTemplates(e).map((e,t)=>({...e,sourceIndex:t,order:"number"==typeof e.order?e.order:t})).sort((e,t)=>Boolean(e.pinned)!==Boolean(t.pinned)?e.pinned?-1:1:e.order!==t.order?e.order-t.order:e.sourceIndex-t.sourceIndex)}changeTempFilterTemplateSettings(e,t={}){if(!e)return;const n=this.getPendingFilterState(),s=this.getFilterTemplates(n).map(n=>{for(const[s,i]of Object.entries(t))n[s]=e===n.key?i:!i;return n});this.tempSettings={...this.tempSettings||{},filter:{...this.tempSettings?.filter||{},selectedTemplateKey:n.selectedTemplateKey,templates:s}},this.requestComponentUpdate("temp-filter-template")}patchTempFilterTemplateSettings(e,t={}){if(!e)return;const n=this.getPendingFilterState(),s=this.getFilterTemplates(n).map(n=>n.key===e?{...n,..."function"==typeof t?t(n):t}:n);this.tempSettings={...this.tempSettings||{},filter:{...this.tempSettings?.filter||{},selectedTemplateKey:n.selectedTemplateKey,templates:s}},this.requestComponentUpdate("temp-filter-template")}selectTempFilterTemplate(e){if(!e)return;const t=this.getPendingFilterState(),n=this.getFilterTemplates(t).map(t=>({...t,selected:t.key===e}));this.tempSettings={...this.tempSettings||{},filter:{...this.tempSettings?.filter||{},selectedTemplateKey:e,templates:n}},this.requestComponentUpdate("temp-filter-template")}normalizeFilterTemplate(e={},t=0){const n=e.key||`filter_template_${t+1}`,s=e.data&&"object"==typeof e.data?e.data:{};return{...e,key:n,label:e.label||s.template_name||n,data:{...s,values:{...s.values||{}},tags:{...s.tags||{}}}}}getFilterTemplates(e=this.state?.filter||{}){const t=(e.templates||[]).map((e,t)=>this.normalizeFilterTemplate(e,t));return t.length?t:[this.normalizeFilterTemplate({key:e.selectedTemplateKey||"default",label:this.text("defaultTemplateText"),selected:!0,order:0,data:{}})]}getFilterTemplateByKey(e,t=this.state?.filter||{}){return e&&t&&this.getFilterTemplates(t).find(t=>t.key===e)||null}getSelectedFilterTemplate(e=this.state?.filter||{}){const t=this.getFilterTemplates(e);if(Object.prototype.hasOwnProperty.call(e,"selectedTemplateKey")&&""===e.selectedTemplateKey)return null;const n=e.selectedTemplateKey||t.find(e=>e.selected)?.key||t[0]?.key||"";return this.getFilterTemplateByKey(n,{...e,templates:t})||t[0]||null}getCurrentFilterValues(e=this.state?.filter||{}){const t=this.getSelectedFilterTemplate(e);return{...t?.data?.values||{}}}getCurrentFilterTags(e=this.state?.filter||{}){const t=this.getSelectedFilterTemplate(e);return{...t?.data?.tags||{}}}normalizeFilterDataForCompare(e){return Array.isArray(e)?e.map(e=>this.normalizeFilterDataForCompare(e)):e&&"object"==typeof e?Object.keys(e).sort().reduce((t,n)=>({...t,[n]:this.normalizeFilterDataForCompare(e[n])}),{}):e}isSameFilterData(e,t){return JSON.stringify(this.normalizeFilterDataForCompare(e||{}))===JSON.stringify(this.normalizeFilterDataForCompare(t||{}))}getMergedFilterDraftData(e=this.state?.filter||{},t=this.tempSettings?.filter||{}){const n=this.getPendingFilterState({...e,selectedTemplateKey:Object.prototype.hasOwnProperty.call(t,"selectedTemplateKey")?t.selectedTemplateKey:e.selectedTemplateKey,templates:t.templates||e.templates||[]}),s=this.getCurrentFilterTags(n),i=this.getCurrentFilterValues(n),r=t.replaceTags?{...t.tags||{}}:{...s,...t.tags||{}},a=t.replaceValues?{...t.values||{}}:{...i,...t.values||{}};return Object.entries(t.values||{}).forEach(([e,t])=>{this.isEmptyFilterEntry(t)&&(delete a[e],delete r[e])}),{filter:n,tags:r,values:a}}hasPendingFilterDataChanges(e=this.state?.filter||{}){const t=this.tempSettings?.filter;if(!t||!Object.prototype.hasOwnProperty.call(t,"tags")&&!Object.prototype.hasOwnProperty.call(t,"values")&&!t.replaceTags&&!t.replaceValues)return!1;const n=this.getMergedFilterDraftData(e,t);return!this.isSameFilterData(this.getCurrentFilterTags(n.filter),n.tags)||!this.isSameFilterData(this.getCurrentFilterValues(n.filter),n.values)}countPendingFilterConditionChanges(e=this.state?.filter||{}){const t=this.tempSettings?.filter;if(!t)return 0;const n=this.getMergedFilterDraftData(e,t),s={tags:this.getCurrentFilterTags(n.filter),values:this.getCurrentFilterValues(n.filter)},i=(e,t)=>this.isSameFilterData(e,t),r=new Set([...Object.keys(s.tags||{}),...Object.keys(n.tags||{}),...Object.keys(s.values||{}),...Object.keys(n.values||{})]);let a=0;for(const e of r){Boolean((s.tags||{})[e]?.active)===Boolean((n.tags||{})[e]?.active)?i((s.values||{})[e],(n.values||{})[e])||(a+=1):a+=1}return a}hasUnsavedFilterDataChanges(){return Boolean(this.state?.filterDataDirty&&this.getSelectedFilterTemplate(this.state?.filter||{}))}saveCurrentFilterTemplateData(){const e=this.getSelectedFilterTemplate(this.state?.filter||{});return e?this.set({filterDataDirty:!1},()=>{this.dispatchFilterTemplateSave(e.key,this.state.filter,this.getFilterTemplateByKey(e.key))}):this}mergeObjectDeep(e={},t={}){return Object.entries(t||{}).reduce((e,[t,n])=>{const s=e[t],i=n&&"object"==typeof n&&!Array.isArray(n)&&s&&"object"==typeof s&&!Array.isArray(s);return{...e,[t]:i?this.mergeObjectDeep(s,n):n}},{...e||{}})}patchFilterTemplateByKey(e,t=this.state.filter,n={}){if(!e||!t)return{filter:t,template:null};let s=null;return{filter:{...t,templates:this.getFilterTemplates(t).map(t=>{if(e!==t.key)return t;const i="function"==typeof n?n(t):n;return s=this.mergeObjectDeep(t,i),s})},template:s}}createFilterTemplatePatchState(e,t={}){const n={filter:e};return Object.prototype.hasOwnProperty.call(t,"saveInputValue")&&(n.saveInputValue=t.saveInputValue),n}getActiveFilterFieldKeys(e=this.state?.filter||{}){const t=this.getCurrentFilterTags(e),n=this.getFilterFields().map(e=>e?.key),s=Object.keys(t).filter(e=>t[e]?.active);return[...n.filter(e=>s.includes(e)),...s.filter(e=>!n.includes(e))]}setActiveFilterFields(e=[],t=this.state?.filter||{}){if(!Array.isArray(e)||e.some(e=>"string"!=typeof e||!e.trim()))throw new TypeError("Filter field keys must be nonempty strings");const n=this.getSelectedFilterTemplate(t);if(!n?.key)return this;const s=this.getFilterFields(),i=this.getCurrentFilterTags(t),r={};for(const e of Object.keys(i))r[e]={...i[e],active:!1};for(const t of e){const e=s.find(e=>e?.key===t);r[t]={...i[t]||{},active:!0,label:e?.label??i[t]?.label??t,control:e?.filter?.control||e?.type||e?.dataType||i[t]?.control||"text"}}const a=this.patchFilterTemplateByKey(n.key,t,e=>({...e,data:{...e.data||{},tags:r}}));return this.set({filter:a.filter})}withFilterFieldSettings(e,t=this.state?.filter||{}){if(Array.isArray(e))return e.map(e=>this.withFilterFieldSettings(e,t));if(!e||"object"!=typeof e)return e;const n=Array.isArray(e.data?.tags)?[]:Object.keys(e.data?.tags||{}).filter(t=>e.data.tags[t]?.active);return{...e,settings:{...e.settings||{},filter_fields:n.length?n:this.getActiveFilterFieldKeys(t)}}}dispatchFilterTemplateSave(e,t,n=null){const s=this.withFilterFieldSettings(n||this.getFilterTemplateByKey(e,t),t);return this.emitTableEvent("template-save",s),this}getChangedFilterTemplates(e={},t={},n=[]){const s=new Map(this.getFilterTemplates(e).map(e=>[e.key,e]));return this.getFilterTemplates(t).filter(e=>{const t=s.get(e.key);return!t||n.some(n=>!Object.is(t[n],e[n]))})}dispatchFilterTemplatesSave(e=[]){const t=e.filter(e=>e?.key);if(!t.length)return this;const n=this.withFilterFieldSettings(1===t.length?t[0]:t);return this.emitTableEvent("template-save",n),this}saveFilterTemplatePatch(e,t={},n={},s=this.state.filter){if(!e||!s)return this;const i=this.patchFilterTemplateByKey(e,s,t),r={...i.filter,...n.filterPatch||{}};return this.set(()=>this.createFilterTemplatePatchState(r,n),()=>{!1!==n.dispatch&&this.dispatchFilterTemplateSave(e,r,i.template)})}setDefaultFilterTemplate(e){return e?this.set(t=>{const n=t.filter||{};return{filter:{...n,templates:this.getFilterTemplates(n).map(t=>({...t,default:t.key===e}))}}}):this}patchFilterTemplateData(e={},t={}){const n={...e};delete n.tags,delete n.values;const s=this.getFilterTemplates(n),i=this.getSelectedFilterTemplate({...n,templates:s});if(!i)return{...n,templates:s};const r=Object.prototype.hasOwnProperty.call(t,"values")?t.values||{}:i.data?.values||{},a=Object.prototype.hasOwnProperty.call(t,"tags")?t.tags||{}:i.data?.tags||{},o=s.map(e=>e.key===i.key?{...e,data:{...e.data||{},...t.data||{},values:r,tags:a}}:e);return{...n,selectedTemplateKey:i.key,templates:o}}getFilterPayload(e=this.state?.filter||{}){const t=this.getSelectedFilterTemplate(e);return{...t?.data||{},templateKey:t?.key||"",templateLabel:t?.label||"",values:this.getCurrentFilterValues(e),tags:this.getCurrentFilterTags(e)}}selectFilterTemplate(e){return e&&this.state?.filter?.selectedTemplateKey!==e?(this.set(t=>{const n={...t.filter||{},selectedTemplateKey:e,templates:(t.filter?.templates||[]).map(t=>({...t,selected:t.key===e}))},s=this.getFilterTemplateByKey(e,n)||n.templates[0]||null;return{filter:n,saveInputValue:s?.label||""}}),this):this}static reorderedKeys(e,t,n){const s=[...e.querySelectorAll("[data-sf-sortable-item]")].filter(t=>t.closest("sf-sortable")===e).map(e=>e.getAttribute("data-sf-sortable-item")).filter(e=>e!==t);return s.splice(Math.max(0,Math.min(n,s.length)),0,t),s}onFilterTemplateIntent(e){const t=e.target,{item:n,index:s}=e.detail??{};if(!(t instanceof Element&&n))return;const i=J.reorderedKeys(t,n,s),r="pinned"===t.getAttribute("data-group")?"pinned":"normal",a={pinned:new Map,normal:new Map};i.forEach((e,t)=>a[r].set(e,t)),this.syncFilterTemplateOrder(a)}onColumnSettingsIntent(e){const t=e.target,{item:n,index:s}=e.detail??{};if(!(t instanceof Element&&n))return;const i="pinned"===t.getAttribute("data-group"),r=J.reorderedKeys(t,n,s),a=r.indexOf(n),o=this.getColumnItems().filter(e=>e?.key&&!e.system),l=o.filter(e=>this.isColumnPinned(e)===i).map(e=>e.key).filter(e=>e!==n),c=r[a+1],u=r[a-1];let d=void 0!==c?l.indexOf(c):-1;-1===d&&(d=void 0!==u?l.indexOf(u)+1:l.length),l.splice(-1===d?l.length:d,0,n);const h=o.filter(e=>this.isColumnPinned(e)!==i).map(e=>e.key);(i?[...l,...h]:[...h,...l]).forEach((e,t)=>this.patchTempColumnSettings(e,{order:10*(t+1)})),this.requestComponentUpdate("column-order"),this.commitColumnSettings("column-order")}syncFilterTemplateOrder(e){const t=this.getPendingFilterState(),n=this.getFilterTemplates(t).map((t,n)=>{const s=t.pinned?"pinned":"normal",i=e[s].get(t.key);return"number"!=typeof i?t:{...t,order:i,sourceIndex:n}});this.tempSettings={...this.tempSettings||{},filter:{...this.tempSettings?.filter||{},selectedTemplateKey:t.selectedTemplateKey,templates:n.sort((e,t)=>Boolean(e.pinned)!==Boolean(t.pinned)?e.pinned?-1:1:e.order!==t.order?e.order-t.order:e.sourceIndex-t.sourceIndex)}},this.requestComponentUpdate("temp-filter-template-order")}get columnsAreCramped(){if(this._layoutReads?.has("cramped"))return this._layoutReads.get("cramped");const e=this.readColumnsAreCramped();return this._layoutReads?.set("cramped",e),e}readColumnsAreCramped(){const e=this.refs.scroll?.value?.clientWidth||this._responsiveWidth;if(!e)return!1;const t=(this.getColumns?.()??[]).filter(e=>this.columnTakesFloor(e));if(!t.length)return!1;const n=this.querySelector(".sf-table")??this,s=globalThis.getComputedStyle?.(n)?.getPropertyValue("--sf-table--column-min-inline-size")?.trim();if(!s)return!1;const i=Number.parseFloat(globalThis.getComputedStyle?.(document.documentElement)?.fontSize)||16,r=s.endsWith("rem")?Number.parseFloat(s)*i:Number.parseFloat(s);if(!Number.isFinite(r)||r<=0)return!1;return e-[...this.querySelectorAll("thead th")].filter(e=>!t.some(t=>t.key===e.dataset.key)).reduce((e,t)=>e+("actions"===t.dataset.key?Math.min(t.getBoundingClientRect().width,r):t.getBoundingClientRect().width),0)<t.length*r}get isList(){const e=this.getProp?.("layout")??"table";if("list"===e)return!0;if("table"===e)return!1;const t=Number(this.getProp?.("listBelow"))||600;return this._responsiveWidth>0&&this._responsiveWidth<t}get actionsColumnWidth(){const e=(this.ACTIONS_SETTINGS_ROW??[]).filter(e=>!1!==e?.inline).length;return e?`calc(${e} * (var(--sf-text-height-1) + var(--sf-ui-1--space-y-tightness-default) * 2) + ${e-1} * var(--sf-space-1\\/3) + var(--sf-b6))`:""}measureContentWidths(){const e=this.refs.table?.value;if(!(e instanceof HTMLTableElement&&e.isConnected))return!1;if(this._columnResizeState||this.columnDragActive)return!1;if(e.querySelector("tbody[data-state]")||e.querySelector("tbody[data-busy]")||!e.querySelector("tbody tr td"))return!1;const t=new Map;let n=0;const s=this.columnWidthCap(),i=e.parentElement?.clientWidth??0,r=new Map;for(const t of e.querySelectorAll("thead th[data-key]"))O.has(t.dataset.key)&&r.set(t,Math.ceil(t.getBoundingClientRect().width));if(e.classList.add("sf-table-measuring"),"auto"!==getComputedStyle(e).tableLayout)return e.classList.remove("sf-table-measuring"),!1;try{n=e.getBoundingClientRect().width;for(const n of e.querySelectorAll("thead th[data-key]")){const e=n.dataset.key;O.has(e)||t.set(e,U(n.getBoundingClientRect().width))}}finally{e.classList.remove("sf-table-measuring")}let a=0;for(const n of e.querySelectorAll("thead th[data-key]")){const e=n.dataset.key;a+=O.has(e)?r.get(n)??0:Math.min(t.get(e)??0,s)}const o=a!==(this._contentInlineSize??0);this._contentInlineSize=a;const l=i>0&&n>0&&n<i,c=l!==Boolean(this._contentSurplus);this._contentSurplus=l,this.remeasureWhenDrawn(e);const u=this._contentWidths??new Map,d=t.size!==u.size||[...t].some(([e,t])=>Math.abs((u.get(e)??0)-t)>2);return d&&(this._contentWidths=t),d||c||o}fitCellValues(){const e=new Set;for(const t of this.querySelectorAll("tbody .sf-table-cell-values > :not(.sf-table-cell-more)"))!t.localName.includes("-")||customElements.get(t.localName)&&W(t).getBoundingClientRect().width||e.add(t.localName);if(e.size&&(this._fitRetries??0)<3){this._fitRetries=(this._fitRetries??0)+1;const t=this._fitToken=(this._fitToken??0)+1;Promise.all([...e].map(e=>customElements.whenDefined(e))).then(()=>new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e)))).then(()=>{t===this._fitToken&&this.isConnected&&this.fitCellValues()})}else e.size||(this._fitRetries=0);const t=[];for(const e of this.querySelectorAll("tbody .sf-table-cell-values")){const n=e.querySelector(":scope > .sf-table-cell-more"),s=[...e.children].filter(e=>e!==n),i=s.map(e=>W(e));t.push({box:e,more:n,items:s,valueBoxes:i})}for(const{more:e,valueBoxes:n}of t){for(const e of n)e.classList.remove("sf-table-cell-folded");e&&(e.hidden=!0,e.removeAttribute("title"))}const n=t.filter(({box:e,more:t})=>t&&e.scrollWidth>e.clientWidth+1);for(const{box:e,more:t,items:s,valueBoxes:i}of n){t.hidden=!1,t.textContent=`+${s.length}`;const n=[];for(let r=s.length-1;r>0&&e.scrollWidth>e.clientWidth+1;r-=1)i[r].classList.add("sf-table-cell-folded"),n.unshift(s[r]),t.textContent=`+${n.length}`;n.length?t.title=n.map(e=>e.textContent.trim()).filter(Boolean).join(", "):t.hidden=!0}}measureWhenCellsDrawn(){const e=this.refs.table?.value;if(!(e instanceof HTMLTableElement)||this._columnResizeState||this.columnDragActive)return!1;if(e.querySelector("tbody[data-state]")||e.querySelector("tbody[data-busy]"))return!1;const t=[];for(const n of e.querySelectorAll("tbody td *"))if(n.localName.includes("-")){if(!customElements.get(n.localName)||"function"!=typeof n.whenRendered)return!1;if(n.hasAttribute("data-sf-style-pending"))return!1;!0!==n.isRendered&&t.push(n)}if(!t.length)return!1;const n=this._cellsDrawnToken=(this._cellsDrawnToken??0)+1,s=new Promise(e=>requestAnimationFrame(e));return Promise.race([Promise.all(t.map(e=>e.whenRendered())),s]).catch(()=>{}).then(()=>{n===this._cellsDrawnToken&&this.isConnected&&(this.measureContentWidths()&&this.applyColumnWidths(),this._contentRetries=0,this.fitCellValues(),this.measurePinnedColumns(),this.hasAttribute("data-sf-page-scroll")&&this.syncRail())}),!0}remeasureWhenDrawn(e){const t=new Set;for(const n of e.querySelectorAll("tbody td *"))n.localName.includes("-")&&(customElements.get(n.localName)&&n.childElementCount||t.add(n.localName));if(!t.size)return void(this._remeasureTries=0);if((this._remeasureTries??0)>=3)return;this._remeasureTries=(this._remeasureTries??0)+1;const n=this._remeasureToken=(this._remeasureToken??0)+1,s=[...e.querySelectorAll("tbody td *")].filter(e=>t.has(e.localName)&&"function"==typeof e.whenRendered);[...t].every(e=>customElements.get(e))&&s.length?Promise.all(s.map(e=>!0===e.isRendered?null:e.whenRendered())).then(()=>{n===this._remeasureToken&&this.isConnected&&this.measureContentWidths()&&this.widthsChanged()}):Promise.all([...t].map(e=>customElements.whenDefined(e))).then(()=>new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e)))).then(()=>{n===this._remeasureToken&&this.isConnected&&this.measureContentWidths()&&this.widthsChanged()})}widthsChanged(){this.applyColumnWidths(),this.fitCellValues(),this.measurePinnedColumns(),this.hasAttribute("data-sf-page-scroll")&&this.syncRail()}applyColumnWidths(){const e=this.refs.table?.value;if(!(e instanceof HTMLTableElement))return;const t=new Map((this.getColumns?.()??[]).map(e=>[String(e?.key),e])),n=[...e.querySelectorAll(":scope > colgroup > col[data-key]")],s=this.readingLayout(()=>n.map(e=>{const n=t.get(e.dataset.key);return n?(0,u.Y5)(this,n):null}));n.forEach((e,t)=>{const n=s[t];null!==n&&(e.getAttribute("style")??"")!==n&&(n?e.setAttribute("style",n):e.removeAttribute("style"))}),e.classList.toggle("sf-table-content-sized",this.hasContentWidths),e.classList.toggle("w-max",!this.hasContentWidths),this.hasContentWidths&&this._contentInlineSize?e.style.setProperty("--sf-table--content-inline-size",`${this._contentInlineSize}px`):e.style.removeProperty("--sf-table--content-inline-size")}contentWidth(e){const t=this._contentWidths?.get(e?.key);return t?e?.key===this.spareRoomColumnKey()?"":`${Math.min(t,this.columnWidthCap())}px`:""}spareRoomColumnKey(){const e=this.getColumns?.()??[];for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n?.key&&!O.has(n.key))return n.colWidth??n.width??n.size?null:n.key}return null}get hasContentWidths(){return Boolean(this._contentWidths?.size)}readingLayout(e){if(this._layoutReads)return e();this._layoutReads=new Map;try{return e()}finally{this._layoutReads=null}}columnWidthCap(){if(this._layoutReads?.has("cap"))return this._layoutReads.get("cap");const e=this.readColumnWidthCap();return this._layoutReads?.set("cap",e),e}readColumnWidthCap(){const e=getComputedStyle(this).getPropertyValue("--sf-table--column-max-inline-size").trim(),t=Number.parseFloat(getComputedStyle(document.documentElement).fontSize)||16,n=Number.parseFloat(e);return!Number.isFinite(n)||n<=0?320:e.endsWith("rem")?n*t:n}columnTakesFloor(e){return!(!e?.key||O.has(e.key))&&!(e.colWidth??e.width??e.size??e.min_width??e.minWidth)}settingsColumnHasUse(e=this.getPropsContext()){return!1!==e.settingsMenu||(!0===e.rowReorder||(this.ACTIONS_SETTINGS_ROW??[]).length>0)}getSystemColumns(){const e=[],t=this.getPropsContext();return t.selectable&&e.push(this.getSelectColumn()),t.settings&&this.settingsColumnHasUse(t)&&e.push(this.TABLE_SETTINGS_COLUMN),t.actions&&t.rowActions&&this.state.actionActive&&e.push(this.TABLE_ACTIONS_COLUMN),e}setTemplates(e){const t=Object.values(e||{}).map((e,t)=>this.normalizeFilterTemplate(e,t));return this.set(e=>{const n=e.filter||{},s=new Map;this.getFilterTemplates(n).forEach(e=>{s.set(e.key,e)}),t.forEach(e=>{s.set(e.key,{...s.get(e.key)||{},...e})});const i=Array.from(s.values()),r=Object.prototype.hasOwnProperty.call(n,"selectedTemplateKey"),a=i.find(e=>!0===e.default),o=t.find(e=>e?.selected)?.key,l=a?.key||i[0]?.key||"",c=this._filterTemplatesLoaded?o??(r?n.selectedTemplateKey:l):o??l,u={...n,selectedTemplateKey:c,templates:i.map(e=>({...e,selected:e.key===c}))},d=""===c?null:this.getFilterTemplateByKey(c,{...u,templates:i})||i[0]||null;return this._filterTemplatesLoaded=!0,{filter:u,saveInputValue:d?.label||""}})}getInstanceId(){return this.id||this._instanceId}getColumnResizerId(e){return`${this.getInstanceId()}--column-resizer--${e}`}getTableSettingsKey(){return this.tableSettingsKey||this.getAttribute?.("table-settings-key")||this.id||this.getInstanceId()}normalizeTableSettings(e={},t=this.getTableSettingsKey()){const n=!e?.tableSettings||"object"!=typeof e.tableSettings||Array.isArray(e.tableSettings)||e.tableSettings.columnSettings?null:e.tableSettings,s=e?.item||n?.[t]||e?.tableSettings||e?.settings||e||{},i=s?.columnSettings||e?.columnSettings||{};return{...s,columnSettings:i&&"object"==typeof i&&!Array.isArray(i)?i:{}}}setTableSettings(e={},t="table-settings-load",n=this.getTableSettingsKey()){const s=this.normalizeTableSettings(e,n);return this.setColumnSettings(s.columnSettings,t,!1)}getContextMenuLabel(e={}){switch(e.menu||e.type){case"filter-favorites":return this.text("contextSaveTemplateLabel");case"filter-settings":return this.text("contextFilterSettingsLabel");case"filter-template-actions":return`${this.text("contextTemplateActionsLabel")}: ${e.template?.label||e.template?.key||""}`.trim();case"tag-settings":{const t=e.fieldKey||"",n=this.getFilterField(t),s=n?.label||this.getCurrentFilterTags()?.[t]?.label||t;return`${this.text("contextFieldFilterLabel")}: ${s||this.text("fieldWordText")}`}case"row-settings":return this.text("contextRowActionsLabel");case"create":return this.text("contextCreateOptionsLabel");case"list-sort":return this.text("sortLabel");case"toolbar-actions":return this.text("contextViewActionsLabel");default:return this.text("contextTableSettingsLabel")}}renderFilterFavoritesContextMenu(e){const{x:t,y:n,position:s}=e,i=this.getSelectedFilterTemplate();return f.html`
624
624
  <sf-menu-context
625
625
  size=${"1/2"===this.size?"1/2":"1"}
626
626
  :key=${t+n+this._renderToken}
@@ -638,7 +638,7 @@
638
638
  <div class="flex flex-col flex-1 gap-2" slot="content">
639
639
  <div class="sf-table-context-top"><span class="sf-text-2 bold">Сохранение шаблона</span></div>
640
640
  <div class="sf-table-context-main">
641
- <form ${(0,m.ref)(this.refs.templateForm)} id="save_template" class="flex flex-col gap-1/2">
641
+ <form ${(0,g.ref)(this.refs.templateForm)} id="save_template" class="flex flex-col gap-1/2">
642
642
  <sf-input
643
643
  size=${this.size}
644
644
  appearance="filled"
@@ -677,7 +677,7 @@
677
677
  </div>
678
678
  </div>
679
679
  </sf-menu-context>
680
- `}saveFilterTemplate(){const e=this.refs.templateForm.value;if(!e)return!1;const t=Object.fromEntries(new FormData(e)),{templates:n}=this.state.filter,s=n.filter(e=>e.label===t.template_name)?.[0],i=this.getCurrentFilterValues(),r=this.getCurrentFilterTags();let a={key:s?s.key:`filter_template_${n.length+1}`,label:t.template_name,selected:!0,data:{...t,values:i,tags:r}};const o=this.withFilterFieldSettings(a);this.emitTableEvent("template-save",o),this.tempSettings=null,this.closeContextMenu()}renderRowSettingsContextMenu(e){const{x:t,y:n,position:s,transform:i,items:r=this.getActionRowItems(e.row||{}).map(e=>({component:"sf-button",props:{appearance:"link",scheme:"on-surface",text:e.name,"@click":t=>{const n=e.component.props["@click"]||e.component.props.onClick;n?.(t),this.closeContextMenu()}}}))}=e;let a=`translateY(calc(${void 0!==i?i:-50}%))`;if(s)switch(s){case"left-bottom":case"right-bottom":a=`translateY(calc(${void 0!==i?i:-100}% + var(--sf-context-menu-tail-corner-offset)))`}return p.html`
680
+ `}saveFilterTemplate(){const e=this.refs.templateForm.value;if(!e)return!1;const t=Object.fromEntries(new FormData(e)),{templates:n}=this.state.filter,s=n.filter(e=>e.label===t.template_name)?.[0],i=this.getCurrentFilterValues(),r=this.getCurrentFilterTags();let a={key:s?s.key:`filter_template_${n.length+1}`,label:t.template_name,selected:!0,data:{...t,values:i,tags:r}};const o=this.withFilterFieldSettings(a);this.emitTableEvent("template-save",o),this.tempSettings=null,this.closeContextMenu()}renderRowSettingsContextMenu(e){const{x:t,y:n,position:s,transform:i,items:r=this.getActionRowItems(e.row||{}).map(e=>({component:"sf-button",props:{appearance:"link",scheme:"on-surface",text:e.name,"@click":t=>{const n=e.component.props["@click"]||e.component.props.onClick;n?.(t),this.closeContextMenu()}}}))}=e;let a=`translateY(calc(${void 0!==i?i:-50}%))`;if(s)switch(s){case"left-bottom":case"right-bottom":a=`translateY(calc(${void 0!==i?i:-100}% + var(--sf-context-menu-tail-corner-offset)))`}return f.html`
681
681
  <sf-menu-context
682
682
  size=${"1/2"===this.size?"1/2":"1"}
683
683
  :key=${t+n}
@@ -694,22 +694,22 @@
694
694
  position="${s||"left"}"
695
695
  >
696
696
  </sf-menu-context>
697
- `}getColumnItems(){const e=this.getTableData().columns||[],t=new Map(e.map((e,t)=>[e?.key,t])),n=e=>{const n=e?.order;return null!=n&&""!==n&&Number.isFinite(Number(n))?Number(n):t.get(e?.key)??0};return e.map(e=>{const t=this.getColumnSetting(e?.key),n={...e,...t};return t.width&&(n.colWidth=t.width),n}).sort((e,s)=>{const i=e=>this.isColumnPinned(e)?0:this.isColumnVisible(e)?1:2,r=i(e),a=i(s);if(r!==a)return r-a;const o=n(e),l=n(s);return o===l?(t.get(e.key)??0)-(t.get(s.key)??0):o-l})}isColumnVisible(e){if(!e?.key)return!1;const t=this.tempSettings?.cols?.[e.key],n=this.getColumnSetting(e.key)||{};return t?.visible??n.visible??!1!==e.visible}getColumnSettings(){const e=this.getTableData().columnSettings,t=this.state?.columnSettings,n=this._columnSettingsMemo;if(n&&n.data===e&&n.state===t)return n.value;const s=this.mergedColumnSettings(e,t);return this._columnSettingsMemo={data:e,state:t,value:s},s}mergedColumnSettings(e,t){return{...e&&"object"==typeof e&&!Array.isArray(e)?e:{},...t&&"object"==typeof t&&!Array.isArray(t)?t:{}}}getColumnSetting(e){if(!e)return{};const t=this.getColumnSettings()?.[e];return t&&"object"==typeof t&&!Array.isArray(t)?t:{}}normalizeColumnSetting(e={}){const t={};return Object.entries(e||{}).forEach(([e,n])=>{void 0!==n&&("colWidth"!==e?t[e]=n:t.width=n)}),void 0!==t.order&&null!==t.order&&""!==t.order&&(t.order=Number(t.order)),t}mergeColumnSettings(e={},t={}){const n={...e||{}};return Object.entries(t||{}).forEach(([e,t])=>{e&&t&&"object"==typeof t&&(n[e]=this.normalizeColumnSetting({...n[e]||{},...t}))}),n}requestColumnSettingsReset(){if(this.viewPreferenceKey){const{columnSettings:e,widths:t,...n}=S()?.read(this.viewPreferenceKey)??{};S()?.write(this.viewPreferenceKey,n)}return this.emitTableEvent("column-settings-reset",Object.freeze({target:"personal",tableSettingsKey:this.getTableSettingsKey?.()??null}))}emitColumnSettingsChange(e="column-settings"){"preferences"!==e&&this.viewPreferenceKey&&this.writeTablePreference(this.viewPreferenceKey,{columnSettings:this.getColumnSettings()});const t={reason:e,columnSettings:this.getColumnSettings(),tableSettingsKey:this.getTableSettingsKey()};return this.emitTableEvent("save",{kind:"columns",...t}),this}setColumnSettings(e={},t="column-settings",n=!0){const s="function"==typeof e?e(this.getColumnSettings()):e;return this.set({columnSettings:s&&"object"==typeof s?s:{}},t,()=>!!n&&this.emitColumnSettingsChange(t))}patchColumnSettings(e,t={},n="column-settings"){if(!e)return this;const s=this.getColumnSetting(e),i="function"==typeof t?t(s):t;return this.patchColumnSettingsBatch({[e]:i||{}},n)}patchColumnSettingsBatch(e={},t="column-settings"){const n=this.getColumnSettings(),s=this.mergeColumnSettings(n,e);return JSON.stringify(n)===JSON.stringify(s)?this:this.setColumnSettings(s,t)}getFilterFields(){const e=this.state?.filter?.fields;return Array.isArray(e)?e:[]}offersFilter(e=0){const t=this.state?.filter?.templates;return this.getFilterFields().length>0||Array.isArray(t)&&t.length>0||e>0}getFilterField(e){return e&&this.getFilterFields().find(t=>t?.key===e)||null}setFilterFields(e=[],t="filter-fields"){for(const e of this._filterOptionPages.values())e.controller?.abort(),clearTimeout(e.searchTimer);return this._filterOptionPages.clear(),this.set(t=>({filter:{...t.filter||{},fields:Array.isArray(e)?e:[]}}),t)}patchTempColumnSettings(e,t={}){e&&(this.tempSettings={...this.tempSettings||{},cols:{...this.tempSettings?.cols||{},[e]:{...this.tempSettings?.cols?.[e]||{},..."function"==typeof t?t():t}}})}patchTempFilterTagSettings(e,t={}){e&&(this.tempSettings={...this.tempSettings||{},filter:{...this.tempSettings?.filter||{},tags:{...this.tempSettings?.filter?.tags||{},[e]:{...this.tempSettings?.filter?.tags?.[e]||{},..."function"==typeof t?t():t}}}},this.requestComponentUpdate("filter-tag"))}patchTempFilterValue(e,t={}){if(!e)return;const n=this.getCurrentFilterValues(this.getPendingFilterState()),s=this.tempSettings?.filter?.values?.[e]||n[e]||{},i="function"==typeof t?t(s):t,r={...s,...i||{}};Object.keys(r).some(e=>{return t=s[e],n=r[e],!(Array.isArray(t)&&Array.isArray(n)?t.length===n.length&&t.every((e,t)=>Object.is(e,n[t])):Object.is(t,n));var t,n})&&(this.tempSettings={...this.tempSettings||{},filter:{...this.tempSettings?.filter||{},values:{...this.tempSettings?.filter?.values||{},[e]:r}}},this.requestComponentUpdate("temp-filter-value"))}isEmptyFilterValue(e){return null==e||(Array.isArray(e)?e.every(e=>this.isEmptyFilterValue(e)):"string"==typeof e?""===e.trim():!(!e||"object"!=typeof e)&&Object.values(e).every(e=>this.isEmptyFilterValue(e)))}isEmptyFilterEntry(e){return e&&"object"==typeof e?Object.prototype.hasOwnProperty.call(e,"values")?this.isEmptyFilterValue(e.values):Object.prototype.hasOwnProperty.call(e,"value")?this.isEmptyFilterValue(e.value):Object.entries(e).filter(([e])=>!["operator","control","type"].includes(e)).every(([,e])=>this.isEmptyFilterValue(e)):this.isEmptyFilterValue(e)}mergeFilterState(e={},t={}){const{filter:n,tags:s,values:i}=this.getMergedFilterDraftData(e,t);return this.patchFilterTemplateData(n,{tags:s,values:i})}setColumnSettingsQuery(e=""){return this.set({columnSettingsQuery:String(e??"")})}matchesColumnQuery(e="",t=""){const n=e=>String(e??"").toLowerCase().replace(/ё/gu,"е"),s=n(t).trim();return!s||n(e).includes(s)}getColumnCheckboxItems(e={}){const{checked:t,onChange:n,refPrefix:s="column"}=e,{pin:i=!1,handle:r=!1,query:a="",group:o=""}=e,l=e=>!o||("pinned"===o?e.system||this.isColumnPinned(e):!e.system&&!this.isColumnPinned(e));return this.getColumnItems().filter(e=>l(e)&&(!i||e.system||this.matchesColumnQuery(e.label,a))).map(e=>{const a=this.getItemRef(`${s}:${e.key}`)||!1,o="function"==typeof t?Boolean(t(e)):Boolean(t),l=p.html`
697
+ `}getColumnItems(){const e=this.getTableData().columns||[],t=new Map(e.map((e,t)=>[e?.key,t])),n=e=>{const n=e?.order;return null!=n&&""!==n&&Number.isFinite(Number(n))?Number(n):t.get(e?.key)??0};return e.map(e=>{const t=this.getColumnSetting(e?.key),n={...e,...t};return t.width&&(n.colWidth=t.width),n}).sort((e,s)=>{const i=e=>this.isColumnPinned(e)?0:this.isColumnVisible(e)?1:2,r=i(e),a=i(s);if(r!==a)return r-a;const o=n(e),l=n(s);return o===l?(t.get(e.key)??0)-(t.get(s.key)??0):o-l})}isColumnVisible(e){if(!e?.key)return!1;const t=this.tempSettings?.cols?.[e.key],n=this.getColumnSetting(e.key)||{};return t?.visible??n.visible??!1!==e.visible}getColumnSettings(){const e=this.getTableData().columnSettings,t=this.state?.columnSettings,n=this._columnSettingsMemo;if(n&&n.data===e&&n.state===t)return n.value;const s=this.mergedColumnSettings(e,t);return this._columnSettingsMemo={data:e,state:t,value:s},s}mergedColumnSettings(e,t){return{...e&&"object"==typeof e&&!Array.isArray(e)?e:{},...t&&"object"==typeof t&&!Array.isArray(t)?t:{}}}getColumnSetting(e){if(!e)return{};const t=this.getColumnSettings()?.[e];return t&&"object"==typeof t&&!Array.isArray(t)?t:{}}normalizeColumnSetting(e={}){const t={};return Object.entries(e||{}).forEach(([e,n])=>{void 0!==n&&("colWidth"!==e?t[e]=n:t.width=n)}),void 0!==t.order&&null!==t.order&&""!==t.order&&(t.order=Number(t.order)),t}mergeColumnSettings(e={},t={}){const n={...e||{}};return Object.entries(t||{}).forEach(([e,t])=>{e&&t&&"object"==typeof t&&(n[e]=this.normalizeColumnSetting({...n[e]||{},...t}))}),n}requestColumnSettingsReset(){if(this.viewPreferenceKey){const{columnSettings:e,widths:t,...n}=C()?.read(this.viewPreferenceKey)??{};C()?.write(this.viewPreferenceKey,n)}return this.emitTableEvent("column-settings-reset",Object.freeze({target:"personal",tableSettingsKey:this.getTableSettingsKey?.()??null}))}emitColumnSettingsChange(e="column-settings"){"preferences"!==e&&this.viewPreferenceKey&&this.writeTablePreference(this.viewPreferenceKey,{columnSettings:this.getColumnSettings()});const t={reason:e,columnSettings:this.getColumnSettings(),tableSettingsKey:this.getTableSettingsKey()};return this.emitTableEvent("save",{kind:"columns",...t}),this}setColumnSettings(e={},t="column-settings",n=!0){const s="function"==typeof e?e(this.getColumnSettings()):e;return this.set({columnSettings:s&&"object"==typeof s?s:{}},t,()=>!!n&&this.emitColumnSettingsChange(t))}patchColumnSettings(e,t={},n="column-settings"){if(!e)return this;const s=this.getColumnSetting(e),i="function"==typeof t?t(s):t;return this.patchColumnSettingsBatch({[e]:i||{}},n)}patchColumnSettingsBatch(e={},t="column-settings"){const n=this.getColumnSettings(),s=this.mergeColumnSettings(n,e);return JSON.stringify(n)===JSON.stringify(s)?this:this.setColumnSettings(s,t)}getFilterFields(){const e=this.state?.filter?.fields;return Array.isArray(e)?e:[]}offersFilter(e=0){const t=this.state?.filter?.templates;return this.getFilterFields().length>0||Array.isArray(t)&&t.length>0||e>0}getFilterField(e){return e&&this.getFilterFields().find(t=>t?.key===e)||null}setFilterFields(e=[],t="filter-fields"){for(const e of this._filterOptionPages.values())e.controller?.abort(),clearTimeout(e.searchTimer);return this._filterOptionPages.clear(),this.set(t=>({filter:{...t.filter||{},fields:Array.isArray(e)?e:[]}}),t)}patchTempColumnSettings(e,t={}){e&&(this.tempSettings={...this.tempSettings||{},cols:{...this.tempSettings?.cols||{},[e]:{...this.tempSettings?.cols?.[e]||{},..."function"==typeof t?t():t}}})}patchTempFilterTagSettings(e,t={}){e&&(this.tempSettings={...this.tempSettings||{},filter:{...this.tempSettings?.filter||{},tags:{...this.tempSettings?.filter?.tags||{},[e]:{...this.tempSettings?.filter?.tags?.[e]||{},..."function"==typeof t?t():t}}}},this.requestComponentUpdate("filter-tag"))}patchTempFilterValue(e,t={}){if(!e)return;const n=this.getCurrentFilterValues(this.getPendingFilterState()),s=this.tempSettings?.filter?.values?.[e]||n[e]||{},i="function"==typeof t?t(s):t,r={...s,...i||{}};Object.keys(r).some(e=>{return t=s[e],n=r[e],!(Array.isArray(t)&&Array.isArray(n)?t.length===n.length&&t.every((e,t)=>Object.is(e,n[t])):Object.is(t,n));var t,n})&&(this.tempSettings={...this.tempSettings||{},filter:{...this.tempSettings?.filter||{},values:{...this.tempSettings?.filter?.values||{},[e]:r}}},this.requestComponentUpdate("temp-filter-value"))}isEmptyFilterValue(e){return null==e||(Array.isArray(e)?e.every(e=>this.isEmptyFilterValue(e)):"string"==typeof e?""===e.trim():!(!e||"object"!=typeof e)&&Object.values(e).every(e=>this.isEmptyFilterValue(e)))}isEmptyFilterEntry(e){return e&&"object"==typeof e?Object.prototype.hasOwnProperty.call(e,"values")?this.isEmptyFilterValue(e.values):Object.prototype.hasOwnProperty.call(e,"value")?this.isEmptyFilterValue(e.value):Object.entries(e).filter(([e])=>!["operator","control","type"].includes(e)).every(([,e])=>this.isEmptyFilterValue(e)):this.isEmptyFilterValue(e)}mergeFilterState(e={},t={}){const{filter:n,tags:s,values:i}=this.getMergedFilterDraftData(e,t);return this.patchFilterTemplateData(n,{tags:s,values:i})}setColumnSettingsQuery(e=""){return this.set({columnSettingsQuery:String(e??"")})}matchesColumnQuery(e="",t=""){const n=e=>String(e??"").toLowerCase().replace(/ё/gu,"е"),s=n(t).trim();return!s||n(e).includes(s)}getColumnCheckboxItems(e={}){const{checked:t,onChange:n,refPrefix:s="column"}=e,{pin:i=!1,handle:r=!1,query:a="",group:o=""}=e,l=e=>!o||("pinned"===o?e.system||this.isColumnPinned(e):!e.system&&!this.isColumnPinned(e));return this.getColumnItems().filter(e=>l(e)&&(!i||e.system||this.matchesColumnQuery(e.label,a))).map(e=>{const a=this.getItemRef(`${s}:${e.key}`)||!1,o="function"==typeof t?Boolean(t(e)):Boolean(t),l=f.html`
698
698
  <sf-checkbox
699
699
  size=${this.size}
700
700
  label=${e.label}
701
701
  position="end"
702
702
  root-class="content-main-between"
703
703
  ?checked=${o}
704
- ${(0,m.ref)(a)}
704
+ ${(0,g.ref)(a)}
705
705
  @change=${t=>n?.(e,t)}
706
706
  ></sf-checkbox>
707
- `;if(!i||e.system)return l;const c=this.isColumnPinned(e);return p.html`
707
+ `;if(!i||e.system)return l;const c=this.isColumnPinned(e);return f.html`
708
708
  <div class="sf-table-column-option flex items-cross-center gap-1/3"
709
709
  data-column-key=${e.key}
710
710
  data-sf-sortable-item=${e.key}
711
711
  data-pinned=${c?"1":"0"}>
712
- ${r?p.html`<sf-button-icon
712
+ ${r?f.html`<sf-button-icon
713
713
  size="1/2"
714
714
  appearance="link"
715
715
  scheme="on-surface"
@@ -718,7 +718,7 @@
718
718
  data-sf-sortable-handle
719
719
  root-class="sf-table-column-move cursor-grab"
720
720
  aria-label=${`${this.text("columnMoveLabel","column-move-label")}: ${e.label||e.key}`}
721
- ></sf-button-icon>`:p.nothing}
721
+ ></sf-button-icon>`:f.nothing}
722
722
  <span class="flex-1 min-w-0">${l}</span>
723
723
  <!-- A pinned column's pin is filled and a loose one's is
724
724
  outlined, the way a pinned filter template already
@@ -737,25 +737,25 @@
737
737
  @click=${()=>this.toggleColumnPinned(e)}
738
738
  ></sf-button-icon>
739
739
  </div>
740
- `})}restoreColumnSettingsOnOpen(e="column-settings-restore"){const t=JSON.parse(JSON.stringify(this._columnSettingsOnOpen||{}));return this.tempSettings=null,this.set(e=>({...e,columnSettings:t}),e,()=>this.emitColumnSettingsChange(e)),this}commitColumnSettings(e="table-settings"){const t=this.tempSettings||{},{cols:n,...s}=t;if(!n)return this;const i=this.mergeColumnSettings(this.getColumnSettings(),n);return this.tempSettings=Object.keys(s).length?s:null,this.set(e=>({...e,columnSettings:i}),e,()=>this.emitColumnSettingsChange(e)),this}toggleColumnPinned(e){if(!e?.key||e.system)return this;const t=!this.isColumnPinned(e),n=this.getColumnItems().filter(e=>e?.key&&!e.system),s=n.map((e,t)=>{const n=this.tempSettings?.cols?.[e.key],s=this.getColumnSetting(e.key)||{},i=Number(n?.order??s.order??e.order);return Number.isFinite(i)?i:10*(t+1)}),i=n.map((e,t)=>({column:e,order:s[t]})).filter(n=>n.column.key!==e.key&&this.isColumnPinned(n.column)===t),r=t?Math.max(0,...i.map(e=>e.order))+10:Math.max(0,Math.min(...i.map(e=>e.order),10)-10);return this.patchTempColumnSettings(e.key,{pinned:t,order:r}),this.requestComponentUpdate("column-pin"),this.commitColumnSettings("column-pin"),this}renderSortableGroups(e,t,{name:n,label:s,onIntent:i}){const r=(e,t)=>t.length?p.html`<sf-sortable
740
+ `})}restoreColumnSettingsOnOpen(e="column-settings-restore"){const t=JSON.parse(JSON.stringify(this._columnSettingsOnOpen||{}));return this.tempSettings=null,this.set(e=>({...e,columnSettings:t}),e,()=>this.emitColumnSettingsChange(e)),this}commitColumnSettings(e="table-settings"){const t=this.tempSettings||{},{cols:n,...s}=t;if(!n)return this;const i=this.mergeColumnSettings(this.getColumnSettings(),n);return this.tempSettings=Object.keys(s).length?s:null,this.set(e=>({...e,columnSettings:i}),e,()=>this.emitColumnSettingsChange(e)),this}toggleColumnPinned(e){if(!e?.key||e.system)return this;const t=!this.isColumnPinned(e),n=this.getColumnItems().filter(e=>e?.key&&!e.system),s=n.map((e,t)=>{const n=this.tempSettings?.cols?.[e.key],s=this.getColumnSetting(e.key)||{},i=Number(n?.order??s.order??e.order);return Number.isFinite(i)?i:10*(t+1)}),i=n.map((e,t)=>({column:e,order:s[t]})).filter(n=>n.column.key!==e.key&&this.isColumnPinned(n.column)===t),r=t?Math.max(0,...i.map(e=>e.order))+10:Math.max(0,Math.min(...i.map(e=>e.order),10)-10);return this.patchTempColumnSettings(e.key,{pinned:t,order:r}),this.requestComponentUpdate("column-pin"),this.commitColumnSettings("column-pin"),this}renderSortableGroups(e,t,{name:n,label:s,onIntent:i}){const r=(e,t)=>t.length?f.html`<sf-sortable
741
741
  group=${`${n}-${e}`}
742
742
  data-group=${e}
743
743
  label=${s}
744
744
  class="flex flex-col gap-1/3"
745
- @sf-sortable-intent=${i}>${t}</sf-sortable>`:p.nothing;return p.html`${r("pinned",e)}${r("loose",t)}`}getTableColsData(e=""){return this.getColumnCheckboxItems({group:e,pin:!0,handle:!0,query:this.state.columnSettingsQuery||"",refPrefix:"table-column",checked:e=>this.isColumnVisible(e),onChange:(e,t)=>{this.patchTempColumnSettings(e.key,{visible:Boolean(t.target?.checked)}),this.commitColumnSettings("column-visibility")}})}getFilterTagColsData(){const e=this.getFilterFields().filter(e=>!1!==e?.filter?.enabled);return(e.length?e:this.getColumnItems()).map(e=>{const t=this.tempSettings?.filter?.tags?.[e.key],n=this.getCurrentFilterTags(this.getPendingFilterState())?.[e.key],s={type:"checkbox",props:{size:this.size,label:e.label,position:"end",rootClass:"content-main-between",checked:t?.active??n?.active??!1,":ref":this.getItemRef(`filter-tag-column:${e.key}`)||!1,"@change":t=>{this.patchTempFilterTagSettings(e.key,{active:Boolean(t.target?.checked),label:e.label,control:e.filter?.control||e.type||e.dataType||"text"})}}};return this.renderSmartElement(s.type,s.props)})}getFilterControlValue(e){return{...this.getCurrentFilterValues()?.[e]||{},...this.tempSettings?.filter?.values?.[e]||{}}}getFilterOptions(e={}){const t=e.filter||{},n=t.optionsSource||{};if("endpoint"===n.type){const t=this.getEndpointFilterPage(e),n=new Set(this.getFilterControlValue(e.key).values||[]),s=new Map;for(const e of[...t?.selected||[],...t?.items||[]])"string"==typeof e?.value&&"string"==typeof e?.label&&(n.has(e.value)||(t?.items||[]).includes(e))&&s.set(e.value,e);return[...s.values()]}return Array.isArray(t.options)?t.options:Array.isArray(n.items)?n.items:[]}getEndpointFilterPage(e={}){const t=e.filter?.optionsSource;if("endpoint"!==t?.type||"string"!=typeof t.url||!t.url.trim()||!e.key)return null;let n=this._filterOptionPages.get(e.key);return n&&n.url===t.url||(n?.controller?.abort(),n={url:t.url,items:[],selected:[],nextCursor:null,status:"idle",sequence:0,searchable:!1},this._filterOptionPages.set(e.key,n),queueMicrotask(()=>{this.isConnected&&this._filterOptionPages.get(e.key)===n&&this.loadEndpointFilterPage(e)})),n}async loadEndpointFilterPage(e={},t=null,n=""){const s=this.getEndpointFilterPage(e);if(!s||!this.isConnected)return!1;let i;try{if(i=new URL(s.url,globalThis.location?.href),i.origin!==globalThis.location?.origin)throw new TypeError("filter_options_cross_origin")}catch{return s.status="error",this.requestComponentUpdate("filter-options"),!1}s.controller?.abort();const r=new AbortController,a=++s.sequence;s.controller=r,s.status="loading",i.searchParams.set("limit","50"),i.searchParams.set("sequence",String(a)),t?i.searchParams.set("cursor",t):i.searchParams.delete("cursor"),n&&s.searchable?i.searchParams.set("search",n):i.searchParams.delete("search"),i.searchParams.delete("selected_values[]");for(const t of this.getFilterControlValue(e.key).values||[])"string"==typeof t&&i.searchParams.append("selected_values[]",t);this.requestComponentUpdate("filter-options");try{const n=await fetch(i,{credentials:"same-origin",signal:r.signal,headers:{Accept:"application/json"}}),o=await n.json();if(s.sequence!==a||this._filterOptionPages.get(e.key)!==s||!this.isConnected)return!1;if(!n.ok||"ok"!==o?.status||o.sequence!==a||!Array.isArray(o.items)||!Array.isArray(o.selected)||null!==o.next_cursor&&"string"!=typeof o.next_cursor)throw new TypeError("filter_options_answer_invalid");const l=e=>e.filter(e=>"string"==typeof e?.value&&e.value&&"string"==typeof e?.label&&e.label).map(({value:e,label:t})=>({value:e,label:t})),c=new Map((t?s.items:[]).map(e=>[e.value,e]));for(const e of l(o.items))c.set(e.value,e);return s.items=[...c.values()],s.selected=l(o.selected),s.nextCursor=o.next_cursor,s.searchable=!0===o.searchable,s.status="ready",this.requestComponentUpdate("filter-options"),!0}catch(e){return s.sequence!==a||"AbortError"===e?.name||(s.status="error",this.requestComponentUpdate("filter-options")),!1}}getFilterOptionSearch(e){return e&&this.tempSettings?.filterSearch?.[e]||""}patchTempFilterOptionSearch(e,t=""){if(!e)return;this.tempSettings={...this.tempSettings||{},filterSearch:{...this.tempSettings?.filterSearch||{},[e]:String(t||"")}},this.requestComponentUpdate("filter-option-search");const n=this.getFilterField(e),s=n&&this.getEndpointFilterPage(n);s?.searchable&&(clearTimeout(s.searchTimer),s.searchTimer=setTimeout(()=>this.loadEndpointFilterPage(n,null,String(t||"").trim()),200))}filterUpdate(){return this.getFilterPayload()}getFilterOptionSearchKeys(e={}){const t=e.filter?.searchKeys||e.filter?.optionSearchKeys;return Array.isArray(t)&&t.length?t:["label","title","name","text","value","id"]}getObjectPathValue(e={},t=""){return String(t||"").split(".").filter(Boolean).reduce((e,t)=>null==e?"":e[t],e)}normalizeFilterSearchValue(e=""){return String(e||"").trim().toLowerCase()}optionMatchesSearch(e={},t="",n=[]){const s=this.normalizeFilterSearchValue(t);return!s||n.some(t=>{const n=this.getObjectPathValue(e,t);return this.normalizeFilterSearchValue(n).includes(s)})}getVisibleFilterOptions(e={}){const t=this.getFilterOptions(e),n=this.getFilterOptionSearch(e.key);if(!n)return t;const s=this.getFilterOptionSearchKeys(e);return t.filter(e=>this.optionMatchesSearch(e,n,s))}cellEditable(e={},t={}){return"true"===this.getAttribute("inline-edit")&&("boolean"===(t.propertyType??t.property_type??t.type)&&(Array.isArray(e.editable)&&e.editable.map(String).includes(String(t.key))))}cellPending(e={},t={}){return!0===this._pendingCells?.has(`${this.getRowKey(e)}\0${t.key}`)}setCellValue(e={},t={},n){const s=this.getRowKey(e);this._pendingCells??=new Set,this._pendingCells.add(`${s}\0${t.key}`),this.requestComponentUpdate("cell-pending"),this.emitTableEvent("cell-set",Object.freeze({id:e.id??s,key:t.key,value:n,revision:e._revision??e.revision??null}))}clearCellPending(e,t){this._pendingCells?.delete(`${e}\0${t}`)&&this.requestComponentUpdate("cell-pending")}resetCellControl(e,t,n){const s=e=>String(e).replace(/"/gu,'\\"'),i=this.querySelector(`tbody tr[data-row-id="${s(e)}"] [data-cell-edit="${s(t)}"]`);if(!i)return;const r=!0===n;i.checked=r,i.toggleAttribute("checked",r);const a=i.querySelector("input");a&&(a.checked=r)}getTypedCellValue(e={},t){return(0,h.dV)(e,t,this.cellHost??null)}renderFilterControl(e={}){return(0,h.fT)(e,{size:this.size,getFilterControlValue:e=>this.getFilterControlValue(e),patchTempFilterValue:(e,t)=>this.patchTempFilterValue(e,t),getFilterOperatorLabel:e=>this.getFilterOperatorLabel(e),getFilterOptionSearch:e=>this.getFilterOptionSearch(e),patchTempFilterOptionSearch:(e,t)=>this.patchTempFilterOptionSearch(e,t),getVisibleFilterOptions:e=>this.getVisibleFilterOptions(e),renderFilterOption:(e,t)=>this.renderFilterOption(e,t),getEndpointFilterPage:e=>this.getEndpointFilterPage(e),loadEndpointFilterPage:(e,t,n)=>this.loadEndpointFilterPage(e,t,n)})}renderFilterOption(e={},t={},n=new Set){const s=t.value??t.id??t.key??t.label??t.title,i=t.label||t.title||String(s||""),r="badge"===e.filter?.optionRenderer?(0,d.f)(t):null;return p.html`
745
+ @sf-sortable-intent=${i}>${t}</sf-sortable>`:f.nothing;return f.html`${r("pinned",e)}${r("loose",t)}`}getTableColsData(e=""){return this.getColumnCheckboxItems({group:e,pin:!0,handle:!0,query:this.state.columnSettingsQuery||"",refPrefix:"table-column",checked:e=>this.isColumnVisible(e),onChange:(e,t)=>{this.patchTempColumnSettings(e.key,{visible:Boolean(t.target?.checked)}),this.commitColumnSettings("column-visibility")}})}getFilterTagColsData(){const e=this.getFilterFields().filter(e=>!1!==e?.filter?.enabled);return(e.length?e:this.getColumnItems()).map(e=>{const t=this.tempSettings?.filter?.tags?.[e.key],n=this.getCurrentFilterTags(this.getPendingFilterState())?.[e.key],s={type:"checkbox",props:{size:this.size,label:e.label,position:"end",rootClass:"content-main-between",checked:t?.active??n?.active??!1,":ref":this.getItemRef(`filter-tag-column:${e.key}`)||!1,"@change":t=>{this.patchTempFilterTagSettings(e.key,{active:Boolean(t.target?.checked),label:e.label,control:e.filter?.control||e.type||e.dataType||"text"})}}};return this.renderSmartElement(s.type,s.props)})}getFilterControlValue(e){return{...this.getCurrentFilterValues()?.[e]||{},...this.tempSettings?.filter?.values?.[e]||{}}}getFilterOptions(e={}){const t=e.filter||{},n=t.optionsSource||{};if("endpoint"===n.type){const t=this.getEndpointFilterPage(e),n=new Set(this.getFilterControlValue(e.key).values||[]),s=new Map;for(const e of[...t?.selected||[],...t?.items||[]])"string"==typeof e?.value&&"string"==typeof e?.label&&(n.has(e.value)||(t?.items||[]).includes(e))&&s.set(e.value,e);return[...s.values()]}return Array.isArray(t.options)?t.options:Array.isArray(n.items)?n.items:[]}getEndpointFilterPage(e={}){const t=e.filter?.optionsSource;if("endpoint"!==t?.type||"string"!=typeof t.url||!t.url.trim()||!e.key)return null;let n=this._filterOptionPages.get(e.key);return n&&n.url===t.url||(n?.controller?.abort(),n={url:t.url,items:[],selected:[],nextCursor:null,status:"idle",sequence:0,searchable:!1},this._filterOptionPages.set(e.key,n),queueMicrotask(()=>{this.isConnected&&this._filterOptionPages.get(e.key)===n&&this.loadEndpointFilterPage(e)})),n}async loadEndpointFilterPage(e={},t=null,n=""){const s=this.getEndpointFilterPage(e);if(!s||!this.isConnected)return!1;let i;try{if(i=new URL(s.url,globalThis.location?.href),i.origin!==globalThis.location?.origin)throw new TypeError("filter_options_cross_origin")}catch{return s.status="error",this.requestComponentUpdate("filter-options"),!1}s.controller?.abort();const r=new AbortController,a=++s.sequence;s.controller=r,s.status="loading",i.searchParams.set("limit","50"),i.searchParams.set("sequence",String(a)),t?i.searchParams.set("cursor",t):i.searchParams.delete("cursor"),n&&s.searchable?i.searchParams.set("search",n):i.searchParams.delete("search"),i.searchParams.delete("selected_values[]");for(const t of this.getFilterControlValue(e.key).values||[])"string"==typeof t&&i.searchParams.append("selected_values[]",t);this.requestComponentUpdate("filter-options");try{const n=await fetch(i,{credentials:"same-origin",signal:r.signal,headers:{Accept:"application/json"}}),o=await n.json();if(s.sequence!==a||this._filterOptionPages.get(e.key)!==s||!this.isConnected)return!1;if(!n.ok||"ok"!==o?.status||o.sequence!==a||!Array.isArray(o.items)||!Array.isArray(o.selected)||null!==o.next_cursor&&"string"!=typeof o.next_cursor)throw new TypeError("filter_options_answer_invalid");const l=e=>e.filter(e=>"string"==typeof e?.value&&e.value&&"string"==typeof e?.label&&e.label).map(({value:e,label:t})=>({value:e,label:t})),c=new Map((t?s.items:[]).map(e=>[e.value,e]));for(const e of l(o.items))c.set(e.value,e);return s.items=[...c.values()],s.selected=l(o.selected),s.nextCursor=o.next_cursor,s.searchable=!0===o.searchable,s.status="ready",this.requestComponentUpdate("filter-options"),!0}catch(e){return s.sequence!==a||"AbortError"===e?.name||(s.status="error",this.requestComponentUpdate("filter-options")),!1}}getFilterOptionSearch(e){return e&&this.tempSettings?.filterSearch?.[e]||""}patchTempFilterOptionSearch(e,t=""){if(!e)return;this.tempSettings={...this.tempSettings||{},filterSearch:{...this.tempSettings?.filterSearch||{},[e]:String(t||"")}},this.requestComponentUpdate("filter-option-search");const n=this.getFilterField(e),s=n&&this.getEndpointFilterPage(n);s?.searchable&&(clearTimeout(s.searchTimer),s.searchTimer=setTimeout(()=>this.loadEndpointFilterPage(n,null,String(t||"").trim()),200))}filterUpdate(){return this.getFilterPayload()}getFilterOptionSearchKeys(e={}){const t=e.filter?.searchKeys||e.filter?.optionSearchKeys;return Array.isArray(t)&&t.length?t:["label","title","name","text","value","id"]}getObjectPathValue(e={},t=""){return String(t||"").split(".").filter(Boolean).reduce((e,t)=>null==e?"":e[t],e)}normalizeFilterSearchValue(e=""){return String(e||"").trim().toLowerCase()}optionMatchesSearch(e={},t="",n=[]){const s=this.normalizeFilterSearchValue(t);return!s||n.some(t=>{const n=this.getObjectPathValue(e,t);return this.normalizeFilterSearchValue(n).includes(s)})}getVisibleFilterOptions(e={}){const t=this.getFilterOptions(e),n=this.getFilterOptionSearch(e.key);if(!n)return t;const s=this.getFilterOptionSearchKeys(e);return t.filter(e=>this.optionMatchesSearch(e,n,s))}cellEditable(e={},t={}){return"true"===this.getAttribute("inline-edit")&&("boolean"===(t.propertyType??t.property_type??t.type)&&(Array.isArray(e.editable)&&e.editable.map(String).includes(String(t.key))))}cellPending(e={},t={}){return!0===this._pendingCells?.has(`${this.getRowKey(e)}\0${t.key}`)}setCellValue(e={},t={},n){const s=this.getRowKey(e);this._pendingCells??=new Set,this._pendingCells.add(`${s}\0${t.key}`),this.requestComponentUpdate("cell-pending"),this.emitTableEvent("cell-set",Object.freeze({id:e.id??s,key:t.key,value:n,revision:e._revision??e.revision??null}))}clearCellPending(e,t){this._pendingCells?.delete(`${e}\0${t}`)&&this.requestComponentUpdate("cell-pending")}resetCellControl(e,t,n){const s=e=>String(e).replace(/"/gu,'\\"'),i=this.querySelector(`tbody tr[data-row-id="${s(e)}"] [data-cell-edit="${s(t)}"]`);if(!i)return;const r=!0===n;i.checked=r,i.toggleAttribute("checked",r);const a=i.querySelector("input");a&&(a.checked=r)}getTypedCellValue(e={},t){const n=this.cellHost??null,s=e.propertyType??e.property_type??e.type;if("file"===s&&Array.isArray(t)){const s=t.map(t=>(0,h.dV)(e,t,n)).filter(e=>null!=e);return s.length?s:null}const i=(0,h.dV)(e,t,n);return null!=i?i:m.J.has(s)&&(0,m.x)(s,t,this)||null}cellText(e={},t){return"html"===(e.propertyType??e.property_type??e.type)?(0,p.j)(t):String(t)}renderFilterControl(e={}){return(0,h.fT)(e,{size:this.size,getFilterControlValue:e=>this.getFilterControlValue(e),patchTempFilterValue:(e,t)=>this.patchTempFilterValue(e,t),getFilterOperatorLabel:e=>this.getFilterOperatorLabel(e),getFilterOptionSearch:e=>this.getFilterOptionSearch(e),patchTempFilterOptionSearch:(e,t)=>this.patchTempFilterOptionSearch(e,t),getVisibleFilterOptions:e=>this.getVisibleFilterOptions(e),renderFilterOption:(e,t)=>this.renderFilterOption(e,t),getEndpointFilterPage:e=>this.getEndpointFilterPage(e),loadEndpointFilterPage:(e,t,n)=>this.loadEndpointFilterPage(e,t,n)})}renderFilterOption(e={},t={},n=new Set){const s=t.value??t.id??t.key??t.label??t.title,i=t.label||t.title||String(s||""),r="badge"===e.filter?.optionRenderer?(0,d.f)(t):null;return f.html`
746
746
  <div
747
- ${(0,m.ref)(this.getItemRef(t.label))}
747
+ ${(0,g.ref)(this.getItemRef(t.label))}
748
748
  class="flex items-cross-center gap-1/2 content-main-between">
749
749
  <div class="flex items-cross-center gap-1/2 min-w-0">
750
- ${r?p.html`
750
+ ${r?f.html`
751
751
  <sf-badge
752
752
  appearance="tonal"
753
753
  scheme=${r.scheme}
754
- root-style=${r.rootStyle||p.nothing}
755
- icon=${t.icon||p.nothing}
754
+ root-style=${r.rootStyle||f.nothing}
755
+ icon=${t.icon||f.nothing}
756
756
  text=${i}
757
757
  ></sf-badge>
758
- `:p.html`
758
+ `:f.html`
759
759
  ${this.renderFilterOptionVisual(e,t)}
760
760
  <span class="sf-text-1 truncate">${i}</span>
761
761
  `}
@@ -768,36 +768,36 @@
768
768
  @change=${t=>{const i=new Set(n);t.target?.checked?i.add(s):i.delete(s),this.patchTempFilterValue(e.key,{values:Array.from(i),operator:e.filter?.defaultOperator||"in"})}}
769
769
  ></sf-checkbox>
770
770
  </div>
771
- `}renderFilterOptionVisual(e={},t={}){return"swatch"===e.filter?.optionRenderer&&t.color?p.html`<span class="sf-table-filter-swatch" aria-hidden="true" style=${`background-color: ${t.color}`}></span>`:"avatar-checkbox"!==e.filter?.optionRenderer?"":t.imageUrl?p.html`
771
+ `}renderFilterOptionVisual(e={},t={}){return"swatch"===e.filter?.optionRenderer&&t.color?f.html`<span class="sf-table-filter-swatch" aria-hidden="true" style=${`background-color: ${t.color}`}></span>`:"avatar-checkbox"!==e.filter?.optionRenderer?"":t.imageUrl?f.html`
772
772
  <sf-avatar
773
773
  size=${this.size}
774
774
  image-url="${t.imageUrl}"
775
775
  heading="${t.title||t.label||""}"
776
776
  ></sf-avatar>
777
- `:p.html`
777
+ `:f.html`
778
778
  <sf-avatar
779
779
  size=${this.size}
780
780
  heading="${t.avatarText||t.title||t.label||""}"
781
781
  ></sf-avatar>
782
- `}getFilterOperatorLabel(e){const t={eq:"operatorEq",gt:"operatorGt",gte:"operatorGte",lt:"operatorLt",lte:"operatorLte",between:"operatorBetween",contains:"operatorContains",startsWith:"operatorStartsWith",any:"operatorAny",today:"operatorToday",week:"operatorWeek",month:"operatorMonth",in:"operatorIn"};return t[e]?this.text(t[e]):e}renderFilterSettingsContextMenu(e){const{x:t,y:n,position:s,columnCount:i,columnsCount:r,transform:a}=e;let o=`translateX(${void 0!==a?a:0}%)`;const l=this.getPendingFilterState(),c=this.countPendingFilterConditionChanges(),u=l.selectedTemplateKey,d=this.getSortedFilterTemplates(l),h=d.map(e=>{let t;const n=this.state.filter.rename===e.key;if(this.state.filter.rename!==e.key){const n={type:"radio",props:{size:this.size,label:e.label||this.text("untitledTemplateText"),name:"filter_templates",checked:u?u===e.key:e.selected||!1,"@change":()=>{this.selectTempFilterTemplate(e.key)}}};t=this.renderSmartElement(n.type,n.props)}else t=p.html`
782
+ `}getFilterOperatorLabel(e){const t={eq:"operatorEq",gt:"operatorGt",gte:"operatorGte",lt:"operatorLt",lte:"operatorLte",between:"operatorBetween",contains:"operatorContains",startsWith:"operatorStartsWith",any:"operatorAny",today:"operatorToday",week:"operatorWeek",month:"operatorMonth",in:"operatorIn"};return t[e]?this.text(t[e]):e}renderFilterSettingsContextMenu(e){const{x:t,y:n,position:s,columnCount:i,columnsCount:r,transform:a}=e;let o=`translateX(${void 0!==a?a:0}%)`;const l=this.getPendingFilterState(),c=this.countPendingFilterConditionChanges(),u=l.selectedTemplateKey,d=this.getSortedFilterTemplates(l),h=d.map(e=>{let t;const n=this.state.filter.rename===e.key;if(this.state.filter.rename!==e.key){const n={type:"radio",props:{size:this.size,label:e.label||this.text("untitledTemplateText"),name:"filter_templates",checked:u?u===e.key:e.selected||!1,"@change":()=>{this.selectTempFilterTemplate(e.key)}}};t=this.renderSmartElement(n.type,n.props)}else t=f.html`
783
783
  <div class="flex items-cross-center gap-1/4 flex-1">
784
- <sf-input size=${this.size} ${(0,m.ref)(this.refs.renameInput)} root-class="flex-1"
784
+ <sf-input size=${this.size} ${(0,g.ref)(this.refs.renameInput)} root-class="flex-1"
785
785
  default-value="${e.label}"></sf-input>
786
786
  <div class="flex items-cross-center flex-none">
787
787
  <sf-button-icon size=${this.size} segment="start" appearance="outline" scheme="on-surface" @click="${()=>{this.set(e=>({filter:{...e.filter||{},rename:""}}))}}"
788
788
  icon="close"></sf-button-icon>
789
789
  <sf-button-icon size=${this.size} segment="end" icon="check" @click="${()=>{const t=this.refs.renameInput.value?.value;this.saveFilterTemplatePatch(e.key,{label:t},{filterPatch:{rename:""},saveInputValue:t})}}"></sf-button-icon>
790
790
  </div>
791
- </div>`;return p.html`
791
+ </div>`;return f.html`
792
792
  <div
793
793
  :key=${e.key}
794
- ${(0,m.ref)(this.getItemRef(e.label))}
794
+ ${(0,g.ref)(this.getItemRef(e.label))}
795
795
  class="sf-settings-context-menu-item flex items-cross-center flex-1 gap-1/3 ${e.deleted?"opacity-3":""}"
796
796
  data-filter-template-key="${e.key}"
797
797
  data-sf-sortable-item=${e.key}
798
798
  data-pinned="${e.pinned?"1":"0"}"
799
799
  >
800
- ${n?p.nothing:p.html`
800
+ ${n?f.nothing:f.html`
801
801
  <sf-button-icon size=${this.size}
802
802
  id="${this.getInstanceId()}--template-move--${e.key}"
803
803
  appearance="link"
@@ -809,7 +809,7 @@
809
809
  root-class="cursor-move"
810
810
  ></sf-button-icon>`}
811
811
  ${t}
812
- ${n?p.nothing:p.html`
812
+ ${n?f.nothing:f.html`
813
813
  <div class="flex items-cross-center m-inline-start-auto gap-1/3">
814
814
  <sf-button-icon
815
815
  appearance="link"
@@ -832,7 +832,7 @@
832
832
  @click=${t=>{this.openContextSubmenu(t,{type:"filter-template-actions",template:e})}}
833
833
  ></sf-button-icon>
834
834
  </div>`}
835
- </div>`}),f=i??r??this.contextMenuColumns??1,g=this.getFilterTagColsData(),b=this.splitItemsByColumns(g,f);let y=`${this.text("templatesTabText")}|${this.text("fieldsTabText")}`;return p.html`
835
+ </div>`}),p=i??r??this.contextMenuColumns??1,m=this.getFilterTagColsData(),b=this.splitItemsByColumns(m,p);let y=`${this.text("templatesTabText")}|${this.text("fieldsTabText")}`;return f.html`
836
836
  <sf-menu-context
837
837
  size=${"1/2"===this.size?"1/2":"1"}
838
838
  :key=${t+n+this._renderToken}
@@ -859,15 +859,15 @@
859
859
  bottom, and the window keeps its width -- it grew under
860
860
  the pointer when «Применить (2)» got longer. -->
861
861
  <div class="sf-table-context-body flex flex-col flex-1" slot="content">
862
- ${"fields"!==this._filterTab?p.html`
862
+ ${"fields"!==this._filterTab?f.html`
863
863
  <div
864
864
  class="sf-context-menu-columns flex flex-col gap-1/4 overflow-auto flex-1"
865
865
  data-filter-template-list
866
866
  >
867
867
  ${this.renderSortableGroups(h.filter((e,t)=>d[t].pinned),h.filter((e,t)=>!d[t].pinned),{name:"filter-templates",label:this.text("templatesTabText"),onIntent:e=>this.onFilterTemplateIntent(e)})}
868
- </div>`:p.html`
868
+ </div>`:f.html`
869
869
  <div class="sf-context-menu-columns flex flex-1 gap-1 overflow-auto">
870
- ${b.map(e=>p.html`
870
+ ${b.map(e=>f.html`
871
871
  <div class="flex flex-col gap-1 flex-1">
872
872
  ${e}
873
873
  </div>
@@ -880,7 +880,7 @@
880
880
  aria-label=${c?`${this.text("filterApplyText","filter-apply-text")}: ${c}`:this.text("filterApplyText","filter-apply-text")}
881
881
  text=${c?`${this.text("filterApplyText","filter-apply-text")} (${c})`:this.text("filterApplyText","filter-apply-text")}></sf-button>
882
882
  </sf-menu-context>
883
- `}renderTagsSettingsContextMenu(e){const{x:t,y:n,position:s,fieldKey:i}=e,r=this.getFilterField(i)||{key:i,label:this.getCurrentFilterTags()?.[i]?.label||i||"",filter:{control:this.getCurrentFilterTags()?.[i]?.control||"text"}};return p.html`
883
+ `}renderTagsSettingsContextMenu(e){const{x:t,y:n,position:s,fieldKey:i}=e,r=this.getFilterField(i)||{key:i,label:this.getCurrentFilterTags()?.[i]?.label||i||"",filter:{control:this.getCurrentFilterTags()?.[i]?.control||"text"}};return f.html`
884
884
  <sf-menu-context
885
885
  size=${"1/2"===this.size?"1/2":"1"}
886
886
  :key=${t+n+this._renderToken}
@@ -909,7 +909,7 @@
909
909
  </div>
910
910
  </div>
911
911
  </sf-menu-context>
912
- `}removeFilterTag(e=null){return e?(this.tempSettings=null,this.set(t=>{const n=t.filter||{},s={...this.getCurrentFilterTags(n)},i={...this.getCurrentFilterValues(n)};return delete s[e],delete i[e],{filter:this.patchFilterTemplateData(n,{tags:s,values:i}),filterDataDirty:!0}},()=>{const e=this.filterUpdate();this.emitTableEvent("filter-change",e)}),this):(this.tempSettings=null,this.set(e=>{const t=e.filter||{};return{filter:{...t,selectedTemplateKey:"",templates:this.getFilterTemplates(t).map(e=>({...e,selected:!1}))},saveInputValue:"",filterDataDirty:!1}},()=>{const e=this.filterUpdate();this.emitTableEvent("filter-change",e)}),this)}renderTableSettingsContextMenu(e){const{x:t,y:n,position:s,transform:i,columnCount:r,columnsCount:a}=e;let o=`translateX(${void 0!==i?i:0}%)`;r??a??this.contextMenuColumns;const l=this.getTableColsData(),c=this.getTableColsData("pinned"),u=this.getTableColsData("loose"),d=this.state.columnSettingsQuery||"";return p.html`
912
+ `}removeFilterTag(e=null){return e?(this.tempSettings=null,this.set(t=>{const n=t.filter||{},s={...this.getCurrentFilterTags(n)},i={...this.getCurrentFilterValues(n)};return delete s[e],delete i[e],{filter:this.patchFilterTemplateData(n,{tags:s,values:i}),filterDataDirty:!0}},()=>{const e=this.filterUpdate();this.emitTableEvent("filter-change",e)}),this):(this.tempSettings=null,this.set(e=>{const t=e.filter||{};return{filter:{...t,selectedTemplateKey:"",templates:this.getFilterTemplates(t).map(e=>({...e,selected:!1}))},saveInputValue:"",filterDataDirty:!1}},()=>{const e=this.filterUpdate();this.emitTableEvent("filter-change",e)}),this)}renderTableSettingsContextMenu(e){const{x:t,y:n,position:s,transform:i,columnCount:r,columnsCount:a}=e;let o=`translateX(${void 0!==i?i:0}%)`;r??a??this.contextMenuColumns;const l=this.getTableColsData(),c=this.getTableColsData("pinned"),u=this.getTableColsData("loose"),d=this.state.columnSettingsQuery||"";return f.html`
913
913
  <sf-menu-context
914
914
  size=${"1/2"===this.size?"1/2":"1"}
915
915
  :key=${t+n+this._renderToken}
@@ -936,7 +936,7 @@
936
936
  stays while the rows scroll, and its width is its own.
937
937
  Esc, a click outside and the gear again close it too. -->
938
938
  <div class="sf-table-context-body flex flex-col flex-1" slot="content">
939
- ${"view"===this._settingsTab?this.renderTableViewSettings():p.html`
939
+ ${"view"===this._settingsTab?this.renderTableViewSettings():f.html`
940
940
  <!-- The search: a site can have hundreds of fields, and
941
941
  scrolling for one is not an answer. -->
942
942
  <label class="sf-table-column-search flex flex-col">
@@ -953,7 +953,7 @@
953
953
  </label>
954
954
  <div class="sf-context-menu-columns flex flex-col flex-1 gap-1/3 overflow-auto"
955
955
  data-column-settings-list>
956
- ${l.length?this.renderSortableGroups(c,u,{name:"table-columns",label:this.text("settingsColumnLabel"),onIntent:e=>this.onColumnSettingsIntent(e)}):p.html`<div class="sf-table-column-empty p-1 color-on-surface-variant">
956
+ ${l.length?this.renderSortableGroups(c,u,{name:"table-columns",label:this.text("settingsColumnLabel"),onIntent:e=>this.onColumnSettingsIntent(e)}):f.html`<div class="sf-table-column-empty p-1 color-on-surface-variant">
957
957
  ${this.text("columnSearchEmptyText","column-search-empty-text")}
958
958
  </div>`}
959
959
  </div>
@@ -970,14 +970,14 @@
970
970
  text=${"view"===this._settingsTab?this.text("viewReset"):this.text("resetText")}
971
971
  @click=${()=>"view"===this._settingsTab?this.resetTableView():this.restoreColumnSettingsOnOpen()}></sf-button>
972
972
  </sf-menu-context>
973
- `}renderTableViewSettings(){const e=this.tableView,t="1/2"===this.size?"1/2":"1",n=!0===this._viewEverywhere,s={compact:"viewDensityCompact",normal:"viewDensityNormal",spacious:"viewDensitySpacious"},i=(s,i)=>p.html`<label class="sf-table-settings-row" data-view-option=${s}>
973
+ `}renderTableViewSettings(){const e=this.tableView,t="1/2"===this.size?"1/2":"1",n=!0===this._viewEverywhere,s={compact:"viewDensityCompact",normal:"viewDensityNormal",spacious:"viewDensitySpacious"},i=(s,i)=>f.html`<label class="sf-table-settings-row" data-view-option=${s}>
974
974
  <sf-checkbox size=${t} ?checked=${!0===e[s]}
975
975
  @change=${e=>this.setTableView({[s]:Boolean(e.target?.checked??e.detail?.checked)},{everywhere:n})}></sf-checkbox>
976
- <span>${this.text(i)}</span></label>`;return p.html`
976
+ <span>${this.text(i)}</span></label>`;return f.html`
977
977
  <div class="sf-table-view-settings flex flex-col flex-1 gap-1/3" data-table-view-settings>
978
978
  <div class="sf-table-settings-heading">${this.text("viewDensity")}</div>
979
979
  <div role="radiogroup" aria-label=${this.text("viewDensity")} class="flex flex-col">
980
- ${["compact","normal","spacious"].map(i=>p.html`<label class="sf-table-settings-row" data-view-density=${i}>
980
+ ${["compact","normal","spacious"].map(i=>f.html`<label class="sf-table-settings-row" data-view-density=${i}>
981
981
  <sf-radio size=${t} name=${`${this.getInstanceId()}-density`} value=${i} ?checked=${e.density===i}
982
982
  @change=${()=>this.setTableView({density:i},{everywhere:n})}></sf-radio>
983
983
  <span>${this.text(s[i])}</span></label>`)}
@@ -985,11 +985,11 @@
985
985
  ${i("stripes","viewStripes")}
986
986
  ${i("lines","viewLines")}
987
987
  ${i("singleLine","viewSingleLine")}
988
- ${"page"===this.getAttribute("vertical-scroll")?i("stickyHead","viewStickyHead"):p.nothing}
989
- ${this.viewPreferenceKey?p.html`<div class="sf-table-settings-separator" role="separator"></div>
990
- ${((e,t)=>p.html`<div class="sf-table-settings-row">${t}<span>${e}</span></div>`)(this.text("viewEverywhere"),p.html`<sf-checkbox size=${t} data-view-everywhere ?checked=${n}
991
- @change=${e=>{this._viewEverywhere=Boolean(e.target?.checked??e.detail?.checked),this.requestComponentUpdate("view-everywhere")}}></sf-checkbox>`)}`:p.nothing}
992
- </div>`}renderMainContextMenu(e){switch(e.menu||e.menuType||e.contextMenu){case"row-settings":return this.renderRowSettingsContextMenu(e);case"create":return this.renderCreateContextMenu(e);case"list-sort":return this.renderListSortContextMenu(e);case"toolbar-actions":return this.renderToolbarActionsContextMenu(e);case"filter-favorites":return this.renderFilterFavoritesContextMenu(e);case"filter-settings":return this.renderFilterSettingsContextMenu(e);case"table-settings":return this.renderTableSettingsContextMenu(e);case"tag-settings":return this.renderTagsSettingsContextMenu(e);default:return"left"===e.type?this.renderRowSettingsContextMenu(e):this.renderTableSettingsContextMenu(e)}}renderTemplateActionsContextSubmenu(e){const{x:t,y:n,position:s,transform:i,template:r={}}=e;let a=`translateY(${void 0!==i?i:0}%)`;const o=this.getFilterTemplateByKey(r.key,this.tempSettings?.filter||null);let l=(o||r).deleted;const c=!0===(o||r).default;return p.html`
988
+ ${"page"===this.getAttribute("vertical-scroll")?i("stickyHead","viewStickyHead"):f.nothing}
989
+ ${this.viewPreferenceKey?f.html`<div class="sf-table-settings-separator" role="separator"></div>
990
+ ${((e,t)=>f.html`<div class="sf-table-settings-row">${t}<span>${e}</span></div>`)(this.text("viewEverywhere"),f.html`<sf-checkbox size=${t} data-view-everywhere ?checked=${n}
991
+ @change=${e=>{this._viewEverywhere=Boolean(e.target?.checked??e.detail?.checked),this.requestComponentUpdate("view-everywhere")}}></sf-checkbox>`)}`:f.nothing}
992
+ </div>`}renderMainContextMenu(e){switch(e.menu||e.menuType||e.contextMenu){case"row-settings":return this.renderRowSettingsContextMenu(e);case"create":return this.renderCreateContextMenu(e);case"list-sort":return this.renderListSortContextMenu(e);case"toolbar-actions":return this.renderToolbarActionsContextMenu(e);case"filter-favorites":return this.renderFilterFavoritesContextMenu(e);case"filter-settings":return this.renderFilterSettingsContextMenu(e);case"table-settings":return this.renderTableSettingsContextMenu(e);case"tag-settings":return this.renderTagsSettingsContextMenu(e);default:return"left"===e.type?this.renderRowSettingsContextMenu(e):this.renderTableSettingsContextMenu(e)}}renderTemplateActionsContextSubmenu(e){const{x:t,y:n,position:s,transform:i,template:r={}}=e;let a=`translateY(${void 0!==i?i:0}%)`;const o=this.getFilterTemplateByKey(r.key,this.tempSettings?.filter||null);let l=(o||r).deleted;const c=!0===(o||r).default;return f.html`
993
993
  <sf-menu-context
994
994
  size=${"1/2"===this.size?"1/2":"1"}
995
995
  :key=${`${r.key||""}-${t}-${n}`}
@@ -1008,23 +1008,23 @@
1008
1008
  @sf-menu-context-select=${e=>{const t=e.detail?.id;"rename"===t?this.set(e=>({filter:{...e.filter||{},rename:r.key},contextMenu:{...e.contextMenu||{},submenu:null}})):"default"===t?(this.changeTempFilterTemplateSettings(r.key,{default:!r.default}),this.closeContextSubmenu()):"delete"===t&&this.patchTempFilterTemplateSettings(r.key,{deleted:!l})}}
1009
1009
  >
1010
1010
  </sf-menu-context>
1011
- `}renderContextSubmenu(e){return"filter-template-actions"===e?.type?this.renderTemplateActionsContextSubmenu(e):p.nothing}renderContextMenu(e){return e?.open&&globalThis.SF?.Loader?.ensure?.("tag-settings"===e.menu?["sf-input-date","sf-slider-range"]:["sf-sortable","sf-radio","sf-tabs"]),e?.open?((0,p.render)(p.html`
1011
+ `}renderContextSubmenu(e){return"filter-template-actions"===e?.type?this.renderTemplateActionsContextSubmenu(e):f.nothing}renderContextMenu(e){return e?.open&&globalThis.SF?.Loader?.ensure?.("tag-settings"===e.menu?["sf-input-date","sf-slider-range"]:["sf-sortable","sf-radio","sf-tabs"]),e?.open?((0,f.render)(f.html`
1012
1012
  <div
1013
1013
  class="sf-table-context-layer"
1014
- data-sf-sheet=${this.isList&&["filter-settings","tag-settings"].includes(e.menu)?"":p.nothing}
1015
- ${(0,m.ref)(this.refs.contextMenu)}
1014
+ data-sf-sheet=${this.isList&&["filter-settings","tag-settings"].includes(e.menu)?"":f.nothing}
1015
+ ${(0,g.ref)(this.refs.contextMenu)}
1016
1016
  @click=${e=>this.handleContextLayerClick(e)}
1017
1017
  >
1018
1018
  ${this.renderMainContextMenu(e)}
1019
- ${e.submenu?.open?this.renderContextSubmenu(e.submenu):p.nothing}
1020
- ${this.isList&&["filter-settings","tag-settings"].includes(e.menu)?p.html`
1019
+ ${e.submenu?.open?this.renderContextSubmenu(e.submenu):f.nothing}
1020
+ ${this.isList&&["filter-settings","tag-settings"].includes(e.menu)?f.html`
1021
1021
  <div class="sf-table-sheet-close">
1022
1022
  <sf-button-icon size=${this.size} appearance="link" scheme="on-surface"
1023
1023
  icon="close" aria-label=${this.text("closeText")}
1024
1024
  @click=${()=>this.closeContextMenu()}></sf-button-icon>
1025
- </div>`:p.nothing}
1025
+ </div>`:f.nothing}
1026
1026
  </div>
1027
- `,this.getPortalContainer()),this.showPortal(),this.bindContextEvent(),this.bindContextViewport(),requestAnimationFrame(()=>{this.clampContextMenusToViewport(),this.redrawWhenComponentsUpgrade(this.getPortalContainer())}),p.nothing):((0,p.render)(null,this.getPortalContainer()),this.hidePortal(),p.nothing)}getActionItems(){return this.state.actions.map(e=>{const t={type:"checkbox",props:{size:this.size,label:e.name,position:"end",rootClass:"content-main-between",checked:e.visible,"@change":t=>{let n=!1;const s=(this.tempSettings&&this.tempSettings.actions?this.tempSettings.actions:this.state.actions).map(s=>{let i=s.id===e.id?t.target.checked:s.visible;return i&&(n=!0),{...s,visible:i}});this.tempSettings={...this.tempSettings||{},actionActive:n,actions:s}}}};return this.renderSmartElement(t.type,t.props)})}hoverEvents(e){if(this._columnResizeState||this.columnDragActive)return;const t=e.target.closest("th");if(!t)return;t.querySelector(".sidebar-resizer")&&(t.classList.add("hover"),this.getColumnResizeHandle(e.target)?this.showColumnResizeGuide(t):this.hideColumnResizeGuide())}outEvent(e){if(this._columnResizeState||this.columnDragActive)return;const t=e.target.closest("th");if(!t)return;t.querySelector(".sidebar-resizer")&&(t.classList.remove("hover"),this.hideColumnResizeGuide())}showColumnResizeGuide(e){const t=this.refs.resizeGuide?.value,n=this.refs.scroll?.value,s=this.refs.table?.value;if(!(t&&n&&e&&s))return;const i=s.querySelector("thead"),r=s.querySelector("tbody");if(!i||!r)return void this.hideColumnResizeGuide();const a=n.getBoundingClientRect(),o=e.getBoundingClientRect(),l=i.getBoundingClientRect(),c=r.getBoundingClientRect();if(c.height<=0)return void this.hideColumnResizeGuide();const u=parseFloat(getComputedStyle(e).borderInlineEndWidth)||0,d=this.isRightToLeft()?o.left-a.left+n.scrollLeft:o.right-a.left+n.scrollLeft-u;t.style.insetInlineStart=`${d}px`,t.style.insetBlockStart=`${l.bottom-a.top+n.scrollTop}px`,t.style.blockSize=`${c.height}px`,t.hidden=!1}hideColumnResizeGuide(){const e=this.refs.resizeGuide?.value;e&&(e.hidden=!0)}isRightToLeft(){return"rtl"===getComputedStyle(this).direction}bindHoverEvent(){if(this._hoverEventBound)return;this._hoverEventBound=!0;const e=this.refs.table?.value;e?.addEventListener("mouseover",this.hoverEvents),e?.addEventListener("mouseout",this.outEvent)}unBindHoverEvent(){if(!this._hoverEventBound)return;const e=this.refs.table?.value;e?.removeEventListener("mouseover",this.hoverEvents),e?.removeEventListener("mouseout",this.outEvent),this._hoverEventBound=!1}bindColumnResizeEvent(){const e=this.refs.table?.value;if(!e||this._columnResizeTable===e)return;const t=globalThis.SF?.Resizer?.attach;"function"==typeof t?(this._columnResizeDetach?.(),this._columnResizeTable=e,this._columnResizeDetach=t(e,{handles:".sf-table-column-resizer",session:e=>this.columnResizeSession(e)})):globalThis.SF?.Loader?.ensure?.(["sf-resizer"],{timeout:1/0}).then(({missing:e})=>{!e.length&&this.isConnected&&this.bindColumnResizeEvent()})}unbindColumnResizeEvent(){this._columnResizeDetach?.(),this._columnResizeDetach=null,this._columnResizeTable=null}columnResizeSession(e){const t=e?.closest?.("th"),n=t?.dataset?.key,s=n?this.getColumns().find(e=>e?.key===n):null;if(!t||!s||s.system||!1===s.resizable)return null;const i=this.refs.table?.value,r=i?.querySelector(`col[data-key="${this.escapeColumnKey(n)}"]`),a={key:n,th:t,col:r,frozenWidths:null,dragging:!1},o=()=>{this._columnResizeState=null,t.style.width=""};return{measure:()=>t.getBoundingClientRect().width,limits:()=>{const{minWidth:e,maxWidth:n}=this.getColumnResizeLimits(s,t.getBoundingClientRect().width);return{min:e,max:n}},direction:()=>i&&"rtl"===getComputedStyle(i).direction?-1:1,step:this.resolveCssLength(getComputedStyle(this).getPropertyValue("--sf-space-1"),16),start:()=>{a.dragging=!0,this._columnResizeState=a,(0,b.J)(!0),document.documentElement.classList.add("sf-table-column-resizing")},apply:e=>(a.frozenWidths??=this.freezeColumnsWidthForResize(i),this._columnResizeState=a,r&&(r.style.width=`${e}px`),t.style.width=`${e}px`,this.showColumnResizeGuide(t),e),commit:e=>{const t=a.frozenWidths??{};o(),this.applyColumnResizeWidths(n,e,t)},end:()=>{document.documentElement.classList.remove("sf-table-column-resizing"),(0,b.J)(!1),this.suppressNextHeaderClick(),o(),this.hideColumnResizeGuide()},reset:()=>{o(),this.resetColumnWidth(n)}}}get rememberedWidthsKey(){return this.viewPreferenceKey?this.viewPreferenceKey:this.hasAttribute("remember-widths")?k(this.getTableSettingsKey()||this.id||globalThis.location?.pathname||"table"):""}readRememberedWidths(){const e=this.rememberedWidthsKey;if(!e)return{};const t=S()?.read(e)?.widths;return t&&"object"==typeof t?t:{}}writeTablePreference(e,t){e&&S()?.write(e,{...S()?.read(e)??{},v:1,...t})}storeRememberedWidths(e={}){this.writeTablePreference(this.rememberedWidthsKey,{widths:{...this.readRememberedWidths(),...e}})}forgetRememberedWidth(e){const t=this.readRememberedWidths();delete t[e],this.writeTablePreference(this.rememberedWidthsKey,{widths:t})}get viewPreferenceKey(){const e=this.getAttribute("preferences-key")||this.getAttribute("table-settings-key")||"";return e?k(e):""}applyTablePreference(e,{render:t=!1}={}){const n=e?.columnSettings;if(!n||"object"!=typeof n)return!1;const s=this.getTableData().columnSettings,i=s&&"object"==typeof s&&!Array.isArray(s)?s:{},r=this.mergeColumnSettings(i,n);return t?this.setColumnSettings(r,"preferences",!1):this.state.columnSettings=r,!0}connectTablePreference(){const e=this.viewPreferenceKey;if(e===this._preferenceKeyBound)return;if(this._preferenceUnsubscribe?.(),this._preferenceKeyBound=e,this._preferenceUnsubscribe=null,this.applyTableView(),!e)return;this.applyTablePreference(S()?.read(e));const t=S()?.subscribe(e,e=>{if(e)this.applyTablePreference(e,{render:!0});else{const e=this.getTableData().columnSettings;this.setColumnSettings(e&&"object"==typeof e&&!Array.isArray(e)?{...e}:{},"preferences",!1)}this.applyTableView()}),n=S()?.subscribe(T,()=>this.applyTableView());this._preferenceUnsubscribe=()=>{t?.(),n?.()}}get tableView(){const e=this.viewPreferenceKey,t=S()?.read(T)?.view??{},n=e?S()?.read(e)?.view??{}:this._sessionView??{};return{..._,...t,...n}}applyTableView(){const e=this.tableView,t=(e,t)=>t?this.setAttribute(e,""):this.removeAttribute(e);"normal"===e.density?this.removeAttribute("data-sf-view-density"):this.setAttribute("data-sf-view-density",e.density),t("data-sf-view-stripes",!0===e.stripes),t("data-sf-view-lines",!0===e.lines),t("data-sf-view-single-line",!0===e.singleLine);const n="page"===this.getAttribute("vertical-scroll")&&!this.isList;t("data-sf-page-scroll",n),t("data-sf-sticky-head",n&&!1!==e.stickyHead)}syncStickyHead(){const e=this.refs.table?.value,t=e?.tHead;if(!t)return;let n=0;if(this.hasAttribute("data-sf-sticky-head")&&e.isConnected){const s=A(this.refs.scroll?.value?.parentElement??this),i=s?s.getBoundingClientRect().top:0,r=this.querySelector(":scope > .sf-table > .sf-table-toolbar"),a=Math.max(i,r?r.getBoundingClientRect().bottom:i),o=e.getBoundingClientRect(),l=o.height-t.offsetHeight;n=Math.round(Math.min(Math.max(a-o.top,0),Math.max(l,0)))}t.style.transform=n?`translateY(${n}px)`:"",this.toggleAttribute("data-sf-head-stuck",n>0)}syncRail(){const e=this.refs.rail?.value,t=this.refs.scroll?.value;if(!e||!t)return;const n=t.scrollWidth>t.clientWidth+1;e.hidden=!n;const s=e.firstElementChild;if(s&&(s.style.inlineSize=`${t.scrollWidth}px`),e._sfBound!==t){e._sfBound=t;let n=!1;const s=(e,t)=>()=>{n||(n=!0,t.scrollLeft=e.scrollLeft,n=!1)};t.addEventListener("scroll",s(t,e),{passive:!0}),e.addEventListener("scroll",s(e,t),{passive:!0}),this._railObserver?.disconnect(),"undefined"!=typeof ResizeObserver&&(this._railObserver=new ResizeObserver(()=>this.syncRail()),this._railObserver.observe(t),this.refs.table?.value&&this._railObserver.observe(this.refs.table.value))}n&&(e.scrollLeft=t.scrollLeft)}bindPageScroll(){if(this._pageScrollAbort)return;this._pageScrollAbort=new AbortController;const{signal:e}=this._pageScrollAbort,t=()=>{this._pageScrollFrame||(this._pageScrollFrame=requestAnimationFrame(()=>{this._pageScrollFrame=0,this.isConnected&&this.syncStickyHead()}))};document.addEventListener("scroll",t,{capture:!0,passive:!0,signal:e}),globalThis.addEventListener("resize",()=>{t(),this.syncRail()},{passive:!0,signal:e})}unbindPageScroll(){this._railObserver?.disconnect(),this._railObserver=null;const e=this.refs.rail?.value;e&&(e._sfBound=null),this._pageScrollAbort?.abort(),this._pageScrollAbort=null,cancelAnimationFrame(this._pageScrollFrame??0),this._pageScrollFrame=0}setTableView(e={},{everywhere:t=!1}={}){const n=this.viewPreferenceKey;if(t||!n){if(t){const t=S()?.read(T)??{};S()?.write(T,{...t,v:1,view:{...t.view??{},...e}})}if(n){const t={...S()?.read(n)?.view??{}};for(const n of Object.keys(e))delete t[n];this.writeTablePreference(n,{view:t})}else t||(this._sessionView={...this._sessionView??{},...e})}else this.writeTablePreference(n,{view:{...S()?.read(n)?.view??{},...e}});return this.applyTableView(),this.requestComponentUpdate("table-view"),this.emitTableEvent("view-change",Object.freeze({view:this.tableView,everywhere:t})),this}resetTableView(){const e=this.viewPreferenceKey;return e&&this.writeTablePreference(e,{view:{}}),this._sessionView=null,this.applyTableView(),this.requestComponentUpdate("table-view"),this}restoreRememberedWidths(){const e=this.readRememberedWidths(),t=new Set((this.getColumns?.()??[]).map(e=>e?.key)),n=Object.fromEntries(Object.entries(e).filter(([e,n])=>t.has(e)&&"string"==typeof n).map(([e,t])=>[e,{width:t}]));Object.keys(n).length&&this.patchColumnSettingsBatch(n,"column-widths-restore")}resetColumnWidth(e){return e?(this.forgetRememberedWidth(e),this.patchColumnSettingsBatch({[e]:{width:null}},"column-resize-reset")):this}get columnDragActive(){return document.documentElement.hasAttribute("data-sf-sortable-active")}bindColumnDragEvent(){const e=this.refs.table?.value,t=e?.tHead?.rows?.[0];if(!t||this._headerSortableRow===t)return;const n=globalThis.SF?.Sortable?.attach;"function"==typeof n?(this._headerSortableDetach?.(),this._headerSortableRow=t,this._headerSortableDetach=n(t,{items:"th[data-key]",extent:e,preview:"line",label:this.text("settingsColumnLabel"),groupOf:e=>this.headerColumnGroup(e.dataset.key),canStart:(e,t)=>!this._columnResizeState&&!this.getColumnResizeHandle(e.target)&&["pinned","loose"].includes(this.headerColumnGroup(t.dataset.key)),cellsOf:t=>[...e.rows].map(e=>e.cells[t.cellIndex]).filter(Boolean),onIntent:e=>this.onHeaderColumnIntent(e)})):globalThis.SF?.Loader?.ensure?.(["sf-sortable"],{timeout:1/0}).then(({missing:e})=>{!e.length&&this.isConnected&&this.bindColumnDragEvent()})}unbindColumnDragEvent(){this._headerSortableDetach?.(),this._headerSortableDetach=null,this._headerSortableRow=null}headerColumnGroup(e){if(this.getSystemColumns().some(t=>String(t.key)===e))return"system";const t=this.getColumns().find(t=>String(t.key)===e);return!t||t.system||!1===t.draggable?"fixed":this.isColumnPinned(t)?"pinned":"loose"}onHeaderColumnIntent({item:e,index:t,group:n}){const s=this.refs.table?.value,i=[...s?.tHead?.rows?.[0]?.cells??[]].map(e=>e.dataset?.key).filter(e=>e&&["pinned","loose","fixed"].includes(this.headerColumnGroup(e))),r=i.filter(t=>t!==e&&this.headerColumnGroup(t)===n),a=i.filter(t=>t!==e),o=r[t],l=r[t-1],c=void 0!==o?a.indexOf(o):void 0!==l?a.indexOf(l)+1:a.length;return a.splice(c,0,e),a.join("|")===i.join("|")?this:this.applyColumnOrder(a,{})}getColumnResizeHandle(e){return e instanceof Element?e.closest("[data-sf-column-resizer]"):null}parseColumnSize(e,t=null){if("number"==typeof e&&Number.isFinite(e))return e;if("string"==typeof e){const t=e.trim();if(/^-?\d+(\.\d+)?px$/.test(t))return parseFloat(t)}return t}resolveCssLength(e,t=0){const n=String(e||"").trim().match(/^(-?\d+(?:\.\d+)?)(px|rem|em)$/);if(!n)return t;const s=Number(n[1]),i=n[2];if("px"===i)return s;const r="rem"===i?document.documentElement:this,a=parseFloat(getComputedStyle(r).fontSize);return Number.isFinite(a)?s*a:t}getColumnResizeLimits(e={},t=0){const n=this.resolveCssLength(getComputedStyle(this).getPropertyValue("--sf-c4"),t),s=this.parseColumnSize(e.minWidth,null)??n,i=this.parseColumnSize(e.maxWidth,1/0);return{minWidth:s,maxWidth:Math.max(i,s)}}hasColumnSize(e={}){return[e.colWidth,e.width,e.size].some(e=>null!=e&&""!==String(e).trim())}escapeColumnKey(e){const t=String(e||"");return"undefined"!=typeof CSS&&"function"==typeof CSS.escape?CSS.escape(t):t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}freezeColumnsWidthForResize(e){const t={};return this.getColumns().forEach(n=>{if(!n?.key)return;const s=String(n.key),i=this.escapeColumnKey(s),r=e?.querySelector(`th[data-key="${i}"]`),a=e?.querySelector(`col[data-key="${i}"]`),o=r?.getBoundingClientRect?.().width||0;if(!o)return;const l=`${Math.round(o)}px`;a&&(a.style.width=l),n.system||this.hasColumnSize(n)||(t[s]=l)}),t}applyColumnResizeWidths(e,t,n={}){if(!e)return this;const s={...n||{},[e]:`${Math.round(t)}px`};this.storeRememberedWidths(s);const i=Object.fromEntries(Object.entries(s).map(([e,t])=>[e,{width:t}]));return this.patchColumnSettingsBatch(i,"column-resize")}reorderColumnDomByKeys(e,t=[]){if(!e||!Array.isArray(t)||!t.length)return;const n=(e,n)=>{if(!e)return;const s=new Set(t);let i=null;for(const t of Array.from(e.children||[])){const e=t?.dataset?.key;if(e&&s.has(e))break;e&&(i=t)}t.forEach(t=>{const s=this.escapeColumnKey(t),r=e.querySelector(`${n}[data-key="${s}"]`);r&&(e.insertBefore(r,i?.nextSibling||e.firstChild),i=r)})};n(e.querySelector("colgroup"),"col"),n(e.tHead?.rows?.[0],"th"),Array.from(e.tBodies||[]).forEach(e=>{Array.from(e.rows||[]).forEach(e=>{n(e,"td")})})}applyColumnOrder(e=[],t={}){if(!Array.isArray(e)||!e.length)return this;const n={},s=this.getColumnOrderSlots(e);return e.forEach((e,i)=>{n[e]={order:s[i]},t?.[e]&&(n[e].width=t[e])}),this.patchColumnSettingsBatch(n,"column-drag")}getColumnOrderSlots(e=[]){const t=(this.getTableData().columns||[]).filter(e=>e?.key&&!e.system),n=(e,t)=>{const n=(this.getColumnSetting(e.key)||{}).order??e.order,s=Number(n);return Number.isFinite(s)?s:10*(t+1)},s=new Map(t.map((e,t)=>[String(e.key),n(e,t)])),i=e.map(e=>s.get(String(e))).filter(e=>Number.isFinite(e)).sort((e,t)=>e-t),r=new Set(i);return i.length!==e.length||r.size!==i.length?e.map((e,t)=>10*(t+1)):i}setColumnResizeClasses(e,t=0){e&&(e.classList.add("is-resizing"),e.classList.toggle("is-resizing-forward",t>=0),e.classList.toggle("is-resizing-backward",t<0),this.showColumnResizeGuide(e),this.measurePinnedColumns())}clearColumnResizeClasses(e){e&&(e.classList.remove("is-resizing","is-resizing-forward","is-resizing-backward"),this.hideColumnResizeGuide(),this.measurePinnedColumns())}bindContextEvent(){this._contextEventBound||(document.addEventListener("click",this.contextEvent),document.addEventListener("keydown",this.contextKeyEvent),this._contextEventBound=!0)}unbindContextEvent(){this._contextEventBound&&(document.removeEventListener("click",this.contextEvent),document.removeEventListener("keydown",this.contextKeyEvent),this._contextEventBound=!1)}contextKeyEvent(e){"Escape"===e.key&&this.state.contextMenu?.open&&(e.preventDefault(),e.stopPropagation(),this.closeContextMenu(!0))}getPortalContainer(){if(this._portalContainer?.isConnected)return this._portalContainer;const e=document.createElement("form");e.className="sf-table-portal",e.noValidate=!0,e.dataset.tableSettingsKey=this.getTableSettingsKey(),e.dataset.sfInstance=this.getInstanceId(),"function"==typeof e.showPopover&&e.setAttribute("popover","manual"),e.addEventListener("submit",e=>e.preventDefault());for(const t of["change","input"])e.addEventListener(t,e=>e.stopPropagation());return this.insertBefore(e,this.firstChild),globalThis.SF?.Loader?.watch?.(e),this._portalContainer=e,e}showPortal(){const e=this._portalContainer;e?.isConnected&&"function"==typeof e.showPopover&&(e.matches(":popover-open")||e.showPopover())}hidePortal(){const e=this._portalContainer;e?.isConnected&&"function"==typeof e.hidePopover&&e.matches(":popover-open")&&e.hidePopover()}getVisualViewportRect(){const e=window.visualViewport;return{left:e?.offsetLeft||0,top:e?.offsetTop||0,right:(e?.offsetLeft||0)+(e?.width||window.innerWidth),bottom:(e?.offsetTop||0)+(e?.height||window.innerHeight)}}clampContextMenusToViewport(){const e=this._portalContainer;if(!e?.isConnected)return;const t=this.getVisualViewportRect(),n=getComputedStyle(document.documentElement),s=parseFloat(n.getPropertyValue("--sf-space-1/3"))||0,i=new Set;e.querySelectorAll("sf-menu-context").forEach(e=>{if(this.anchorContextMenu(e,t,s))return void i.add(e);const n=Math.max(0,t.right-t.left-2*s),r=Math.max(0,t.bottom-t.top-2*s);e.style.setProperty("--sf-table-context-menu--available-inline-size",`${n}px`),e.style.setProperty("--sf-context-menu-available-inline-size",`${n}px`),e.style.setProperty("--sf-context-menu-available-block-size",`${r}px`),e.style.translate="";const a=(e.querySelector(":scope > .sf-context-menu")||e).getBoundingClientRect();let o=0,l=0;a.left<t.left+s?o=t.left+s-a.left:a.right>t.right-s&&(o=t.right-s-a.right),a.top<t.top+s?l=t.top+s-a.top:a.bottom>t.bottom-s&&(l=t.bottom-s-a.bottom),(o||l)&&(e.style.translate=`${o}px ${l}px`)});for(const[e,t]of this._contextPositions||[])i.has(e)||(t.controller.stop(),this._contextPositions.delete(e))}describeContextAnchor(e){if(!(e instanceof Element))return null;const t=e.closest("[data-item], th[data-key], [id]");if(!t||!this.contains(t))return null;const n=void 0!==t.dataset.item?`[data-item="${this.escapeColumnKey(t.dataset.item)}"]`:t.matches("th[data-key]")?`th[data-key="${this.escapeColumnKey(t.dataset.key)}"]`:`[id="${this.escapeColumnKey(t.id)}"]`,s=e.tagName.toLowerCase();return{selector:n,tag:s,index:t===e?-1:Array.from(t.querySelectorAll(s)).indexOf(e)}}resolveContextAnchor(e){if(e?.anchor instanceof Element&&e.anchor.isConnected)return e.anchor;const t=e?.anchorRef,n=t?this.querySelector(t.selector):null,s=n&&(t.index<0?n:n.querySelectorAll(t.tag)[t.index]);return s?(e.anchor=s,s):null}getContextMenuPlacement(e){const t=e.hasAttribute("data-context-submenu"),n=t?this.state.contextMenu?.submenu:this.state.contextMenu,s=this.resolveContextAnchor(n);if(!s)return null;const i=String(n.position||(t||"left"===n.type?"left":"")),r=/^(left|right)(-top|-bottom)?$/.exec(i);if(!r){return{anchor:s,side:"block-end",align:["create","toolbar-actions"].includes(n.menu)?"end":"start",tail:null}}const a=r[2]||"";return{anchor:s,side:"left"===r[1]?"inline-end":"inline-start",align:"-top"===a?"start":"-bottom"===a?"end":"center",tail:a}}anchorContextMenu(e,t,n){const s=this.getContextMenuPlacement(e);if(!s)return!1;const i=e.querySelector(":scope > .sf-context-menu");if(!i)return!1;this._contextPositions=this._contextPositions||new Map;const r=this._contextPositions.get(e),a=r?.cssCap??(parseFloat(getComputedStyle(i).maxWidth)||1/0),o=`${Math.max(0,Math.min(t.right-t.left-2*n,a))}px`;i.style.setProperty("--sf-table-context-menu--available-inline-size",o),i.style.setProperty("--sf-context-menu-available-inline-size",o);const l=`${s.side}|${s.align}`;if(r&&r.anchor===s.anchor&&r.surface===i&&r.key===l)return r.controller.update(),!0;r?.controller.stop(),i.style.transform="none",i.style.translate="none",i.style.setProperty("--sf-context-menu-available-block-size",`${Math.max(0,t.bottom-t.top-2*n)}px`);const c=E(),u=null===s.tail?c.resolveLength("calc(var(--sf-focus-outline-width) * 2)",i):c.resolveLength("var(--sf-context-menu-tail-corner-offset)",i),d=s.anchor.getBoundingClientRect(),h=c.anchor(s.anchor,i,{side:s.side,align:s.align,offset:u,alignmentOffset:"center"===s.align||null===s.tail?0:Math.max(0,d.height/2-u),padding:n,fitHeight:!1,onPosition:({side:t})=>{const r=s.anchor.getBoundingClientRect(),a=this.getVisualViewportRect(),o="block-end"===t?a.bottom-n-r.bottom-u:"block-start"===t?r.top-u-n-a.top:a.bottom-a.top-2*n,l=`${Math.max(0,Math.floor(o))}px`;if(i.style.getPropertyValue("--sf-context-menu-available-block-size")!==l&&i.style.setProperty("--sf-context-menu-available-block-size",l),null!==s.tail){const n=`${"inline-end"===t?"left":"right"}${s.tail}`;e.getAttribute("position")!==n&&e.setAttribute("position",n)}}});return this._contextPositions.set(e,{controller:h,anchor:s.anchor,surface:i,key:l,cssCap:a}),document.fonts?.ready?.then(()=>{this._contextPositions?.get(e)?.controller===h&&h.update()}).catch(()=>{}),!0}stopContextMenuPositions(){for(const e of this._contextPositions?.values()||[])e.controller.stop();this._contextPositions?.clear()}contextViewportEvent(){requestAnimationFrame(()=>this.clampContextMenusToViewport())}bindContextViewport(){this._contextViewportBound||(window.addEventListener("resize",this.contextViewportEvent),window.visualViewport?.addEventListener("resize",this.contextViewportEvent),window.visualViewport?.addEventListener("scroll",this.contextViewportEvent),this._contextViewportBound=!0)}unbindContextViewport(){this._contextViewportBound&&(window.removeEventListener("resize",this.contextViewportEvent),window.visualViewport?.removeEventListener("resize",this.contextViewportEvent),window.visualViewport?.removeEventListener("scroll",this.contextViewportEvent),this._contextViewportBound=!1)}openContextMenu(e,t={}){this.closeContextMenu(!1),this.contextTarget?.classList.remove("active");const n=e.currentTarget instanceof Element?e.currentTarget:e.target instanceof Element?e.target:null;if(!n)return;const s=(e.composedPath?.()||[]).filter(e=>e instanceof Element).map(e=>e.closest?.('button, input, select, textarea, a[href], [role="button"]')).find(e=>e&&(e===n||n.contains(e))),i=e=>{const t=e.getBoundingClientRect();return t.width>0||t.height>0},r=s||i(n)?n:Array.from((n.shadowRoot||n).querySelectorAll?.("*")||[]).find(i)||n;this.contextTarget=s||r,this.contextTarget.classList.add("active");let a=t.anchorSelector&&this.contextTarget.closest?.(t.anchorSelector)||this.contextTarget,o=a.getBoundingClientRect();e.preventDefault(),e.stopPropagation();let l={open:!0,id:this.contextTarget,...t},c={};switch(t.type){case"left":c={x:o.left+o.width,y:o.y+o.height/2};break;case"bottom":{let n=null;t.parent&&(n=(0,g.PA)(e.target),o=n.getBoundingClientRect(),a=n),c={x:o.left,y:o.y+o.height};break}default:c={x:o.left,y:o.y+o.height}}l={...l,...c,anchor:a,anchorRef:this.describeContextAnchor(a)},"table-settings"===l.menu&&(this._columnSettingsOnOpen=JSON.parse(JSON.stringify(this.getColumnSettings()||{}))),this.set({contextMenu:{...l}})}resolveBoxedAnchor(e,t){if(!(t instanceof Element))return t;const n=e=>{const t=e?.getBoundingClientRect?.();return Boolean(t)&&(t.width>0||t.height>0)},s=(e?.composedPath?.()||[]).filter(e=>e instanceof Element).map(e=>e.closest?.('button, input, select, textarea, a[href], [role="button"]')).find(e=>e&&(e===t||t.contains(e)));if(s&&n(s))return s;if(n(t))return t;return Array.from((t.shadowRoot||t).querySelectorAll?.("*")||[]).find(n)||t}redrawWhenComponentsUpgrade(e=this){if(!e?.querySelectorAll)return this;this._awaitedComponents=this._awaitedComponents||new Set;const t=new Set(Array.from(e.querySelectorAll("*")).map(e=>e.tagName.toLowerCase()).filter(e=>e.includes("-")&&!customElements.get(e)));for(const e of t)this._awaitedComponents.has(e)||(this._awaitedComponents.add(e),customElements.whenDefined(e).then(()=>{this.requestComponentUpdate("component-upgrade")}).catch(()=>{}));return this}openContextSubmenu(e,t={}){e.preventDefault(),e.stopPropagation();const n=e.target instanceof Element?e.target:null,s=e.currentTarget instanceof Element?e.currentTarget:n;if(!s)return;const i=this.resolveBoxedAnchor(e,s),r=i.getBoundingClientRect(),a=t.anchorKey||t.template?.key||s.dataset?.contextSubmenuAnchor||"";if(a&&this.state.contextMenu?.submenu?.open&&this.state.contextMenu.submenu.anchorKey===a)return void this.closeContextSubmenu();const o={open:!0,type:t.type,anchorKey:a,x:r.left+r.width,y:r.y+r.height/2,position:t.position||"left",transform:-50,...t,anchor:i,anchorRef:this.describeContextAnchor(i)};this.set(e=>({contextMenu:{...e.contextMenu||{},submenu:o}}))}handleContextLayerClick(e){const t=e.target;t instanceof Element&&(t.closest("[data-context-submenu]")||t.closest("[data-context-submenu-anchor]")||this.state.contextMenu?.submenu?.open&&!t.closest("[data-context-main-menu]")&&this.closeContextSubmenu())}closeContextSubmenu(){this.set(e=>({contextMenu:{...e.contextMenu||{},submenu:null}}))}renderCellElement(e,t={}){const n=(0,s.canonicalTag)(`sf-${String(e??"").replace(/^sf-/u,"")}`);if(!(C.has(n)&&!0!==t.interactive&&!0!==t.closable&&"checkbox"!==t.type&&!Object.keys(t).some(e=>e.startsWith("@")||/^on[A-Z]/u.test(e))?customElements.get(n):null))return this.renderSmartElement(e,t);this._lightCells??=new Map;let i=this._lightCells.get(n);if(i||(i=document.createElement(n),this._lightCells.set(n,i)),"function"!=typeof i.template)return this.renderSmartElement(e,t);for(const e of[...i.getAttributeNames()])i.removeAttribute(e);const r="1"!==this.size&&"1"===String(t.size)?this.size:t.size;for(const[e,n]of Object.entries({...t,...void 0!==r?{size:r}:{}})){if(null==n||!1===n)continue;const t=e.replace(/[A-Z]/gu,e=>`-${e.toLowerCase()}`);"object"==typeof n||"function"==typeof n?i[e]=n:i.setAttribute(t,!0===n?"":String(n))}try{return i.template()}catch{return this.renderSmartElement(e,t)}}renderSmartElement(e,t={}){e=(0,s.canonicalTag)(`sf-${String(e??"").replace(/^sf-/u,"")}`);const n=this.size;return"1"!==n&&t&&"1"===String(t.size)?super.renderSmartElement(e,{...t,size:n}):super.renderSmartElement(e,t)}get size(){return this.getEnumAttr("size",["1/2","1"],"1")}getSelectColumn(){return{...this.TABLE_SELECT_COLUMN,component:{...this.TABLE_SELECT_COLUMN.component,props:{...this.TABLE_SELECT_COLUMN.component?.props||{},checked:Boolean(this.state?.settingsChecked),indeterminate:Boolean(this.state?.selectIndeterminate)}}}}getColumns(){const e=this.getTableData().columns||[],t=this.getSystemColumns(),n=new Set(t.map(e=>e.key)),s=new Set(["actions"]),i=new Map(e.map((e,t)=>[e?.key,t])),r=e.filter(e=>e?.key&&!n.has(e.key)).map(e=>{const t=this.getColumnSetting(e.key),n={...e,...t};return t.width&&(n.colWidth=t.width),n}).sort((e,t)=>{const n=e=>{const t=e?.order;return null!=t&&""!==t&&Number.isFinite(Number(t))?Number(t):i.get(e?.key)??0},s=n(e),r=n(t);return s===r?(i.get(e.key)??0)-(i.get(t.key)??0):s-r}),a=t.filter(e=>!s.has(e?.key)),o=t.filter(e=>s.has(e?.key)),l=[...a,...r.filter(e=>this.isColumnPinned(e)),...r.filter(e=>!this.isColumnPinned(e)),...o].filter(e=>!1!==e?.visible),c=this._responsiveWidth||this.clientWidth||0;if(this.isList||!c||!r.some(e=>void 0!==e.priority))return l;const u=e=>{const t=e.min_width??e.minWidth??e.width,n="number"==typeof t?t:Number.parseFloat(String(t??""));return Number.isFinite(n)&&n>0?n:e.system?48:160},d=new Set(l);let h=l.reduce((e,t)=>e+u(t),0);const p=r.filter(e=>!1!==e.visible).sort((e,t)=>(t.priority??0)-(e.priority??0));for(const e of p){if(h<=c||d.size<=t.length+1)break;d.delete(e),h-=u(e)}return l.filter(e=>d.has(e))}isColumnPinned(e){if(!e?.key)return!1;if("select"===e.key||"settings"===e.key)return!0;if(e.system)return!1;const t=this.tempSettings?.cols?.[e.key],n=this.getColumnSetting(e.key)||{},s=t?.pinned??n.pinned??e.pinned;return"boolean"==typeof s?s:"title"===e.role}getPinnedColumnKeys(e=this.getColumns()){return e.filter(e=>e?.key&&this.isColumnPinned(e)).map(e=>e.key)}isPinnedColumn(e){return!!e?.key&&(!!["start","end"].includes(e.sticky)||this.isColumnPinned(e))}getStickyCellStyle(e,t){const n=e[t];if(!this.isPinnedColumn(n))return"";return`position: sticky; inset-inline-${["start","end"].includes(n.sticky)?n.sticky:"start"}: var(--sf-table-pin-${n.key}, 0px); z-index: 2;`}measurePinnedColumns(){const e=this.refs.table?.value,t=this.refs.scroll?.value;if(!e)return this;const n=this.getPinnedColumnKeys(),s=e.querySelector("thead tr"),i=n.map(e=>{const t=s?.querySelector(`th[data-key="${e}"]`);return t?t.getBoundingClientRect().width:0});let r=0;n.forEach((t,n)=>{const s=`${Math.round(r)}px`;e.style.getPropertyValue(`--sf-table-pin-${t}`)!==s&&e.style.setProperty(`--sf-table-pin-${t}`,s),r+=i[n]});const a=n[n.length-1],o=new Set(a?e.querySelectorAll(`[data-key="${a}"]`):[]);for(const t of e.querySelectorAll("[data-sf-pin-edge]"))o.has(t)||t.removeAttribute("data-sf-pin-edge");for(const e of o)e.hasAttribute("data-sf-pin-edge")||e.setAttribute("data-sf-pin-edge","");if(t){Math.abs(t.scrollLeft)>0?t.setAttribute("data-sf-pin-scrolled",""):t.removeAttribute("data-sf-pin-scrolled")}return this}bindPinnedColumnScroll(){const e=this.refs.scroll?.value;return e&&this._pinnedScrollBound!==e?(this._pinnedScrollBound=e,e.addEventListener("scroll",()=>this.measurePinnedColumns(),{passive:!0}),this):this}getRowSelectLabel(e){const t=this._labelColumnBatch,n=t&&"column"in t?t.column:this.getColumnItems().find(e=>e?.key&&!e.system&&"select"!==e.key&&"settings"!==e.key);t&&(t.column=n);const s=n?e?.[n.key]:void 0,i=null!==s&&"object"==typeof s?s.text??s.label??s.value??"":s,r=String(i??"").trim()||String(e?.id??"").trim();return r?`${this.text("selectRowLabel")}: ${r}`:this.text("selectRowLabel")}createRowComponentCell(e,t={}){return e?.type?{component:{type:e.type,props:{...e.props||{},...t}}}:null}async openRowMenu(e,t={}){const n=e?.currentTarget?.querySelector?.("button")??e?.target?.closest?.("button")??e?.currentTarget;if(!(n instanceof Element))return null;const s=Array.isArray(t.actions)&&t.actions.every(e=>"string"==typeof e)?t.actions:null,i=this.getActionRowItems(t),r=e=>e?.icon??e?.component?.props?.icon??void 0,a=i.map(e=>Array.isArray(e.members)?{id:e.id,text:e.name,icon:r(e),submenu:e.members.filter(e=>!s||s.includes(e.id)).map(e=>({id:e.id,text:e.name,icon:r(e),danger:!0===e.danger}))}:{id:e.id,text:e.name,icon:r(e),danger:!0===e.danger});await(globalThis.SF?.Loader?.ensure?.(["sf-menu-context"]));const o=this.rowMenu();return o.setAttribute("aria-label",this.getContextMenuLabel({row:t,menu:"row-settings"})),o.entries=a,this._rowMenuContext={row:t,items:i,anchor:n},o.toggleFor(n)}rowMenu(){if(this._rowMenu?.isConnected)return this._rowMenu;const e=document.createElement("sf-menu-context");return e.setAttribute("popup",""),e.dataset.sfTableMenu="row",e.addEventListener("sf-menu-context-select",e=>{const t=this._rowMenuContext;if(!t)return;const n=e.detail?.id,{row:s,items:i,anchor:r}=t,a=i.find(e=>e.id===n),o=a?null:i.flatMap(e=>e.members??[]).find(e=>e.id===n);if(o)return void this.requestActionIntent(o.id,[s.id]);const l=a?.component?.props?.["@click"]??a?.component?.props?.onClick;"function"==typeof l?l({currentTarget:r,target:r,preventDefault(){},stopPropagation(){}}):a&&this.requestActionIntent(a.id,[s.id])}),(this.closest("dialog[open]")||document.body).append(e),this._rowMenu=e,e}rowActionItems(e={}){const t=Array.isArray(e?.actions)&&e.actions.every(e=>"string"==typeof e)?e.actions.join(","):"*",n=(this.ACTIONS_SETTINGS_ROW??[]).map(e=>e?.id??"").join(",");this._rowActionListKey!==n&&(this._rowActionListKey=n,this._rowActionItems=new Map);const s=`${e?.id??""}|${t}`;return this._rowActionItems||(this._rowActionItems=new Map),this._rowActionItems.has(s)||this._rowActionItems.set(s,this.getActionRowItems(e)),this._rowActionItems.get(s)}getActionRowItems(e={},t=this.ACTIONS_SETTINGS_ROW){const n=Array.isArray(e.actions)&&e.actions.every(e=>"string"==typeof e)?e.actions:null,s=e=>(e.members||[]).filter(e=>!n||n.includes(e.id));return t.filter(e=>Array.isArray(e.members)?s(e).length>0:!n||n.includes(e.id)).map(t=>{if(Array.isArray(t.members)){const n=s(t),i={...t.component?.props||{}};return i["@click"]=s=>this.openContextMenu(s,{type:"left",row:e,action:t,menu:"row-settings",items:n.map(t=>({component:"sf-button",props:{appearance:"link",scheme:t.danger?"error":"on-surface",text:t.name,"@click":()=>{this.requestActionIntent(t.id,[e.id]),this.closeContextMenu()}}}))}),{...t,component:{...t.component||{},props:i}}}const n=t.component||{},i={...t.props||{},...n.props||{}},r=t.menu||i.menu,a="function"==typeof i["@click"]||"function"==typeof i.onClick;return r&&!a?i["@click"]=n=>{const s=r&&"object"==typeof r?r:{menu:r};this.openContextMenu(n,{type:"left",row:e,action:t,...s})}:a||(i["@click"]=()=>this.requestActionIntent(t.id,[e.id])),{...t,component:{...n,props:i}}})}getDefaultRowCell(e,t){return e?.key?"select"===e.key?this.createRowComponentCell(e.rowComponent,{checked:!!this.state.settingsChecked||Boolean(t?.selected||t?.checked),value:t?.id??t?.value??"",ariaLabel:this.getRowSelectLabel(t),"@change":e=>{this.applyRowSelection(t.id,Boolean(e.target.checked),{range:!0===this._selectRangeModifier})}}):"settings"===e.key?this.createRowComponentCell(e.rowComponent||{type:"button-icon",props:{size:"1",appearance:"link",scheme:"on-surface",icon:"menu",ariaLabel:this.text("menuLabel"),value:"menu","@click":e=>this.openRowMenu(e,t)}}):"actions"===e.key?this.getActionRowItems(t):null:null}normalizeRow(e={},t=this.getSystemColumns()){if(!e||"object"!=typeof e||Array.isArray(e))return e;if(t.every(t=>!t?.key||!1===t.visible||void 0!==e[t.key]))return e;const n={...e};return t.forEach(e=>{if(!e?.key||void 0!==n[e.key]||!1===e.visible)return;const t=this.getDefaultRowCell(e,n);t&&(n[e.key]=t)}),n}normalizeRows(e=[]){if(!Array.isArray(e))return[];const t=this.getSystemColumns();this._labelColumnBatch={};try{return e.map(e=>this.normalizeRow(e,t))}finally{this._labelColumnBatch=null}}setTableData(e={},t="data"){const n=this.getTableData(),s="function"==typeof e?e(n):e;if(!s||"object"!=typeof s)return this;const i=this.set({data:{...n,...s}},t);return this.syncSelectionPort(),Object.prototype.hasOwnProperty.call(s,"rows")&&this.syncSelectAllState(),i}setColumns(e=[],t="columns"){const n=this.getTableData().columns||[],s="function"==typeof e?e(n):e,i=this.setTableData({columns:Array.isArray(s)?s:[]},t);return this.rememberedWidthsKey&&this.restoreRememberedWidths(),i}addColumns(e=[]){const t=Array.isArray(e)?e:[e];return this.setColumns(e=>[...e,...t.filter(Boolean)])}updateColumn(e,t={},n="columns"){return e?this.setColumns(n=>n.map((n,s)=>{if(!n||n.key!==e)return n;const i="function"==typeof t?t(n,s):t;return{...n,...i||{}}}),n):this}rowsGeneration(){return this._rowsGeneration??0}setRows(e=[],t="rows"){const n=this.getTableData().rows||[],s="function"==typeof e?e(n):e;return"result"===t&&Array.isArray(s)&&U(n,s)&&(this._rowsGeneration=(this._rowsGeneration??0)+1),this.setTableData({rows:this.normalizeRows(s)},t)}addRows(e=[],t="rows"){this.isActionParameters?.(e,["rows"])&&(e=e.rows??[]);const n=Array.isArray(e)?e:[e];return this.setRows(e=>[...e,...n.filter(Boolean)],t),{outcome:"applied"}}updateRowsByKey(e,t,n={},s="rows"){if(!e)return this;const i="function"==typeof n?n:e=>({...e,...n||{}});return this.setRows(n=>n.map((n,s)=>{if(!n||n[e]!==t)return n;const r=i(n,s);return r&&"object"==typeof r?r:n}),s)}updateRowByKey(e,t,n={},s="row"){return this._entryOnly=!0,this.updateRowsByKey(e,t,n,s)}updateRows(e={},t="rows"){const n="function"==typeof e?e:t=>({...t,...e||{}});return this.setRows(e=>e.map((e,t)=>{const s=n(e,t);return s&&"object"==typeof s?s:e}),t)}updateRowCell(e,t,n,s={},i="cell"){return n?this.updateRowsByKey(e,t,e=>{const t=e&&e[n]&&"object"==typeof e[n]?e[n]:{},i="function"==typeof s?s(t,e):s;return{...e,[n]:{...t,...i||{}}}},i):this}updateRowCellProps(e,t,n,s={},i="cell-props"){return this.updateRowCell(e,t,n,e=>({component:{...e.component||{},props:{...e.component?.props||{},..."function"==typeof s?s(e.component?.props||{},e):s||{}}}}),i)}closeContextMenu(e=!0){const t=this.contextTarget;this.set({contextMenu:{open:!1}}),this.stopContextMenuPositions(),(0,p.render)(null,this.getPortalContainer()),this.hidePortal(),this.refs.contextMenu&&(this.refs.contextMenu.value=null),this.unbindContextEvent(),this.unbindContextViewport(),this.contextTarget?.classList.remove("active"),this.contextTarget=null,e&&t?.isConnected&&"function"==typeof t.focus&&requestAnimationFrame(()=>t.focus())}get templateName(){return this.getAttribute("template")||"default"}get dataState(){const e=this.getEnumAttr("data-state",["loading","ready","populated","empty","error"],"auto");return"ready"===e?"populated":e}setDataState(e="auto"){const t="ready"===e?"populated":e,n=["loading","populated","empty","error"].includes(t)?t:"auto";return"auto"===n?this.removeAttribute("data-state"):this.setAttribute("data-state",n),this}requestRetry(){return this.emitTableEvent("refresh",{}),{outcome:"applied"}}get emptyContext(){return this._emptyContext}set emptyContext(e){this._emptyContext=e&&"object"==typeof e?{...e}:null,this.requestComponentUpdate("empty-context")}resetQuery(e="both"){return"search"!==e&&this.removeFilterTag(),"filters"!==e&&(this.clearSearchDebounce(),this._searchPendingProps=null,this.state.search?.value?this.updateSearchState({value:""}):this.emitTableEvent("search-change",{search:""})),this}emptyBrick(e){const t=this._emptyContext??{},n="1/2"===this.size?"1/2":"1",s=String(t.headingLevel??3),i="string"==typeof t.message?t.message.trim():"";if("error"===e)return{kind:"error",size:n,headingLevel:s,title:i||this.getAttribute("error-text")||"",text:"",live:t.caused?"alert":"auto",actions:[{id:"retry",text:this.text("retryText","retry-text"),appearance:"outline"}]};const r=["no-access","nothing-found"].includes(t.kind)?t.kind:"no-data";if("no-access"===r)return{kind:r,size:n,headingLevel:s,title:i,text:"",actions:[]};if("nothing-found"===r){const e={search:"resetSearchText",filters:"resetFiltersText"}[t.reset]??"resetBothText";return{kind:r,size:n,headingLevel:s,title:"",text:"",actions:[{id:"reset-query",text:this.text(e),appearance:"outline"}]}}const a=this.getBooleanAttr("actions",!0)&&this.getBooleanAttr("creatable",!0);return{kind:r,size:n,headingLevel:s,title:this.getAttribute("empty-text")||"",text:this.getAttribute("empty-description")||"",actions:a?[{id:"create",text:this.text("createText","create-text")}]:[]}}disconnectedCallback(){this.unbindWindowScroll(),this._rowMenu?.close?.({restoreFocus:!1}),this._rowMenu?.remove(),this._rowMenu=null;for(const e of this._filterOptionPages.values())e.controller?.abort(),clearTimeout(e.searchTimer);this._filterOptionPages.clear(),this._responsiveObserver?.disconnect(),this._responsiveObserver=null,this._responsiveWidth=0,this._responsiveTarget=null,this._preferenceUnsubscribe?.(),this._preferenceUnsubscribe=null,this._preferenceKeyBound=void 0,this._rowActionsAbort?.abort(),this._rowActionsAbort=null,this._rowActionsTable=null,this.unbindPageScroll(),this._lateLayoutAbort?.abort(),this._lateLayoutAbort=null,cancelAnimationFrame(this._lateLayoutFrame??0),this._lateLayoutFrame=0,this.clearSearchDebounce(),this._searchPendingProps=null,this._searchHoldKey="",this.stopContextMenuPositions(),this.unbindContextEvent(),this.unbindContextViewport(),this.unBindHoverEvent(),this.unbindColumnResizeEvent(),this.unbindColumnDragEvent(),this.tempSettings=null,this._selectionPortKey="[]",this._abandonedQuery=null!==this._pendingQuerySequence,this._pendingQuerySequence=null,this.state.contextMenu={open:!1},this.state.settingsChecked=!1,this.state.selectIndeterminate=!1;const e=this.getTableData();this.state.data={...e,rows:e.rows.map(e=>({...e,selected:!1,checked:!1,...e.select?.component?{select:{...e.select,component:{...e.select.component,props:{...e.select.component.props,checked:!1}}}}:{}}))},this.refs.contextMenu&&(this.refs.contextMenu.value=null),this.contextTarget?.classList?.remove("active"),this.contextTarget=null,this._portalContainer&&((0,p.render)(null,this._portalContainer),this._portalContainer.remove(),this._portalContainer=null),super.disconnectedCallback()}text(e,t){return t&&this.getAttribute(t)||(0,f.pageText)(z,e,this)}templateContext(){this._renderedCramped=this.columnsAreCramped;const e=this.getPropsContext();return this.createTemplateContext({...e,component:this,list:this.isList,rootClass:this.getRootClass(),rootStyle:this.getRootStyle(),filterText:this.text("filterText","filter-text"),clearText:this.text("clearText","clear-text"),searchPlaceholder:this.text("searchPlaceholder","search-placeholder"),createText:this.text("createText","create-text"),pinColumnLabel:this.text("pinColumnLabel","pin-column-label"),unpinColumnLabel:this.text("unpinColumnLabel","unpin-column-label"),loadingText:this.text("loadingText","loading-text"),emptyText:this.text("emptyText","empty-text"),errorText:this.text("errorText","error-text"),retryText:this.text("retryText","retry-text"),columnMoveLabel:this.text("columnMoveLabel","column-move-label"),filterApplyText:this.text("filterApplyText","filter-apply-text"),columnSearchPlaceholder:this.text("columnSearchPlaceholder","column-search-placeholder"),columnSearchEmptyText:this.text("columnSearchEmptyText","column-search-empty-text")})}setCheckboxHeight(){if(!this.refs.items.size)return;const e=++this._checkboxMeasureToken;requestAnimationFrame(()=>{if(!this.isConnected||e!==this._checkboxMeasureToken)return;const t=(0,g.lF)(this.refs.items);if(!t)return;const{item:n,gap:s,parent:i}=t;this.parentGap=s;const r=n.tagName.toLowerCase().startsWith("sf-")?n.children[0]?.clientHeight:n.clientHeight;if(!r)return;const a=(r+s)*(i.dataset.size||8);if(i.clientHeight<=a)return!1;i.setAttribute("style",`height: ${a}px; overflow: auto;`)})}beforeRender(){super.beforeRender(),this.connectTablePreference(),this.applyTableView(),this._checkboxMeasureToken++,this.refs.items=new Map}_observeResponsiveBox(){if(!this._responsiveObserver||this._responsiveTarget?.isConnected)return;const e=[this.querySelector(".sf-table"),this.parentElement,this.getRootNode()?.host],t=e.find(e=>e?.getBoundingClientRect?.().width>0)??e.find(Boolean)??this;this._responsiveTarget&&this._responsiveObserver.unobserve(this._responsiveTarget),this._responsiveTarget=t,this._responsiveObserver.observe(t)}afterRender(){if(this._observeResponsiveBox(),this.bindRowActionsEvents(this.refs.table?.value),this._windowed&&this.bindWindowScroll(),this._pendingFocusRow){const e=this._pendingFocusRow;return this._pendingFocusRow=null,this._windowOnly=!1,this._entryOnly=!1,void this.focusRow(e,{reveal:!0})}if(this._windowOnly||this._entryOnly)return this._windowOnly=!1,this._entryOnly=!1,this._layoutUnchanged=!1,this.fitCellValues(),this.measurePinnedColumns(),void this.syncWindow();if(this._layoutUnchanged)this._layoutUnchanged=!1;else{if(this.measureWhenCellsDrawn()||(this.measureContentWidths()&&this.applyColumnWidths(),this._contentRetries=0,this.fitCellValues(),this.measurePinnedColumns()),this.hasAttribute("data-sf-page-scroll"))this.bindPageScroll(),this.syncRail(),this.syncStickyHead();else{this.unbindPageScroll();const e=this.refs.table?.value?.tHead;e?.style.transform&&(e.style.transform="")}this.columnsAreCramped!==this._renderedCramped&&(this._crampedRetries??0)<2?(this._crampedRetries=(this._crampedRetries??0)+1,this.requestComponentUpdate("cramped-columns")):this._crampedRetries=0,this.bindPinnedColumnScroll(),this.setCheckboxHeight(),this.bindHoverEvent(),this.bindColumnResizeEvent(),this.bindColumnDragEvent(),this.syncWindow()}}template(){return this.readingLayout(()=>(0,u.b1)(this.templateContext()))}}(0,r.l6)(H,a),H.define("sf-view-table"),t()}catch(G){t(G)}})},"17828be41e75"(e,t,n){n.d(t,{l6:()=>i});const s=e=>String(e).replace(/-([a-z0-9])/gu,(e,t)=>t.toUpperCase());function i(e,t){const n=e.prototype;for(const[e,i]of Object.entries(t.settings||{})){if(["list","object","state"].includes(i?.type))continue;const t=s(e);let r=n,a=null;for(;r&&r!==globalThis.HTMLElement?.prototype&&r!==Object.prototype&&(a=Object.getOwnPropertyDescriptor(r,t),!a);)r=Object.getPrototypeOf(r);a&&a.get&&!a.set&&Object.defineProperty(r,t,{configurable:!0,get:a.get,set(t){"boolean"===i.type?!0===t||""===t||"true"===t?this.setAttribute(e,""):!1===t&&!0===i.default?this.setAttribute(e,"false"):this.removeAttribute(e):null==t?this.removeAttribute(e):this.setAttribute(e,String(t))}})}return e}},"9d9caaf4f796"(e,t,n){n.a(e,async(e,s)=>{try{n.d(t,{Y5:()=>T,b1:()=>M});var i=n("2a080a730149"),r=n("9d9903b87148"),a=n("efa66f8927d1"),o=n("8137feb490e0"),l=n("80c480e5196c"),c=n("5bfdd9ec12a1"),u=e([i,r,a,o,l]);[i,r,a,o,l]=u.then?(await u)():u;function d(e,t=""){const n=e?.composedPath?.()?.[0],s=[n,e?.target,e?.currentTarget];for(const e of s){if(!e)continue;if(void 0!==e.value)return e.value;const t=e.querySelector?.("input, textarea");if(t&&void 0!==t.value)return t.value}return t}function h(e){const{state:t}=e.component,{value:n}=t.search,s=e.component.getCurrentFilterTags(),r=e.component.getCurrentFilterValues(),a=Object.entries(s||{}).filter(([,e])=>!1!==e?.active);return i.html`
1027
+ `,this.getPortalContainer()),this.showPortal(),this.bindContextEvent(),this.bindContextViewport(),requestAnimationFrame(()=>{this.clampContextMenusToViewport(),this.redrawWhenComponentsUpgrade(this.getPortalContainer())}),f.nothing):((0,f.render)(null,this.getPortalContainer()),this.hidePortal(),f.nothing)}getActionItems(){return this.state.actions.map(e=>{const t={type:"checkbox",props:{size:this.size,label:e.name,position:"end",rootClass:"content-main-between",checked:e.visible,"@change":t=>{let n=!1;const s=(this.tempSettings&&this.tempSettings.actions?this.tempSettings.actions:this.state.actions).map(s=>{let i=s.id===e.id?t.target.checked:s.visible;return i&&(n=!0),{...s,visible:i}});this.tempSettings={...this.tempSettings||{},actionActive:n,actions:s}}}};return this.renderSmartElement(t.type,t.props)})}hoverEvents(e){if(this._columnResizeState||this.columnDragActive)return;const t=e.target.closest("th");if(!t)return;t.querySelector(".sidebar-resizer")&&(t.classList.add("hover"),this.getColumnResizeHandle(e.target)?this.showColumnResizeGuide(t):this.hideColumnResizeGuide())}outEvent(e){if(this._columnResizeState||this.columnDragActive)return;const t=e.target.closest("th");if(!t)return;t.querySelector(".sidebar-resizer")&&(t.classList.remove("hover"),this.hideColumnResizeGuide())}showColumnResizeGuide(e){const t=this.refs.resizeGuide?.value,n=this.refs.scroll?.value,s=this.refs.table?.value;if(!(t&&n&&e&&s))return;const i=s.querySelector("thead"),r=s.querySelector("tbody");if(!i||!r)return void this.hideColumnResizeGuide();const a=n.getBoundingClientRect(),o=e.getBoundingClientRect(),l=i.getBoundingClientRect(),c=r.getBoundingClientRect();if(c.height<=0)return void this.hideColumnResizeGuide();const u=parseFloat(getComputedStyle(e).borderInlineEndWidth)||0,d=this.isRightToLeft()?o.left-a.left+n.scrollLeft:o.right-a.left+n.scrollLeft-u;t.style.insetInlineStart=`${d}px`,t.style.insetBlockStart=`${l.bottom-a.top+n.scrollTop}px`,t.style.blockSize=`${c.height}px`,t.hidden=!1}hideColumnResizeGuide(){const e=this.refs.resizeGuide?.value;e&&(e.hidden=!0)}isRightToLeft(){return"rtl"===getComputedStyle(this).direction}bindHoverEvent(){if(this._hoverEventBound)return;this._hoverEventBound=!0;const e=this.refs.table?.value;e?.addEventListener("mouseover",this.hoverEvents),e?.addEventListener("mouseout",this.outEvent)}unBindHoverEvent(){if(!this._hoverEventBound)return;const e=this.refs.table?.value;e?.removeEventListener("mouseover",this.hoverEvents),e?.removeEventListener("mouseout",this.outEvent),this._hoverEventBound=!1}bindColumnResizeEvent(){const e=this.refs.table?.value;if(!e||this._columnResizeTable===e)return;const t=globalThis.SF?.Resizer?.attach;"function"==typeof t?(this._columnResizeDetach?.(),this._columnResizeTable=e,this._columnResizeDetach=t(e,{handles:".sf-table-column-resizer",session:e=>this.columnResizeSession(e)})):globalThis.SF?.Loader?.ensure?.(["sf-resizer"],{timeout:1/0}).then(({missing:e})=>{!e.length&&this.isConnected&&this.bindColumnResizeEvent()})}unbindColumnResizeEvent(){this._columnResizeDetach?.(),this._columnResizeDetach=null,this._columnResizeTable=null}columnResizeSession(e){const t=e?.closest?.("th"),n=t?.dataset?.key,s=n?this.getColumns().find(e=>e?.key===n):null;if(!t||!s||s.system||!1===s.resizable)return null;const i=this.refs.table?.value,r=i?.querySelector(`col[data-key="${this.escapeColumnKey(n)}"]`),a={key:n,th:t,col:r,frozenWidths:null,dragging:!1},o=()=>{this._columnResizeState=null,t.style.width=""};return{measure:()=>t.getBoundingClientRect().width,limits:()=>{const{minWidth:e,maxWidth:n}=this.getColumnResizeLimits(s,t.getBoundingClientRect().width);return{min:e,max:n}},direction:()=>i&&"rtl"===getComputedStyle(i).direction?-1:1,step:this.resolveCssLength(getComputedStyle(this).getPropertyValue("--sf-space-1"),16),start:()=>{a.dragging=!0,this._columnResizeState=a,(0,v.J)(!0),document.documentElement.classList.add("sf-table-column-resizing")},apply:e=>(a.frozenWidths??=this.freezeColumnsWidthForResize(i),this._columnResizeState=a,r&&(r.style.width=`${e}px`),t.style.width=`${e}px`,this.showColumnResizeGuide(t),e),commit:e=>{const t=a.frozenWidths??{};o(),this.applyColumnResizeWidths(n,e,t)},end:()=>{document.documentElement.classList.remove("sf-table-column-resizing"),(0,v.J)(!1),this.suppressNextHeaderClick(),o(),this.hideColumnResizeGuide()},reset:()=>{o(),this.resetColumnWidth(n)}}}get rememberedWidthsKey(){return this.viewPreferenceKey?this.viewPreferenceKey:this.hasAttribute("remember-widths")?T(this.getTableSettingsKey()||this.id||globalThis.location?.pathname||"table"):""}readRememberedWidths(){const e=this.rememberedWidthsKey;if(!e)return{};const t=C()?.read(e)?.widths;return t&&"object"==typeof t?t:{}}writeTablePreference(e,t){e&&C()?.write(e,{...C()?.read(e)??{},v:1,...t})}storeRememberedWidths(e={}){this.writeTablePreference(this.rememberedWidthsKey,{widths:{...this.readRememberedWidths(),...e}})}forgetRememberedWidth(e){const t=this.readRememberedWidths();delete t[e],this.writeTablePreference(this.rememberedWidthsKey,{widths:t})}get viewPreferenceKey(){const e=this.getAttribute("preferences-key")||this.getAttribute("table-settings-key")||"";return e?T(e):""}applyTablePreference(e,{render:t=!1}={}){const n=e?.columnSettings;if(!n||"object"!=typeof n)return!1;const s=this.getTableData().columnSettings,i=s&&"object"==typeof s&&!Array.isArray(s)?s:{},r=this.mergeColumnSettings(i,n);return t?this.setColumnSettings(r,"preferences",!1):this.state.columnSettings=r,!0}connectTablePreference(){const e=this.viewPreferenceKey;if(e===this._preferenceKeyBound)return;if(this._preferenceUnsubscribe?.(),this._preferenceKeyBound=e,this._preferenceUnsubscribe=null,this.applyTableView(),!e)return;this.applyTablePreference(C()?.read(e));const t=C()?.subscribe(e,e=>{if(e)this.applyTablePreference(e,{render:!0});else{const e=this.getTableData().columnSettings;this.setColumnSettings(e&&"object"==typeof e&&!Array.isArray(e)?{...e}:{},"preferences",!1)}this.applyTableView()}),n=C()?.subscribe(A,()=>this.applyTableView());this._preferenceUnsubscribe=()=>{t?.(),n?.()}}get tableView(){const e=this.viewPreferenceKey,t=C()?.read(A)?.view??{},n=e?C()?.read(e)?.view??{}:this._sessionView??{};return{...F,...t,...n}}applyTableView(){const e=this.tableView,t=(e,t)=>t?this.setAttribute(e,""):this.removeAttribute(e);"normal"===e.density?this.removeAttribute("data-sf-view-density"):this.setAttribute("data-sf-view-density",e.density),t("data-sf-view-stripes",!0===e.stripes),t("data-sf-view-lines",!0===e.lines),t("data-sf-view-single-line",!0===e.singleLine);const n="page"===this.getAttribute("vertical-scroll")&&!this.isList;t("data-sf-page-scroll",n),t("data-sf-sticky-head",n&&!1!==e.stickyHead)}syncStickyHead(){const e=this.refs.table?.value,t=e?.tHead;if(!t)return;let n=0;if(this.hasAttribute("data-sf-sticky-head")&&e.isConnected){const s=z(this.refs.scroll?.value?.parentElement??this),i=s?s.getBoundingClientRect().top:0,r=this.querySelector(":scope > .sf-table > .sf-table-toolbar"),a=Math.max(i,r?r.getBoundingClientRect().bottom:i),o=e.getBoundingClientRect(),l=o.height-t.offsetHeight;n=Math.round(Math.min(Math.max(a-o.top,0),Math.max(l,0)))}t.style.transform=n?`translateY(${n}px)`:"",this.toggleAttribute("data-sf-head-stuck",n>0)}syncRail(){const e=this.refs.rail?.value,t=this.refs.scroll?.value;if(!e||!t)return;const n=t.scrollWidth>t.clientWidth+1;e.hidden=!n;const s=e.firstElementChild;if(s&&(s.style.inlineSize=`${t.scrollWidth}px`),e._sfBound!==t){e._sfBound=t;let n=!1;const s=(e,t)=>()=>{n||(n=!0,t.scrollLeft=e.scrollLeft,n=!1)};t.addEventListener("scroll",s(t,e),{passive:!0}),e.addEventListener("scroll",s(e,t),{passive:!0}),this._railObserver?.disconnect(),"undefined"!=typeof ResizeObserver&&(this._railObserver=new ResizeObserver(()=>this.syncRail()),this._railObserver.observe(t),this.refs.table?.value&&this._railObserver.observe(this.refs.table.value))}n&&(e.scrollLeft=t.scrollLeft)}bindPageScroll(){if(this._pageScrollAbort)return;this._pageScrollAbort=new AbortController;const{signal:e}=this._pageScrollAbort,t=()=>{this._pageScrollFrame||(this._pageScrollFrame=requestAnimationFrame(()=>{this._pageScrollFrame=0,this.isConnected&&this.syncStickyHead()}))};document.addEventListener("scroll",t,{capture:!0,passive:!0,signal:e}),globalThis.addEventListener("resize",()=>{t(),this.syncRail()},{passive:!0,signal:e})}unbindPageScroll(){this._railObserver?.disconnect(),this._railObserver=null;const e=this.refs.rail?.value;e&&(e._sfBound=null),this._pageScrollAbort?.abort(),this._pageScrollAbort=null,cancelAnimationFrame(this._pageScrollFrame??0),this._pageScrollFrame=0}setTableView(e={},{everywhere:t=!1}={}){const n=this.viewPreferenceKey;if(t||!n){if(t){const t=C()?.read(A)??{};C()?.write(A,{...t,v:1,view:{...t.view??{},...e}})}if(n){const t={...C()?.read(n)?.view??{}};for(const n of Object.keys(e))delete t[n];this.writeTablePreference(n,{view:t})}else t||(this._sessionView={...this._sessionView??{},...e})}else this.writeTablePreference(n,{view:{...C()?.read(n)?.view??{},...e}});return this.applyTableView(),this.requestComponentUpdate("table-view"),this.emitTableEvent("view-change",Object.freeze({view:this.tableView,everywhere:t})),this}resetTableView(){const e=this.viewPreferenceKey;return e&&this.writeTablePreference(e,{view:{}}),this._sessionView=null,this.applyTableView(),this.requestComponentUpdate("table-view"),this}restoreRememberedWidths(){const e=this.readRememberedWidths(),t=new Set((this.getColumns?.()??[]).map(e=>e?.key)),n=Object.fromEntries(Object.entries(e).filter(([e,n])=>t.has(e)&&"string"==typeof n).map(([e,t])=>[e,{width:t}]));Object.keys(n).length&&this.patchColumnSettingsBatch(n,"column-widths-restore")}resetColumnWidth(e){return e?(this.forgetRememberedWidth(e),this.patchColumnSettingsBatch({[e]:{width:null}},"column-resize-reset")):this}get columnDragActive(){return document.documentElement.hasAttribute("data-sf-sortable-active")}bindColumnDragEvent(){const e=this.refs.table?.value,t=e?.tHead?.rows?.[0];if(!t||this._headerSortableRow===t)return;const n=globalThis.SF?.Sortable?.attach;"function"==typeof n?(this._headerSortableDetach?.(),this._headerSortableRow=t,this._headerSortableDetach=n(t,{items:"th[data-key]",extent:e,preview:"line",label:this.text("settingsColumnLabel"),groupOf:e=>this.headerColumnGroup(e.dataset.key),canStart:(e,t)=>!this._columnResizeState&&!this.getColumnResizeHandle(e.target)&&["pinned","loose"].includes(this.headerColumnGroup(t.dataset.key)),cellsOf:t=>[...e.rows].map(e=>e.cells[t.cellIndex]).filter(Boolean),onIntent:e=>this.onHeaderColumnIntent(e)})):globalThis.SF?.Loader?.ensure?.(["sf-sortable"],{timeout:1/0}).then(({missing:e})=>{!e.length&&this.isConnected&&this.bindColumnDragEvent()})}unbindColumnDragEvent(){this._headerSortableDetach?.(),this._headerSortableDetach=null,this._headerSortableRow=null}headerColumnGroup(e){if(this.getSystemColumns().some(t=>String(t.key)===e))return"system";const t=this.getColumns().find(t=>String(t.key)===e);return!t||t.system||!1===t.draggable?"fixed":this.isColumnPinned(t)?"pinned":"loose"}onHeaderColumnIntent({item:e,index:t,group:n}){const s=this.refs.table?.value,i=[...s?.tHead?.rows?.[0]?.cells??[]].map(e=>e.dataset?.key).filter(e=>e&&["pinned","loose","fixed"].includes(this.headerColumnGroup(e))),r=i.filter(t=>t!==e&&this.headerColumnGroup(t)===n),a=i.filter(t=>t!==e),o=r[t],l=r[t-1],c=void 0!==o?a.indexOf(o):void 0!==l?a.indexOf(l)+1:a.length;return a.splice(c,0,e),a.join("|")===i.join("|")?this:this.applyColumnOrder(a,{})}getColumnResizeHandle(e){return e instanceof Element?e.closest("[data-sf-column-resizer]"):null}parseColumnSize(e,t=null){if("number"==typeof e&&Number.isFinite(e))return e;if("string"==typeof e){const t=e.trim();if(/^-?\d+(\.\d+)?px$/.test(t))return parseFloat(t)}return t}resolveCssLength(e,t=0){const n=String(e||"").trim().match(/^(-?\d+(?:\.\d+)?)(px|rem|em)$/);if(!n)return t;const s=Number(n[1]),i=n[2];if("px"===i)return s;const r="rem"===i?document.documentElement:this,a=parseFloat(getComputedStyle(r).fontSize);return Number.isFinite(a)?s*a:t}getColumnResizeLimits(e={},t=0){const n=this.resolveCssLength(getComputedStyle(this).getPropertyValue("--sf-c4"),t),s=this.parseColumnSize(e.minWidth,null)??n,i=this.parseColumnSize(e.maxWidth,1/0);return{minWidth:s,maxWidth:Math.max(i,s)}}hasColumnSize(e={}){return[e.colWidth,e.width,e.size].some(e=>null!=e&&""!==String(e).trim())}escapeColumnKey(e){const t=String(e||"");return"undefined"!=typeof CSS&&"function"==typeof CSS.escape?CSS.escape(t):t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}freezeColumnsWidthForResize(e){const t={};return this.getColumns().forEach(n=>{if(!n?.key)return;const s=String(n.key),i=this.escapeColumnKey(s),r=e?.querySelector(`th[data-key="${i}"]`),a=e?.querySelector(`col[data-key="${i}"]`),o=r?.getBoundingClientRect?.().width||0;if(!o)return;const l=`${Math.round(o)}px`;a&&(a.style.width=l),n.system||this.hasColumnSize(n)||(t[s]=l)}),t}applyColumnResizeWidths(e,t,n={}){if(!e)return this;const s={...n||{},[e]:`${Math.round(t)}px`};this.storeRememberedWidths(s);const i=Object.fromEntries(Object.entries(s).map(([e,t])=>[e,{width:t}]));return this.patchColumnSettingsBatch(i,"column-resize")}reorderColumnDomByKeys(e,t=[]){if(!e||!Array.isArray(t)||!t.length)return;const n=(e,n)=>{if(!e)return;const s=new Set(t);let i=null;for(const t of Array.from(e.children||[])){const e=t?.dataset?.key;if(e&&s.has(e))break;e&&(i=t)}t.forEach(t=>{const s=this.escapeColumnKey(t),r=e.querySelector(`${n}[data-key="${s}"]`);r&&(e.insertBefore(r,i?.nextSibling||e.firstChild),i=r)})};n(e.querySelector("colgroup"),"col"),n(e.tHead?.rows?.[0],"th"),Array.from(e.tBodies||[]).forEach(e=>{Array.from(e.rows||[]).forEach(e=>{n(e,"td")})})}applyColumnOrder(e=[],t={}){if(!Array.isArray(e)||!e.length)return this;const n={},s=this.getColumnOrderSlots(e);return e.forEach((e,i)=>{n[e]={order:s[i]},t?.[e]&&(n[e].width=t[e])}),this.patchColumnSettingsBatch(n,"column-drag")}getColumnOrderSlots(e=[]){const t=(this.getTableData().columns||[]).filter(e=>e?.key&&!e.system),n=(e,t)=>{const n=(this.getColumnSetting(e.key)||{}).order??e.order,s=Number(n);return Number.isFinite(s)?s:10*(t+1)},s=new Map(t.map((e,t)=>[String(e.key),n(e,t)])),i=e.map(e=>s.get(String(e))).filter(e=>Number.isFinite(e)).sort((e,t)=>e-t),r=new Set(i);return i.length!==e.length||r.size!==i.length?e.map((e,t)=>10*(t+1)):i}setColumnResizeClasses(e,t=0){e&&(e.classList.add("is-resizing"),e.classList.toggle("is-resizing-forward",t>=0),e.classList.toggle("is-resizing-backward",t<0),this.showColumnResizeGuide(e),this.measurePinnedColumns())}clearColumnResizeClasses(e){e&&(e.classList.remove("is-resizing","is-resizing-forward","is-resizing-backward"),this.hideColumnResizeGuide(),this.measurePinnedColumns())}bindContextEvent(){this._contextEventBound||(document.addEventListener("click",this.contextEvent),document.addEventListener("keydown",this.contextKeyEvent),this._contextEventBound=!0)}unbindContextEvent(){this._contextEventBound&&(document.removeEventListener("click",this.contextEvent),document.removeEventListener("keydown",this.contextKeyEvent),this._contextEventBound=!1)}contextKeyEvent(e){"Escape"===e.key&&this.state.contextMenu?.open&&(e.preventDefault(),e.stopPropagation(),this.closeContextMenu(!0))}getPortalContainer(){if(this._portalContainer?.isConnected)return this._portalContainer;const e=document.createElement("form");e.className="sf-table-portal",e.noValidate=!0,e.dataset.tableSettingsKey=this.getTableSettingsKey(),e.dataset.sfInstance=this.getInstanceId(),"function"==typeof e.showPopover&&e.setAttribute("popover","manual"),e.addEventListener("submit",e=>e.preventDefault());for(const t of["change","input"])e.addEventListener(t,e=>e.stopPropagation());return this.insertBefore(e,this.firstChild),globalThis.SF?.Loader?.watch?.(e),this._portalContainer=e,e}showPortal(){const e=this._portalContainer;e?.isConnected&&"function"==typeof e.showPopover&&(e.matches(":popover-open")||e.showPopover())}hidePortal(){const e=this._portalContainer;e?.isConnected&&"function"==typeof e.hidePopover&&e.matches(":popover-open")&&e.hidePopover()}getVisualViewportRect(){const e=window.visualViewport;return{left:e?.offsetLeft||0,top:e?.offsetTop||0,right:(e?.offsetLeft||0)+(e?.width||window.innerWidth),bottom:(e?.offsetTop||0)+(e?.height||window.innerHeight)}}clampContextMenusToViewport(){const e=this._portalContainer;if(!e?.isConnected)return;const t=this.getVisualViewportRect(),n=getComputedStyle(document.documentElement),s=parseFloat(n.getPropertyValue("--sf-space-1/3"))||0,i=new Set;e.querySelectorAll("sf-menu-context").forEach(e=>{if(this.anchorContextMenu(e,t,s))return void i.add(e);const n=Math.max(0,t.right-t.left-2*s),r=Math.max(0,t.bottom-t.top-2*s);e.style.setProperty("--sf-table-context-menu--available-inline-size",`${n}px`),e.style.setProperty("--sf-context-menu-available-inline-size",`${n}px`),e.style.setProperty("--sf-context-menu-available-block-size",`${r}px`),e.style.translate="";const a=(e.querySelector(":scope > .sf-context-menu")||e).getBoundingClientRect();let o=0,l=0;a.left<t.left+s?o=t.left+s-a.left:a.right>t.right-s&&(o=t.right-s-a.right),a.top<t.top+s?l=t.top+s-a.top:a.bottom>t.bottom-s&&(l=t.bottom-s-a.bottom),(o||l)&&(e.style.translate=`${o}px ${l}px`)});for(const[e,t]of this._contextPositions||[])i.has(e)||(t.controller.stop(),this._contextPositions.delete(e))}describeContextAnchor(e){if(!(e instanceof Element))return null;const t=e.closest("[data-item], th[data-key], [id]");if(!t||!this.contains(t))return null;const n=void 0!==t.dataset.item?`[data-item="${this.escapeColumnKey(t.dataset.item)}"]`:t.matches("th[data-key]")?`th[data-key="${this.escapeColumnKey(t.dataset.key)}"]`:`[id="${this.escapeColumnKey(t.id)}"]`,s=e.tagName.toLowerCase();return{selector:n,tag:s,index:t===e?-1:Array.from(t.querySelectorAll(s)).indexOf(e)}}resolveContextAnchor(e){if(e?.anchor instanceof Element&&e.anchor.isConnected)return e.anchor;const t=e?.anchorRef,n=t?this.querySelector(t.selector):null,s=n&&(t.index<0?n:n.querySelectorAll(t.tag)[t.index]);return s?(e.anchor=s,s):null}getContextMenuPlacement(e){const t=e.hasAttribute("data-context-submenu"),n=t?this.state.contextMenu?.submenu:this.state.contextMenu,s=this.resolveContextAnchor(n);if(!s)return null;const i=String(n.position||(t||"left"===n.type?"left":"")),r=/^(left|right)(-top|-bottom)?$/.exec(i);if(!r){return{anchor:s,side:"block-end",align:["create","toolbar-actions"].includes(n.menu)?"end":"start",tail:null}}const a=r[2]||"";return{anchor:s,side:"left"===r[1]?"inline-end":"inline-start",align:"-top"===a?"start":"-bottom"===a?"end":"center",tail:a}}anchorContextMenu(e,t,n){const s=this.getContextMenuPlacement(e);if(!s)return!1;const i=e.querySelector(":scope > .sf-context-menu");if(!i)return!1;this._contextPositions=this._contextPositions||new Map;const r=this._contextPositions.get(e),a=r?.cssCap??(parseFloat(getComputedStyle(i).maxWidth)||1/0),o=`${Math.max(0,Math.min(t.right-t.left-2*n,a))}px`;i.style.setProperty("--sf-table-context-menu--available-inline-size",o),i.style.setProperty("--sf-context-menu-available-inline-size",o);const l=`${s.side}|${s.align}`;if(r&&r.anchor===s.anchor&&r.surface===i&&r.key===l)return r.controller.update(),!0;r?.controller.stop(),i.style.transform="none",i.style.translate="none",i.style.setProperty("--sf-context-menu-available-block-size",`${Math.max(0,t.bottom-t.top-2*n)}px`);const c=P(),u=null===s.tail?c.resolveLength("calc(var(--sf-focus-outline-width) * 2)",i):c.resolveLength("var(--sf-context-menu-tail-corner-offset)",i),d=s.anchor.getBoundingClientRect(),h=c.anchor(s.anchor,i,{side:s.side,align:s.align,offset:u,alignmentOffset:"center"===s.align||null===s.tail?0:Math.max(0,d.height/2-u),padding:n,fitHeight:!1,onPosition:({side:t})=>{const r=s.anchor.getBoundingClientRect(),a=this.getVisualViewportRect(),o="block-end"===t?a.bottom-n-r.bottom-u:"block-start"===t?r.top-u-n-a.top:a.bottom-a.top-2*n,l=`${Math.max(0,Math.floor(o))}px`;if(i.style.getPropertyValue("--sf-context-menu-available-block-size")!==l&&i.style.setProperty("--sf-context-menu-available-block-size",l),null!==s.tail){const n=`${"inline-end"===t?"left":"right"}${s.tail}`;e.getAttribute("position")!==n&&e.setAttribute("position",n)}}});return this._contextPositions.set(e,{controller:h,anchor:s.anchor,surface:i,key:l,cssCap:a}),document.fonts?.ready?.then(()=>{this._contextPositions?.get(e)?.controller===h&&h.update()}).catch(()=>{}),!0}stopContextMenuPositions(){for(const e of this._contextPositions?.values()||[])e.controller.stop();this._contextPositions?.clear()}contextViewportEvent(){requestAnimationFrame(()=>this.clampContextMenusToViewport())}bindContextViewport(){this._contextViewportBound||(window.addEventListener("resize",this.contextViewportEvent),window.visualViewport?.addEventListener("resize",this.contextViewportEvent),window.visualViewport?.addEventListener("scroll",this.contextViewportEvent),this._contextViewportBound=!0)}unbindContextViewport(){this._contextViewportBound&&(window.removeEventListener("resize",this.contextViewportEvent),window.visualViewport?.removeEventListener("resize",this.contextViewportEvent),window.visualViewport?.removeEventListener("scroll",this.contextViewportEvent),this._contextViewportBound=!1)}openContextMenu(e,t={}){this.closeContextMenu(!1),this.contextTarget?.classList.remove("active");const n=e.currentTarget instanceof Element?e.currentTarget:e.target instanceof Element?e.target:null;if(!n)return;const s=(e.composedPath?.()||[]).filter(e=>e instanceof Element).map(e=>e.closest?.('button, input, select, textarea, a[href], [role="button"]')).find(e=>e&&(e===n||n.contains(e))),i=e=>{const t=e.getBoundingClientRect();return t.width>0||t.height>0},r=s||i(n)?n:Array.from((n.shadowRoot||n).querySelectorAll?.("*")||[]).find(i)||n;this.contextTarget=s||r,this.contextTarget.classList.add("active");let a=t.anchorSelector&&this.contextTarget.closest?.(t.anchorSelector)||this.contextTarget,o=a.getBoundingClientRect();e.preventDefault(),e.stopPropagation();let l={open:!0,id:this.contextTarget,...t},c={};switch(t.type){case"left":c={x:o.left+o.width,y:o.y+o.height/2};break;case"bottom":{let n=null;t.parent&&(n=(0,y.PA)(e.target),o=n.getBoundingClientRect(),a=n),c={x:o.left,y:o.y+o.height};break}default:c={x:o.left,y:o.y+o.height}}l={...l,...c,anchor:a,anchorRef:this.describeContextAnchor(a)},"table-settings"===l.menu&&(this._columnSettingsOnOpen=JSON.parse(JSON.stringify(this.getColumnSettings()||{}))),this.set({contextMenu:{...l}})}resolveBoxedAnchor(e,t){if(!(t instanceof Element))return t;const n=e=>{const t=e?.getBoundingClientRect?.();return Boolean(t)&&(t.width>0||t.height>0)},s=(e?.composedPath?.()||[]).filter(e=>e instanceof Element).map(e=>e.closest?.('button, input, select, textarea, a[href], [role="button"]')).find(e=>e&&(e===t||t.contains(e)));if(s&&n(s))return s;if(n(t))return t;return Array.from((t.shadowRoot||t).querySelectorAll?.("*")||[]).find(n)||t}redrawWhenComponentsUpgrade(e=this){if(!e?.querySelectorAll)return this;this._awaitedComponents=this._awaitedComponents||new Set;const t=new Set(Array.from(e.querySelectorAll("*")).map(e=>e.tagName.toLowerCase()).filter(e=>e.includes("-")&&!customElements.get(e)));for(const e of t)this._awaitedComponents.has(e)||(this._awaitedComponents.add(e),customElements.whenDefined(e).then(()=>{this.requestComponentUpdate("component-upgrade")}).catch(()=>{}));return this}openContextSubmenu(e,t={}){e.preventDefault(),e.stopPropagation();const n=e.target instanceof Element?e.target:null,s=e.currentTarget instanceof Element?e.currentTarget:n;if(!s)return;const i=this.resolveBoxedAnchor(e,s),r=i.getBoundingClientRect(),a=t.anchorKey||t.template?.key||s.dataset?.contextSubmenuAnchor||"";if(a&&this.state.contextMenu?.submenu?.open&&this.state.contextMenu.submenu.anchorKey===a)return void this.closeContextSubmenu();const o={open:!0,type:t.type,anchorKey:a,x:r.left+r.width,y:r.y+r.height/2,position:t.position||"left",transform:-50,...t,anchor:i,anchorRef:this.describeContextAnchor(i)};this.set(e=>({contextMenu:{...e.contextMenu||{},submenu:o}}))}handleContextLayerClick(e){const t=e.target;t instanceof Element&&(t.closest("[data-context-submenu]")||t.closest("[data-context-submenu-anchor]")||this.state.contextMenu?.submenu?.open&&!t.closest("[data-context-main-menu]")&&this.closeContextSubmenu())}closeContextSubmenu(){this.set(e=>({contextMenu:{...e.contextMenu||{},submenu:null}}))}renderCellElement(e,t={}){const n=(0,s.canonicalTag)(`sf-${String(e??"").replace(/^sf-/u,"")}`);if(!(_.has(n)&&!0!==t.interactive&&!0!==t.closable&&"checkbox"!==t.type&&!Object.keys(t).some(e=>e.startsWith("@")||/^on[A-Z]/u.test(e))?customElements.get(n):null))return this.renderSmartElement(e,t);this._lightCells??=new Map;let i=this._lightCells.get(n);if(i||(i=document.createElement(n),this._lightCells.set(n,i)),"function"!=typeof i.template)return this.renderSmartElement(e,t);for(const e of[...i.getAttributeNames()])i.removeAttribute(e);const r="1"!==this.size&&"1"===String(t.size)?this.size:t.size;for(const[e,n]of Object.entries({...t,...void 0!==r?{size:r}:{}})){if(null==n||!1===n)continue;const t=e.replace(/[A-Z]/gu,e=>`-${e.toLowerCase()}`);"object"==typeof n||"function"==typeof n?i[e]=n:i.setAttribute(t,!0===n?"":String(n))}try{return i.template()}catch{return this.renderSmartElement(e,t)}}renderSmartElement(e,t={}){e=(0,s.canonicalTag)(`sf-${String(e??"").replace(/^sf-/u,"")}`);const n=this.size;return"1"!==n&&t&&"1"===String(t.size)?super.renderSmartElement(e,{...t,size:n}):super.renderSmartElement(e,t)}get size(){return this.getEnumAttr("size",["1/2","1"],"1")}getSelectColumn(){return{...this.TABLE_SELECT_COLUMN,component:{...this.TABLE_SELECT_COLUMN.component,props:{...this.TABLE_SELECT_COLUMN.component?.props||{},checked:Boolean(this.state?.settingsChecked),indeterminate:Boolean(this.state?.selectIndeterminate)}}}}getColumns(){const e=this.getTableData().columns||[],t=this.getSystemColumns(),n=new Set(t.map(e=>e.key)),s=new Set(["actions"]),i=new Map(e.map((e,t)=>[e?.key,t])),r=e.filter(e=>e?.key&&!n.has(e.key)).map(e=>{const t=this.getColumnSetting(e.key),n={...e,...t};return t.width&&(n.colWidth=t.width),n}).sort((e,t)=>{const n=e=>{const t=e?.order;return null!=t&&""!==t&&Number.isFinite(Number(t))?Number(t):i.get(e?.key)??0},s=n(e),r=n(t);return s===r?(i.get(e.key)??0)-(i.get(t.key)??0):s-r}),a=t.filter(e=>!s.has(e?.key)),o=t.filter(e=>s.has(e?.key)),l=[...a,...r.filter(e=>this.isColumnPinned(e)),...r.filter(e=>!this.isColumnPinned(e)),...o].filter(e=>!1!==e?.visible),c=this._responsiveWidth||this.clientWidth||0;if(this.isList||!c||!r.some(e=>void 0!==e.priority))return l;const u=e=>{const t=e.min_width??e.minWidth??e.width,n="number"==typeof t?t:Number.parseFloat(String(t??""));return Number.isFinite(n)&&n>0?n:e.system?48:160},d=new Set(l);let h=l.reduce((e,t)=>e+u(t),0);const p=r.filter(e=>!1!==e.visible).sort((e,t)=>(t.priority??0)-(e.priority??0));for(const e of p){if(h<=c||d.size<=t.length+1)break;d.delete(e),h-=u(e)}return l.filter(e=>d.has(e))}isColumnPinned(e){if(!e?.key)return!1;if("select"===e.key||"settings"===e.key)return!0;if(e.system)return!1;const t=this.tempSettings?.cols?.[e.key],n=this.getColumnSetting(e.key)||{},s=t?.pinned??n.pinned??e.pinned;return"boolean"==typeof s?s:"title"===e.role}getPinnedColumnKeys(e=this.getColumns()){return e.filter(e=>e?.key&&this.isColumnPinned(e)).map(e=>e.key)}isPinnedColumn(e){return!!e?.key&&(!!["start","end"].includes(e.sticky)||this.isColumnPinned(e))}getStickyCellStyle(e,t){const n=e[t];if(!this.isPinnedColumn(n))return"";return`position: sticky; inset-inline-${["start","end"].includes(n.sticky)?n.sticky:"start"}: var(--sf-table-pin-${n.key}, 0px); z-index: 2;`}measurePinnedColumns(){const e=this.refs.table?.value,t=this.refs.scroll?.value;if(!e)return this;const n=this.getPinnedColumnKeys(),s=e.querySelector("thead tr"),i=n.map(e=>{const t=s?.querySelector(`th[data-key="${e}"]`);return t?t.getBoundingClientRect().width:0});let r=0;n.forEach((t,n)=>{const s=`${Math.round(r)}px`;e.style.getPropertyValue(`--sf-table-pin-${t}`)!==s&&e.style.setProperty(`--sf-table-pin-${t}`,s),r+=i[n]});const a=n[n.length-1],o=new Set(a?e.querySelectorAll(`[data-key="${a}"]`):[]);for(const t of e.querySelectorAll("[data-sf-pin-edge]"))o.has(t)||t.removeAttribute("data-sf-pin-edge");for(const e of o)e.hasAttribute("data-sf-pin-edge")||e.setAttribute("data-sf-pin-edge","");if(t){Math.abs(t.scrollLeft)>0?t.setAttribute("data-sf-pin-scrolled",""):t.removeAttribute("data-sf-pin-scrolled")}return this}bindPinnedColumnScroll(){const e=this.refs.scroll?.value;return e&&this._pinnedScrollBound!==e?(this._pinnedScrollBound=e,e.addEventListener("scroll",()=>this.measurePinnedColumns(),{passive:!0}),this):this}getRowSelectLabel(e){const t=this._labelColumnBatch,n=t&&"column"in t?t.column:this.getColumnItems().find(e=>e?.key&&!e.system&&"select"!==e.key&&"settings"!==e.key);t&&(t.column=n);const s=n?e?.[n.key]:void 0,i=null!==s&&"object"==typeof s?s.text??s.label??s.value??"":s,r=String(i??"").trim()||String(e?.id??"").trim();return r?`${this.text("selectRowLabel")}: ${r}`:this.text("selectRowLabel")}createRowComponentCell(e,t={}){return e?.type?{component:{type:e.type,props:{...e.props||{},...t}}}:null}async openRowMenu(e,t={}){const n=e?.currentTarget?.querySelector?.("button")??e?.target?.closest?.("button")??e?.currentTarget;if(!(n instanceof Element))return null;const s=Array.isArray(t.actions)&&t.actions.every(e=>"string"==typeof e)?t.actions:null,i=this.getActionRowItems(t),r=e=>e?.icon??e?.component?.props?.icon??void 0,a=i.map(e=>Array.isArray(e.members)?{id:e.id,text:e.name,icon:r(e),submenu:e.members.filter(e=>!s||s.includes(e.id)).map(e=>({id:e.id,text:e.name,icon:r(e),danger:!0===e.danger}))}:{id:e.id,text:e.name,icon:r(e),danger:!0===e.danger});await(globalThis.SF?.Loader?.ensure?.(["sf-menu-context"]));const o=this.rowMenu();return o.setAttribute("aria-label",this.getContextMenuLabel({row:t,menu:"row-settings"})),o.entries=a,this._rowMenuContext={row:t,items:i,anchor:n},o.toggleFor(n)}rowMenu(){if(this._rowMenu?.isConnected)return this._rowMenu;const e=document.createElement("sf-menu-context");return e.setAttribute("popup",""),e.dataset.sfTableMenu="row",e.addEventListener("sf-menu-context-select",e=>{const t=this._rowMenuContext;if(!t)return;const n=e.detail?.id,{row:s,items:i,anchor:r}=t,a=i.find(e=>e.id===n),o=a?null:i.flatMap(e=>e.members??[]).find(e=>e.id===n);if(o)return void this.requestActionIntent(o.id,[s.id]);const l=a?.component?.props?.["@click"]??a?.component?.props?.onClick;"function"==typeof l?l({currentTarget:r,target:r,preventDefault(){},stopPropagation(){}}):a&&this.requestActionIntent(a.id,[s.id])}),(this.closest("dialog[open]")||document.body).append(e),this._rowMenu=e,e}rowActionItems(e={}){const t=Array.isArray(e?.actions)&&e.actions.every(e=>"string"==typeof e)?e.actions.join(","):"*",n=(this.ACTIONS_SETTINGS_ROW??[]).map(e=>e?.id??"").join(",");this._rowActionListKey!==n&&(this._rowActionListKey=n,this._rowActionItems=new Map);const s=`${e?.id??""}|${t}`;return this._rowActionItems||(this._rowActionItems=new Map),this._rowActionItems.has(s)||this._rowActionItems.set(s,this.getActionRowItems(e)),this._rowActionItems.get(s)}getActionRowItems(e={},t=this.ACTIONS_SETTINGS_ROW){const n=Array.isArray(e.actions)&&e.actions.every(e=>"string"==typeof e)?e.actions:null,s=e=>(e.members||[]).filter(e=>!n||n.includes(e.id));return t.filter(e=>Array.isArray(e.members)?s(e).length>0:!n||n.includes(e.id)).map(t=>{if(Array.isArray(t.members)){const n=s(t),i={...t.component?.props||{}};return i["@click"]=s=>this.openContextMenu(s,{type:"left",row:e,action:t,menu:"row-settings",items:n.map(t=>({component:"sf-button",props:{appearance:"link",scheme:t.danger?"error":"on-surface",text:t.name,"@click":()=>{this.requestActionIntent(t.id,[e.id]),this.closeContextMenu()}}}))}),{...t,component:{...t.component||{},props:i}}}const n=t.component||{},i={...t.props||{},...n.props||{}},r=t.menu||i.menu,a="function"==typeof i["@click"]||"function"==typeof i.onClick;return r&&!a?i["@click"]=n=>{const s=r&&"object"==typeof r?r:{menu:r};this.openContextMenu(n,{type:"left",row:e,action:t,...s})}:a||(i["@click"]=()=>this.requestActionIntent(t.id,[e.id])),{...t,component:{...n,props:i}}})}getDefaultRowCell(e,t){return e?.key?"select"===e.key?this.createRowComponentCell(e.rowComponent,{checked:!!this.state.settingsChecked||Boolean(t?.selected||t?.checked),value:t?.id??t?.value??"",ariaLabel:this.getRowSelectLabel(t),"@change":e=>{this.applyRowSelection(t.id,Boolean(e.target.checked),{range:!0===this._selectRangeModifier})}}):"settings"===e.key?this.createRowComponentCell(e.rowComponent||{type:"button-icon",props:{size:"1",appearance:"link",scheme:"on-surface",icon:"menu",ariaLabel:this.text("menuLabel"),value:"menu","@click":e=>this.openRowMenu(e,t)}}):"actions"===e.key?this.getActionRowItems(t):null:null}normalizeRow(e={},t=this.getSystemColumns()){if(!e||"object"!=typeof e||Array.isArray(e))return e;if(t.every(t=>!t?.key||!1===t.visible||void 0!==e[t.key]))return e;const n={...e};return t.forEach(e=>{if(!e?.key||void 0!==n[e.key]||!1===e.visible)return;const t=this.getDefaultRowCell(e,n);t&&(n[e.key]=t)}),n}normalizeRows(e=[]){if(!Array.isArray(e))return[];const t=this.getSystemColumns();this._labelColumnBatch={};try{return e.map(e=>this.normalizeRow(e,t))}finally{this._labelColumnBatch=null}}setTableData(e={},t="data"){const n=this.getTableData(),s="function"==typeof e?e(n):e;if(!s||"object"!=typeof s)return this;const i=this.set({data:{...n,...s}},t);return this.syncSelectionPort(),Object.prototype.hasOwnProperty.call(s,"rows")&&this.syncSelectAllState(),i}setColumns(e=[],t="columns"){const n=this.getTableData().columns||[],s="function"==typeof e?e(n):e,i=this.setTableData({columns:Array.isArray(s)?s:[]},t);return this.rememberedWidthsKey&&this.restoreRememberedWidths(),i}addColumns(e=[]){const t=Array.isArray(e)?e:[e];return this.setColumns(e=>[...e,...t.filter(Boolean)])}updateColumn(e,t={},n="columns"){return e?this.setColumns(n=>n.map((n,s)=>{if(!n||n.key!==e)return n;const i="function"==typeof t?t(n,s):t;return{...n,...i||{}}}),n):this}rowsGeneration(){return this._rowsGeneration??0}setRows(e=[],t="rows"){const n=this.getTableData().rows||[],s="function"==typeof e?e(n):e;return"result"===t&&Array.isArray(s)&&G(n,s)&&(this._rowsGeneration=(this._rowsGeneration??0)+1),this.setTableData({rows:this.normalizeRows(s)},t)}addRows(e=[],t="rows"){this.isActionParameters?.(e,["rows"])&&(e=e.rows??[]);const n=Array.isArray(e)?e:[e];return this.setRows(e=>[...e,...n.filter(Boolean)],t),{outcome:"applied"}}updateRowsByKey(e,t,n={},s="rows"){if(!e)return this;const i="function"==typeof n?n:e=>({...e,...n||{}});return this.setRows(n=>n.map((n,s)=>{if(!n||n[e]!==t)return n;const r=i(n,s);return r&&"object"==typeof r?r:n}),s)}updateRowByKey(e,t,n={},s="row"){return this._entryOnly=!0,this.updateRowsByKey(e,t,n,s)}updateRows(e={},t="rows"){const n="function"==typeof e?e:t=>({...t,...e||{}});return this.setRows(e=>e.map((e,t)=>{const s=n(e,t);return s&&"object"==typeof s?s:e}),t)}updateRowCell(e,t,n,s={},i="cell"){return n?this.updateRowsByKey(e,t,e=>{const t=e&&e[n]&&"object"==typeof e[n]?e[n]:{},i="function"==typeof s?s(t,e):s;return{...e,[n]:{...t,...i||{}}}},i):this}updateRowCellProps(e,t,n,s={},i="cell-props"){return this.updateRowCell(e,t,n,e=>({component:{...e.component||{},props:{...e.component?.props||{},..."function"==typeof s?s(e.component?.props||{},e):s||{}}}}),i)}closeContextMenu(e=!0){const t=this.contextTarget;this.set({contextMenu:{open:!1}}),this.stopContextMenuPositions(),(0,f.render)(null,this.getPortalContainer()),this.hidePortal(),this.refs.contextMenu&&(this.refs.contextMenu.value=null),this.unbindContextEvent(),this.unbindContextViewport(),this.contextTarget?.classList.remove("active"),this.contextTarget=null,e&&t?.isConnected&&"function"==typeof t.focus&&requestAnimationFrame(()=>t.focus())}get templateName(){return this.getAttribute("template")||"default"}get dataState(){const e=this.getEnumAttr("data-state",["loading","ready","populated","empty","error"],"auto");return"ready"===e?"populated":e}setDataState(e="auto"){const t="ready"===e?"populated":e,n=["loading","populated","empty","error"].includes(t)?t:"auto";return"auto"===n?this.removeAttribute("data-state"):this.setAttribute("data-state",n),this}requestRetry(){return this.emitTableEvent("refresh",{}),{outcome:"applied"}}get emptyContext(){return this._emptyContext}set emptyContext(e){this._emptyContext=e&&"object"==typeof e?{...e}:null,this.requestComponentUpdate("empty-context")}resetQuery(e="both"){return"search"!==e&&this.removeFilterTag(),"filters"!==e&&(this.clearSearchDebounce(),this._searchPendingProps=null,this.state.search?.value?this.updateSearchState({value:""}):this.emitTableEvent("search-change",{search:""})),this}emptyBrick(e){const t=this._emptyContext??{},n="1/2"===this.size?"1/2":"1",s=String(t.headingLevel??3),i="string"==typeof t.message?t.message.trim():"";if("error"===e)return{kind:"error",size:n,headingLevel:s,title:i||this.getAttribute("error-text")||"",text:"",live:t.caused?"alert":"auto",actions:[{id:"retry",text:this.text("retryText","retry-text"),appearance:"outline"}]};const r=["no-access","nothing-found"].includes(t.kind)?t.kind:"no-data";if("no-access"===r)return{kind:r,size:n,headingLevel:s,title:i,text:"",actions:[]};if("nothing-found"===r){const e={search:"resetSearchText",filters:"resetFiltersText"}[t.reset]??"resetBothText";return{kind:r,size:n,headingLevel:s,title:"",text:"",actions:[{id:"reset-query",text:this.text(e),appearance:"outline"}]}}const a=this.getBooleanAttr("actions",!0)&&this.getBooleanAttr("creatable",!0);return{kind:r,size:n,headingLevel:s,title:this.getAttribute("empty-text")||"",text:this.getAttribute("empty-description")||"",actions:a?[{id:"create",text:this.text("createText","create-text")}]:[]}}disconnectedCallback(){this.unbindWindowScroll(),this._rowMenu?.close?.({restoreFocus:!1}),this._rowMenu?.remove(),this._rowMenu=null;for(const e of this._filterOptionPages.values())e.controller?.abort(),clearTimeout(e.searchTimer);this._filterOptionPages.clear(),this._responsiveObserver?.disconnect(),this._responsiveObserver=null,this._responsiveWidth=0,this._responsiveTarget=null,this._preferenceUnsubscribe?.(),this._preferenceUnsubscribe=null,this._preferenceKeyBound=void 0,this._rowActionsAbort?.abort(),this._rowActionsAbort=null,this._rowActionsTable=null,this.unbindPageScroll(),this._lateLayoutAbort?.abort(),this._lateLayoutAbort=null,cancelAnimationFrame(this._lateLayoutFrame??0),this._lateLayoutFrame=0,this.clearSearchDebounce(),this._searchPendingProps=null,this._searchHoldKey="",this.stopContextMenuPositions(),this.unbindContextEvent(),this.unbindContextViewport(),this.unBindHoverEvent(),this.unbindColumnResizeEvent(),this.unbindColumnDragEvent(),this.tempSettings=null,this._selectionPortKey="[]",this._abandonedQuery=null!==this._pendingQuerySequence,this._pendingQuerySequence=null,this.state.contextMenu={open:!1},this.state.settingsChecked=!1,this.state.selectIndeterminate=!1;const e=this.getTableData();this.state.data={...e,rows:e.rows.map(e=>({...e,selected:!1,checked:!1,...e.select?.component?{select:{...e.select,component:{...e.select.component,props:{...e.select.component.props,checked:!1}}}}:{}}))},this.refs.contextMenu&&(this.refs.contextMenu.value=null),this.contextTarget?.classList?.remove("active"),this.contextTarget=null,this._portalContainer&&((0,f.render)(null,this._portalContainer),this._portalContainer.remove(),this._portalContainer=null),super.disconnectedCallback()}text(e,t){return t&&this.getAttribute(t)||(0,b.pageText)(E,e,this)}templateContext(){this._renderedCramped=this.columnsAreCramped;const e=this.getPropsContext();return this.createTemplateContext({...e,component:this,list:this.isList,rootClass:this.getRootClass(),rootStyle:this.getRootStyle(),filterText:this.text("filterText","filter-text"),clearText:this.text("clearText","clear-text"),searchPlaceholder:this.text("searchPlaceholder","search-placeholder"),createText:this.text("createText","create-text"),pinColumnLabel:this.text("pinColumnLabel","pin-column-label"),unpinColumnLabel:this.text("unpinColumnLabel","unpin-column-label"),loadingText:this.text("loadingText","loading-text"),emptyText:this.text("emptyText","empty-text"),errorText:this.text("errorText","error-text"),retryText:this.text("retryText","retry-text"),columnMoveLabel:this.text("columnMoveLabel","column-move-label"),filterApplyText:this.text("filterApplyText","filter-apply-text"),columnSearchPlaceholder:this.text("columnSearchPlaceholder","column-search-placeholder"),columnSearchEmptyText:this.text("columnSearchEmptyText","column-search-empty-text")})}setCheckboxHeight(){if(!this.refs.items.size)return;const e=++this._checkboxMeasureToken;requestAnimationFrame(()=>{if(!this.isConnected||e!==this._checkboxMeasureToken)return;const t=(0,y.lF)(this.refs.items);if(!t)return;const{item:n,gap:s,parent:i}=t;this.parentGap=s;const r=n.tagName.toLowerCase().startsWith("sf-")?n.children[0]?.clientHeight:n.clientHeight;if(!r)return;const a=(r+s)*(i.dataset.size||8);if(i.clientHeight<=a)return!1;i.setAttribute("style",`height: ${a}px; overflow: auto;`)})}beforeRender(){super.beforeRender(),this.connectTablePreference(),this.applyTableView(),this._checkboxMeasureToken++,this.refs.items=new Map}_observeResponsiveBox(){if(!this._responsiveObserver||this._responsiveTarget?.isConnected)return;const e=[this.querySelector(".sf-table"),this.parentElement,this.getRootNode()?.host],t=e.find(e=>e?.getBoundingClientRect?.().width>0)??e.find(Boolean)??this;this._responsiveTarget&&this._responsiveObserver.unobserve(this._responsiveTarget),this._responsiveTarget=t,this._responsiveObserver.observe(t)}afterRender(){if(this._observeResponsiveBox(),this.bindRowActionsEvents(this.refs.table?.value),this._windowed&&this.bindWindowScroll(),this._pendingFocusRow){const e=this._pendingFocusRow;return this._pendingFocusRow=null,this._windowOnly=!1,this._entryOnly=!1,void this.focusRow(e,{reveal:!0})}if(this._windowOnly||this._entryOnly)return this._windowOnly=!1,this._entryOnly=!1,this._layoutUnchanged=!1,this.fitCellValues(),this.measurePinnedColumns(),void this.syncWindow();if(this._layoutUnchanged)this._layoutUnchanged=!1;else{if(this.measureWhenCellsDrawn()||(this.measureContentWidths()&&this.applyColumnWidths(),this._contentRetries=0,this.fitCellValues(),this.measurePinnedColumns()),this.hasAttribute("data-sf-page-scroll"))this.bindPageScroll(),this.syncRail(),this.syncStickyHead();else{this.unbindPageScroll();const e=this.refs.table?.value?.tHead;e?.style.transform&&(e.style.transform="")}this.columnsAreCramped!==this._renderedCramped&&(this._crampedRetries??0)<2?(this._crampedRetries=(this._crampedRetries??0)+1,this.requestComponentUpdate("cramped-columns")):this._crampedRetries=0,this.bindPinnedColumnScroll(),this.setCheckboxHeight(),this.bindHoverEvent(),this.bindColumnResizeEvent(),this.bindColumnDragEvent(),this.syncWindow()}}template(){return this.readingLayout(()=>(0,u.b1)(this.templateContext()))}}(0,r.l6)(J,a),J.define("sf-view-table"),t()}catch(Q){t(Q)}})},"2f31b00ad99a"(e,t,n){n.a(e,async(e,s)=>{try{n.d(t,{x:()=>h});var i=n("e577837dd70a"),r=e([i]),a=r.then?(await r)():r;i=a[0];const o=/^(\d{4})-(\d{2})-(\d{2})$/u,l=/^(\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?$/u,c=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?$/u,u=new Set(["date","datetime","time"]);function d(e,t){const n=o.exec(t);if(n)return new Date(Number(n[1]),Number(n[2])-1,Number(n[3]));const s=l.exec(t);if(s)return"time"===e?new Date(2e3,0,1,Number(s[1]),Number(s[2]),Number(s[3]??0)):null;const i=c.exec(t);if(!i)return null;if(i[7]){const e=new Date(t.replace(" ","T"));return Number.isNaN(e.getTime())?null:e}return new Date(Number(i[1]),Number(i[2])-1,Number(i[3]),Number(i[4]),Number(i[5]),Number(i[6]??0))}function h(e,t,n){if(!u.has(e)||"string"!=typeof t||!t.trim())return"";const s=t.trim(),r=d(e,s);if(!r)return"";const a="date"!==e&&!o.test(s);return"time"===e?(0,i.Yq)(r,{date:null,time:"short",node:n}):(0,i.Yq)(r,{date:"medium",time:a?"short":null,node:n})}n.d(t,["J",0,u]),s()}catch(p){s(p)}})},"17828be41e75"(e,t,n){n.d(t,{l6:()=>i});const s=e=>String(e).replace(/-([a-z0-9])/gu,(e,t)=>t.toUpperCase());function i(e,t){const n=e.prototype;for(const[e,i]of Object.entries(t.settings||{})){if(["list","object","state"].includes(i?.type))continue;const t=s(e);let r=n,a=null;for(;r&&r!==globalThis.HTMLElement?.prototype&&r!==Object.prototype&&(a=Object.getOwnPropertyDescriptor(r,t),!a);)r=Object.getPrototypeOf(r);a&&a.get&&!a.set&&Object.defineProperty(r,t,{configurable:!0,get:a.get,set(t){"boolean"===i.type?!0===t||""===t||"true"===t?this.setAttribute(e,""):!1===t&&!0===i.default?this.setAttribute(e,"false"):this.removeAttribute(e):null==t?this.removeAttribute(e):this.setAttribute(e,String(t))}})}return e}},"9d9caaf4f796"(e,t,n){n.a(e,async(e,s)=>{try{n.d(t,{Y5:()=>T,b1:()=>M});var i=n("2a080a730149"),r=n("9d9903b87148"),a=n("efa66f8927d1"),o=n("8137feb490e0"),l=n("80c480e5196c"),c=n("5bfdd9ec12a1"),u=e([i,r,a,o,l]);[i,r,a,o,l]=u.then?(await u)():u;function d(e,t=""){const n=e?.composedPath?.()?.[0],s=[n,e?.target,e?.currentTarget];for(const e of s){if(!e)continue;if(void 0!==e.value)return e.value;const t=e.querySelector?.("input, textarea");if(t&&void 0!==t.value)return t.value}return t}function h(e){const{state:t}=e.component,{value:n}=t.search,s=e.component.getCurrentFilterTags(),r=e.component.getCurrentFilterValues(),a=Object.entries(s||{}).filter(([,e])=>!1!==e?.active);return i.html`
1028
1028
  <div class="sf-table-toolbar sf-table-toolbar--list flex flex-col gap-1/3 flex-none"
1029
1029
  data-sf-filter-tags="${a.length?"1":"0"}">
1030
1030
  <div class="flex items-cross-center gap-1/3 min-w-0">
@@ -1308,7 +1308,7 @@
1308
1308
  </span>`}function c(n,s){if(!s||!n)return i.nothing;let r=n[s.key];if("link"===s.renderer)return R(r);if("actions"===s.key&&e.component?.getActionRowItems){Array.isArray(r)&&r.length&&r.every(e=>e&&"object"==typeof e)||(r=e.component.rowActionItems(n))}if(e.component?.cellEditable?.(n,s))return i.html`<sf-checkbox size=${"1/2"===e.size?"1/2":"1"} data-cell-edit=${s.key}
1309
1309
  ?checked=${!0===r} ?disabled=${e.component.cellPending(n,s)}
1310
1310
  aria-label=${s.label??s.key}
1311
- @change=${t=>e.component.setCellValue(n,s,Boolean(t.target?.checked??t.detail?.checked))}></sf-checkbox>`;if(s.component)return null==r||Array.isArray(r)&&!r.length?"settings"!==s.key||r&&(!Array.isArray(r)||r.length)?F(s.rowComponent||s.component,e.component):F({type:"button-icon",props:{size:"1",appearance:"link",scheme:"on-surface",icon:"menu",ariaLabel:"Меню",value:"menu"}},e.component):z(r,e.component);if(null==r)return i.nothing;if(w.has(s.propertyType??s.property_type??s.type)&&("string"==typeof r||"number"==typeof r)){const e=String(r);return i.html`<span class="sf-table-cell-clip" title=${e}>${e}</span>`}if(!("object"==typeof r&&!Array.isArray(r)&&Boolean(r.component?.type))){const t=e.component?.getTypedCellValue?.(s,r);if(null!=t)return Array.isArray(t)?"avatar"===t[0]?.component?.type?i.html`
1311
+ @change=${t=>e.component.setCellValue(n,s,Boolean(t.target?.checked??t.detail?.checked))}></sf-checkbox>`;if(s.component)return null==r||Array.isArray(r)&&!r.length?"settings"!==s.key||r&&(!Array.isArray(r)||r.length)?F(s.rowComponent||s.component,e.component):F({type:"button-icon",props:{size:"1",appearance:"link",scheme:"on-surface",icon:"menu",ariaLabel:"Меню",value:"menu"}},e.component):z(r,e.component);if(null==r)return i.nothing;if(w.has(s.propertyType??s.property_type??s.type)&&("string"==typeof r||"number"==typeof r)){const t=e.component?.cellText?.(s,r)??String(r);return i.html`<span class="sf-table-cell-clip" title=${t}>${t}</span>`}if(!("object"==typeof r&&!Array.isArray(r)&&Boolean(r.component?.type))){const t=e.component?.getTypedCellValue?.(s,r);if(null!=t)return Array.isArray(t)?"avatar"===t[0]?.component?.type?i.html`
1312
1312
  <div class="flex flex-nowrap items-cross-center gap-1/3">
1313
1313
  ${z(t[0],e.component)}
1314
1314
  <span style="min-inline-size: 0">
@@ -1437,4 +1437,4 @@
1437
1437
  ticket. Closed, it still took a box of its own, and in a card that
1438
1438
  spaces its parts that box became the gap above Show more: three
1439
1439
  spacings instead of one. -->
1440
- `}s()}catch(L){s(L)}})},"5bfdd9ec12a1"(e,t,n){n.d(t,{O:()=>r});const s=["/","./","../","#","?"];function i(e){if("string"!=typeof e)return null;const t=e.trim();if(!t)return null;if(t.startsWith("//"))return null;if(s.some(e=>t.startsWith(e)))return t;try{const e=new URL(t);return"http:"===e.protocol||"https:"===e.protocol?t:null}catch{return null}}function r(e){if(!e||"object"!=typeof e||Array.isArray(e))return null;const t=null===e.text||void 0===e.text?"":String(e.text),n=null===e.subtext||void 0===e.subtext?null:String(e.subtext);return{href:i(e.href),subtext:n,text:t}}},"5b7d7695b41b"(e){e.exports=globalThis.SF&&globalThis.SF.runtimeModule?globalThis.SF.runtimeModule("element-manifest",1):new Promise((e,t)=>globalThis.addEventListener("sf-runtime-ready",()=>globalThis.SF.runtimeModule("element-manifest",1).then(e,t),{once:!0}))},"80c480e5196c"(e){e.exports=globalThis.SF&&globalThis.SF.runtimeModule?globalThis.SF.runtimeModule("lit/directive-helpers.js",1):new Promise((e,t)=>globalThis.addEventListener("sf-runtime-ready",()=>globalThis.SF.runtimeModule("lit/directive-helpers.js",1).then(e,t),{once:!0}))},"9d9903b87148"(e){e.exports=globalThis.SF&&globalThis.SF.runtimeModule?globalThis.SF.runtimeModule("lit/directives/keyed.js",1):new Promise((e,t)=>globalThis.addEventListener("sf-runtime-ready",()=>globalThis.SF.runtimeModule("lit/directives/keyed.js",1).then(e,t),{once:!0}))},"8137feb490e0"(e){e.exports=globalThis.SF&&globalThis.SF.runtimeModule?globalThis.SF.runtimeModule("lit/directives/ref.js",1):new Promise((e,t)=>globalThis.addEventListener("sf-runtime-ready",()=>globalThis.SF.runtimeModule("lit/directives/ref.js",1).then(e,t),{once:!0}))},efa66f8927d1(e){e.exports=globalThis.SF&&globalThis.SF.runtimeModule?globalThis.SF.runtimeModule("lit/directives/repeat.js",1):new Promise((e,t)=>globalThis.addEventListener("sf-runtime-ready",()=>globalThis.SF.runtimeModule("lit/directives/repeat.js",1).then(e,t),{once:!0}))},"073f05ff1a81"(e){e.exports=globalThis.SF&&globalThis.SF.runtimeModule?globalThis.SF.runtimeModule("lit/directives/unsafe-html.js",1):new Promise((e,t)=>globalThis.addEventListener("sf-runtime-ready",()=>globalThis.SF.runtimeModule("lit/directives/unsafe-html.js",1).then(e,t),{once:!0}))},"2a080a730149"(e){e.exports=globalThis.SF&&globalThis.SF.runtimeModule?globalThis.SF.runtimeModule("lit",1):new Promise((e,t)=>globalThis.addEventListener("sf-runtime-ready",()=>globalThis.SF.runtimeModule("lit",1).then(e,t),{once:!0}))},"43090d1c8307"(e){e.exports=globalThis.SF&&globalThis.SF.runtimeModule?globalThis.SF.runtimeModule("page-language",1):new Promise((e,t)=>globalThis.addEventListener("sf-runtime-ready",()=>globalThis.SF.runtimeModule("page-language",1).then(e,t),{once:!0}))},"116963e5e31b"(e){e.exports=globalThis.SF&&globalThis.SF.runtimeModule?globalThis.SF.runtimeModule("position",1):new Promise((e,t)=>globalThis.addEventListener("sf-runtime-ready",()=>globalThis.SF.runtimeModule("position",1).then(e,t),{once:!0}))},deb1a4d61565(e){e.exports=globalThis.SF&&globalThis.SF.runtimeModule?globalThis.SF.runtimeModule("smart-base",1):new Promise((e,t)=>globalThis.addEventListener("sf-runtime-ready",()=>globalThis.SF.runtimeModule("smart-base",1).then(e,t),{once:!0}))},f8651e83c6c6(e){e.exports=JSON.parse('{"$comment":"Dated aliases of sf-view-table for the shim (core/js/aliases.js, standard §16 item 20, vocabulary §9). mode: same-detail (the shim sends the new and the old name), detail-adds (the old name gets the larger new detail), split (the old detail from the element\'s adapter, sfAliasAdapters), host-attribute (no shim).","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","aliases":[{"from":"aria-label","to":null,"kind":"attribute","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","mode":"host-attribute","section":"§3.1, §4.8","note":"stays a host attribute, read for the accessible name; no shim"},{"from":"sf-table-action-intent","to":"sf-table-apply","kind":"event","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","mode":"split","cancelable":false,"section":"§8, §16 item 20, vocabulary §9","note":"vocabulary §5 apply {action, scope, ids, revisions}; the old detail {action_id, record_ids} is made by the element\'s adapter (vocabulary §9: sf-table-action-intent → sf-table-apply)"},{"from":"sf-table-create-intent","to":"sf-table-create","kind":"event","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","mode":"same-detail","cancelable":false,"section":"§8, §16 item 20, vocabulary §9","note":"vocabulary §5 create; the detail {item} is unchanged"},{"from":"sf-port-output","to":"sf-table-select","kind":"event","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","mode":"split","cancelable":false,"section":"§8, §16 item 20, vocabulary §9","note":"vocabulary §5 select {ids}; the composition port\'s old detail {port: selection, value} is made by the element\'s adapter"},{"from":"sf-table-query-intent","to":"sf-table-query","kind":"event","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","mode":"same-detail","cancelable":false,"section":"§8, §16 item 20, vocabulary §9","note":"vocabulary §5.1: sf-table-query-intent → sf-table-query; the detail {reason, context, sequence} is unchanged"},{"from":"sf-table-retry","to":"sf-table-refresh","kind":"event","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","mode":"same-detail","cancelable":false,"section":"§8, §16 item 20, vocabulary §9","note":"vocabulary §5 refresh (table-retry)"},{"from":"sf-table-tree-toggle","to":"sf-table-expand","kind":"event","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","mode":"same-detail","cancelable":false,"section":"§8, §16 item 20, vocabulary §9","note":"vocabulary §5 expand; the detail {id, expanded} is unchanged"},{"from":"sf-table-tree-more","to":"sf-table-load-more","kind":"event","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","mode":"detail-adds","cancelable":false,"section":"§8, §16 item 20, vocabulary §9","note":"vocabulary §5 load-more; the new detail adds direction: after to {parent, cursor}"},{"from":"sf-table-rows-reorder","to":"sf-table-move","kind":"event","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","mode":"same-detail","cancelable":false,"section":"§8, §16 item 20, vocabulary §9","note":"vocabulary §5 move; the detail {ids, before, order} is unchanged"},{"from":"sf-table-column-settings-change","to":"sf-table-save","kind":"event","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","mode":"detail-adds","cancelable":false,"section":"§8, §16 item 20, vocabulary §9","note":"vocabulary §5 save {kind: columns}; the new detail adds kind to {reason, columnSettings, tableSettingsKey}","when":{"kind":"columns"}},{"from":"sf-table:column-settings-change","to":"sf-table-save","kind":"event","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","mode":"detail-adds","cancelable":false,"section":"§8, §16 item 20, vocabulary §9","note":"vocabulary §5.1: sf-table:column-settings-change → sf-table-save {kind: columns}; a colon name (§8)","when":{"kind":"columns"}},{"from":"onColumnSettingsChange","to":"sf-table-save","kind":"event","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","mode":"detail-adds","cancelable":false,"section":"§8, §16 item 20, vocabulary §9","note":"a camelCase name outside §8 (simai/ui-pro#1); ui-admin listens to it (src/main.ts, src/smart-component-catalog.ts)","when":{"kind":"columns"}},{"from":"onSearchEnd","to":"sf-table-search-change","kind":"event","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","mode":"split","cancelable":false,"section":"§8, §16 item 20, vocabulary §9","note":"a camelCase name outside §8 (simai/ui-pro#1); its detail was the search text itself, made by the element\'s adapter; ui-admin listens to it (src/main.ts, src/smart-component-catalog.ts)"},{"from":"onTemplateSave","to":"sf-table-template-save","kind":"event","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","mode":"same-detail","cancelable":false,"section":"§8, §16 item 20, vocabulary §9","note":"a camelCase name outside §8 (simai/ui-pro#1); ui-admin listens to it"},{"from":"onFilterUpdate","to":"sf-table-filter-change","kind":"event","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","mode":"same-detail","cancelable":false,"section":"§8, §16 item 20, vocabulary §9","note":"a camelCase name outside §8 (simai/ui-pro#1); ui-admin listens to it"},{"from":"sf-table","to":"sf-view-table","kind":"tag","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","section":"rename plan R2 (ui-control RENAME-PLAN-2026-11-03), naming decision 2026-11-02","note":"the element is sf-view-table; sf-table is a subclass defined beside it until the date"},{"from":"sf-table-select","to":"sf-view-table-select","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-apply","to":"sf-view-table-apply","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-save","to":"sf-view-table-save","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-column-settings-reset","to":"sf-view-table-column-settings-reset","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-create","to":"sf-view-table-create","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-filter-change","to":"sf-view-table-filter-change","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-query","to":"sf-view-table-query","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-refresh","to":"sf-view-table-refresh","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-search-change","to":"sf-view-table-search-change","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-sort-change","to":"sf-view-table-sort-change","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-template-delete","to":"sf-view-table-template-delete","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-template-save","to":"sf-view-table-template-save","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-template-select","to":"sf-view-table-template-select","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-toolbar-action","to":"sf-view-table-toolbar-action","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-reference-open","to":"sf-view-table-reference-open","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-expand","to":"sf-view-table-expand","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-load-more","to":"sf-view-table-load-more","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-rows-drag","to":"sf-view-table-rows-drag","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-move","to":"sf-view-table-move","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-cell-set","to":"sf-view-table-cell-set","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-view-change","to":"sf-view-table-view-change","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-window","to":"sf-view-table-window","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"}]}')},c1f17ed5a348(e){e.exports=JSON.parse('{"id":"smart.view-table","tag":"sf-view-table","version":"1.14.0","kind":"leaf","settings":{"selectable":{"type":"boolean","default":true},"settings":{"type":"boolean","default":true},"actions":{"type":"boolean","default":true},"row-actions":{"type":"boolean","default":true},"creatable":{"type":"boolean","default":true},"filter-templates":{"type":"boolean","default":true},"settings-menu":{"type":"boolean","default":true},"pagin":{"type":"boolean","default":false},"filter-text":{"type":"string","default-from":"runtime.filter-text"},"clear-text":{"type":"string","default-from":"runtime.clear-text"},"search-placeholder":{"type":"string","default-from":"runtime.search-placeholder"},"create-text":{"type":"string","default-from":"runtime.create-text"},"pagination-total":{"type":"number","default":10,"integer":true,"min":0},"pagination-page-size":{"type":"number","default":10,"integer":true,"min":1,"max":100},"page-sizes":{"type":"string","default":"10,20,30,40"},"context-menu-columns":{"type":"number","default":1,"integer":true,"min":1,"max":4},"remember-widths":{"type":"boolean","default":false},"table-settings-key":{"type":"string","default":""},"data-state":{"type":"enum","values":["auto","loading","ready","populated","empty","error"],"default":"auto","x-alias":{"populated":"ready"}},"loading-text":{"type":"string","default-from":"runtime.loading-text"},"empty-text":{"type":"string","default-from":"runtime.empty-text"},"empty-description":{"type":"string"},"error-text":{"type":"string","default-from":"runtime.error-text"},"retry-text":{"type":"string","default-from":"runtime.retry-text"},"toolbar":{"type":"boolean","default":true},"pin-column-label":{"type":"string","default-from":"runtime.pin-column-label"},"unpin-column-label":{"type":"string","default-from":"runtime.unpin-column-label"},"column-move-label":{"type":"string","default-from":"runtime.column-move-label"},"column-search-placeholder":{"type":"string","default-from":"runtime.column-search-placeholder"},"column-search-empty-text":{"type":"string","default-from":"runtime.column-search-empty-text"},"vertical-scroll":{"type":"enum","values":["self","page"],"default":"self"},"filter-apply-text":{"type":"string","default-from":"runtime.filter-apply-text"},"layout":{"type":"enum","values":["auto","table","list"],"default":"table"},"list-below":{"type":"number","default":600},"list-fields":{"type":"number","default":3},"size":{"type":"enum","values":["1/2","1"],"default":"1"},"preferences-key":{"type":"string","default":""},"row-actions-visible":{"type":"enum","values":["hover","always"],"default":"hover"},"drag-rows":{"type":"boolean","default":false},"row-reorder":{"type":"boolean","default":false},"inline-edit":{"type":"boolean","default":false},"active-filter-fields":{"type":"list","entries":{"key":"id"}},"bulk-actions":{"type":"list"},"columns":{"type":"list","of":{"key":"string","label":"string"}},"create-items":{"type":"list"},"filter-fields":{"type":"list"},"rows":{"type":"list","entries":{"key":"id","changes":"revision"},"of":{"id":"id","revision":{"type":"string","optional":true}}},"table-data":{"type":"object"},"table-settings":{"type":"object"},"templates":{"type":"list"},"toolbar-actions":{"type":"list"},"sort":{"type":"list","of":{"key":"string","direction":{"type":"enum","values":["asc","desc"]}},"controlled":true},"current":{"type":"string","default":""}},"values":{"selected":{"type":"id","optional":true},"selection":{"type":"list","default":[]}},"events":{"select":{"carries":{"ids":"list"}},"apply":{"carries":{"action":"string","scope":{"type":"enum","values":["entry","selection","filter"]},"ids":"list","revisions":{"type":"object","optional":true}}},"save":{"carries":{"kind":{"type":"enum","values":["columns"]},"reason":"string","column-settings":{"type":"object"},"table-settings-key":{"type":"string"}}},"column-settings-reset":{"carries":{"target":{"type":"enum","values":["personal"]},"table-settings-key":{"type":"string","nullable":true}},"own-verb":true},"create":{"carries":{"item":{"type":"string","nullable":true,"optional":true}}},"filter-change":{"carries":{"template-key":{"type":"string"},"template-label":{"type":"string"},"values":{"type":"object"},"tags":{"type":"object"}},"own-verb":true},"query":{"carries":{"reason":"string","context":"object","sequence":{"type":"number","integer":true}}},"refresh":{"carries":{}},"search-change":{"carries":{"search":"string"},"own-verb":true},"sort-change":{"carries":{"key":{"type":"string","schema":{"minLength":1}},"direction":{"type":"enum","values":["asc","desc",null],"nullable":true}},"own-verb":true},"template-delete":{"carries":{"key":{"type":"string","schema":{"minLength":1}}},"own-verb":true},"template-save":{"carries":{},"own-verb":true},"template-select":{"carries":{"key":{"type":"string","schema":{"minLength":1}}},"own-verb":true},"toolbar-action":{"carries":{"action":"string","href":{"type":"string","nullable":true,"optional":true}},"cancelable":true,"own-verb":true},"reference-open":{"carries":{"field":"string","value":"object","href":"string"},"cancelable":true,"own-verb":true},"expand":{"carries":{"id":"id","expanded":{"type":"boolean","optional":true}}},"load-more":{"carries":{"direction":{"type":"enum","values":["after"]},"parent":{"type":"id","nullable":true},"cursor":{"type":"string","nullable":true}}},"rows-drag":{"carries":{"ids":{"type":"list","schema":{"items":{"type":"string"},"minItems":1}},"source":{"type":"string","nullable":true}},"own-verb":true},"move":{"carries":{"ids":"list","before":{"type":"id","nullable":true},"order":"list"}},"cell-set":{"carries":{"id":"object","key":"string","value":"object","revision":"object"},"own-verb":true},"view-change":{"carries":{"view":"object","everywhere":"boolean"},"own-verb":true},"window":{"carries":{"first":{"type":"number","integer":true},"last":{"type":"number","integer":true}},"own-verb":true}},"actions":{"add-rows":{"with":{"rows":"list"}},"apply-query-result":{"with":{"sequence":{"type":"number","integer":true,"schema":{"minimum":1}},"rows":"list"}},"clear-selection":{},"request-action-intent":{"with":{"action-id":{"type":"string","schema":{"minLength":1}},"record-ids":{"type":"list","schema":{"items":{"type":["string","integer"],"minLength":1},"minItems":1}}},"emits":"apply"},"request-create-intent":{"with":{"item-id":{"type":"string","optional":true,"nullable":true}},"emits":"create"},"request-retry":{"emits":"refresh"},"set-sort":{"with":{"key":{"type":"string","nullable":true},"direction":{"type":"enum","values":["asc","desc"],"nullable":true}}},"toggle-tree-row":{"with":{"row":"object"},"emits":"expand"},"request-tree-more":{"with":{"row":"object"},"emits":"load-more"},"focus-row":{"with":{"id":"id"}}},"port":{"id":"simai.dataview-port","version":"1.0.0","contract":"src/core/contracts/ports/simai.dataview-port/1.0.0/port.json"},"presentation":{"skeleton":{"late":["rows"]}},"host-states":{"data-sf-view-stripes":"boolean","data-sf-page-scroll":"boolean"},"css-variables":{"--sf-table-row-block-size-1/2":{"type":"length","state":"default"},"--sf-table-row-block-size-1":{"type":"length","state":"default"},"--sf-table-row-2-lines-block-size-1/2":{"type":"length","state":"default"},"--sf-table-row-2-lines-block-size-1":{"type":"length","state":"default"},"--sf-table-head-block-size-1/2":{"type":"length","state":"default"},"--sf-table-head-block-size-1":{"type":"length","state":"default"},"--sf-table-toolbar-block-size-1/2":{"type":"length","state":"default"},"--sf-table-toolbar-block-size-1":{"type":"length","state":"default"},"--sf-table-toolbar-gap":{"type":"length","state":"default"},"--sf-table-head--background-color":{"type":"color","state":"default"},"--sf-table-row--background-color":{"type":"color","state":"default"},"--sf-table--cell-spacing":{"type":"length","state":"default"},"--sf-table-cell--line-clamp":{"type":"number","state":"default"},"--sf-table-context-menu--z-index":{"type":"number","state":"open"},"--sf-table-context-menu--max-width":{"type":"length","state":"open"}}}')},"678dc07d76bf"(e){e.exports=JSON.parse('{"title":"Table","events":{"column-settings-reset":{"label":"Column settings reset"},"filter-change":{"label":"Filter changed"},"search-change":{"label":"Search changed"},"sort-change":{"label":"Order changed"},"template-delete":{"label":"Template deleted"},"template-save":{"label":"Template saved"},"template-select":{"label":"Template chosen"},"toolbar-action":{"label":"Toolbar action"},"reference-open":{"label":"Open the linked record"},"rows-drag":{"label":"Rows dragged"},"cell-set":{"label":"Cell value changed"},"view-change":{"label":"Table view changed"},"window":{"label":"Rows shown"}},"runtime":{"actions-column-label":"Actions","apply-text":"Apply","clear-text":"Clear","close-text":"Close","column-move-label":"Move the column","column-search-empty-text":"No field matches","column-search-placeholder":"Search the fields","context-create-options-label":"Ways to create","context-field-filter-label":"Filtering by","context-filter-settings-label":"Filter settings","context-row-actions-label":"Row actions","context-save-template-label":"Saving the filter as a template","context-table-settings-label":"Table settings","context-template-actions-label":"Template actions","context-view-actions-label":"View actions","create-options-label":"Ways to create","create-text":"Create","default-template-text":"Default","delete-action-text":"Delete","edit-action-text":"Edit","empty-text":"No data","error-text":"The data could not be loaded","field-word-text":"field","fields-tab-text":"Fields","filter-apply-text":"Apply","filter-settings-label":"Filter settings","filter-text":"Filter","list-filter-label":"Filter, {count} active","loading-text":"Loading","make-default-label":"Make it the default","menu-label":"Menu","operator-any":"Any date","operator-between":"Range","operator-contains":"Contains","operator-eq":"Exactly","operator-gt":"Greater than","operator-gte":"Greater or equal","operator-in":"In the list","operator-lt":"Less than","operator-lte":"Less or equal","operator-month":"This month","operator-starts-with":"Starts with","operator-today":"Today","operator-week":"This week","pin-column-label":"Pin the column","rename-text":"Rename","reset-both-text":"Reset the search and filters","reset-filters-text":"Reset the filters","reset-search-text":"Clear the search","reset-text":"Reset","restore-text":"Restore","retry-text":"Try again","row-actions-label":"Row actions","save-for-everyone-label":"Save for everyone","save-template-label":"Save the filter as a template","search-placeholder":"Search","select-all-label":"Select every row","select-row-label":"Select the row","settings-column-label":"Settings","settings-fields-tab":"Fields","settings-view-tab":"View","sort-ascending":"ascending","sort-descending":"descending","sort-label":"Sort","sort-none":"As the host orders it","template-actions-label":"Template actions","template-move-label":"Move the template","template-name-placeholder":"Name","template-pin-label":"Keep the template at the top","templates-tab-text":"Templates","tree-collapse":"Collapse","tree-expand":"Expand","tree-more":"Show more","unpin-column-label":"Unpin the column","untitled-template-text":"All records","view-action-text":"View","view-density":"Rows","view-density-compact":"Compact","view-density-normal":"Normal","view-density-spacious":"Spacious","view-everywhere":"For all my tables","view-lines":"Lines between columns","view-reset":"Reset the view","view-single-line":"Text on one line","view-sticky-head":"Keep the filter and the head in view","view-stripes":"Alternate rows"}}')},"32294b89604f"(e){e.exports=JSON.parse('{"title":"Таблица","events":{"column-settings-reset":{"label":"Настройки столбцов сброшены"},"filter-change":{"label":"Фильтр изменён"},"search-change":{"label":"Поиск изменён"},"sort-change":{"label":"Порядок изменён"},"template-delete":{"label":"Шаблон удалён"},"template-save":{"label":"Шаблон сохранён"},"template-select":{"label":"Шаблон выбран"},"toolbar-action":{"label":"Действие панели"},"reference-open":{"label":"Открыть связанную запись"},"rows-drag":{"label":"Строки перетащены"},"cell-set":{"label":"Значение в ячейке изменено"},"view-change":{"label":"Вид таблицы изменён"},"window":{"label":"Показаны строки"}},"runtime":{"actions-column-label":"Действия","apply-text":"Применить","clear-text":"Очистить","close-text":"Закрыть","column-move-label":"Переместить столбец","column-search-empty-text":"Поля не найдены","column-search-placeholder":"Поиск по полям","context-create-options-label":"Варианты создания","context-field-filter-label":"Настройка фильтра","context-filter-settings-label":"Настройки фильтра","context-row-actions-label":"Действия со строкой","context-save-template-label":"Сохранение шаблона фильтра","context-table-settings-label":"Настройки таблицы","context-template-actions-label":"Действия с шаблоном","context-view-actions-label":"Действия с представлением","create-options-label":"Варианты создания","create-text":"Создать","default-template-text":"По умолчанию","delete-action-text":"Удалить","edit-action-text":"Редактировать","empty-text":"Нет данных","error-text":"Не удалось загрузить данные","field-word-text":"поле","fields-tab-text":"Поля","filter-apply-text":"Применить","filter-settings-label":"Настройки фильтра","filter-text":"Фильтр","list-filter-label":"Фильтр, активных условий: {count}","loading-text":"Загрузка данных","make-default-label":"Сделать по умолчанию","menu-label":"Меню","operator-any":"Любая дата","operator-between":"Диапазон","operator-contains":"Содержит","operator-eq":"Точно","operator-gt":"Больше чем","operator-gte":"Больше или равно","operator-in":"В списке","operator-lt":"Меньше чем","operator-lte":"Меньше или равно","operator-month":"Месяц","operator-starts-with":"Начинается с","operator-today":"Сегодня","operator-week":"Неделя","pin-column-label":"Закрепить столбец","rename-text":"Переименовать","reset-both-text":"Сбросить поиск и фильтры","reset-filters-text":"Сбросить фильтры","reset-search-text":"Очистить поиск","reset-text":"Сбросить","restore-text":"Восстановить","retry-text":"Повторить","row-actions-label":"Действия со строкой","save-for-everyone-label":"Сохранить для всех","save-template-label":"Сохранение шаблона фильтра","search-placeholder":"Поиск","select-all-label":"Выбрать все строки","select-row-label":"Выбрать строку","settings-column-label":"Настройки","settings-fields-tab":"Поля","settings-view-tab":"Вид","sort-ascending":"по возрастанию","sort-descending":"по убыванию","sort-label":"Сортировка","sort-none":"Как задано источником","template-actions-label":"Действия с шаблоном","template-move-label":"Переместить шаблон","template-name-placeholder":"Название","template-pin-label":"Закрепить шаблон сверху","templates-tab-text":"Шаблоны","tree-collapse":"Свернуть","tree-expand":"Развернуть","tree-more":"Показать ещё","unpin-column-label":"Открепить столбец","untitled-template-text":"Все записи","view-action-text":"Посмотреть","view-density":"Строки","view-density-compact":"Компактно","view-density-normal":"Обычно","view-density-spacious":"Просторно","view-everywhere":"Для всех моих таблиц","view-lines":"Линии между столбцами","view-reset":"Сбросить вид","view-single-line":"Текст в одну строку","view-sticky-head":"Закреплять фильтр и шапку","view-stripes":"Чередовать строки"}}')}};const t={};function n(s){const i=t[s];if(void 0!==i)return i.exports;const r=t[s]={exports:{}};return e[s](r,r.exports,n),r.exports}(()=>{const e="function"==typeof Symbol,t=e?Symbol("webpack queues"):"__webpack_queues__",s=e?Symbol("webpack exports"):"__webpack_exports__",i=e?Symbol("webpack error"):"__webpack_error__",r=e=>{e?.d<1&&(e.d=1,e.forEach(e=>e.r--),e.forEach(e=>e.r--?e.r++:e()))};n.a=(e,n,a)=>{let o;a&&((o=[]).d=-1);const l=new Set,c=e.exports;let u,d,h;const p=new Promise((e,t)=>{h=t,d=e});p[s]=c,p[t]=e=>(o&&e(o),l.forEach(e),p.catch(e=>{})),e.exports=p;n(e=>{let n;u=(e=>e.map(e=>{if(null!==e&&"object"==typeof e){if(e[t])return e;if(e.then){const n=[];n.d=0,e.then(e=>{a[s]=e,r(n)},e=>{a[i]=e,r(n)});const a={};return a[t]=e=>e(n),a}}const n={};return n[t]=e=>{},n[s]=e,n}))(e);const a=()=>u.map(e=>{if(e[i])throw e[i];return e[s]}),c=new Promise(e=>{n=()=>e(a),n.r=0;const s=e=>e!==o&&!l.has(e)&&(l.add(e),e&&!e.d&&(n.r++,e.push(n)));u.map(e=>e[t](s))});return n.r?c:a()},e=>(e?h(p[i]=e):d(c),r(o))),o?.d<0&&(o.d=0)}})(),n.n=e=>{const t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{if(Array.isArray(t))for(var s=0;s<t.length;){var i=t[s++],r=t[s++];n.o(e,i)?0===r&&s++:0===r?Object.defineProperty(e,i,{enumerable:!0,value:t[s++]}):Object.defineProperty(e,i,{enumerable:!0,get:r})}else for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);n("94d60d3691b5")})();
1440
+ `}s()}catch(L){s(L)}})},"5bfdd9ec12a1"(e,t,n){n.d(t,{O:()=>r});const s=["/","./","../","#","?"];function i(e){if("string"!=typeof e)return null;const t=e.trim();if(!t)return null;if(t.startsWith("//"))return null;if(s.some(e=>t.startsWith(e)))return t;try{const e=new URL(t);return"http:"===e.protocol||"https:"===e.protocol?t:null}catch{return null}}function r(e){if(!e||"object"!=typeof e||Array.isArray(e))return null;const t=null===e.text||void 0===e.text?"":String(e.text),n=null===e.subtext||void 0===e.subtext?null:String(e.subtext);return{href:i(e.href),subtext:n,text:t}}},"5b7d7695b41b"(e){e.exports=globalThis.SF&&globalThis.SF.runtimeModule?globalThis.SF.runtimeModule("element-manifest",1):new Promise((e,t)=>globalThis.addEventListener("sf-runtime-ready",()=>globalThis.SF.runtimeModule("element-manifest",1).then(e,t),{once:!0}))},"80c480e5196c"(e){e.exports=globalThis.SF&&globalThis.SF.runtimeModule?globalThis.SF.runtimeModule("lit/directive-helpers.js",1):new Promise((e,t)=>globalThis.addEventListener("sf-runtime-ready",()=>globalThis.SF.runtimeModule("lit/directive-helpers.js",1).then(e,t),{once:!0}))},"9d9903b87148"(e){e.exports=globalThis.SF&&globalThis.SF.runtimeModule?globalThis.SF.runtimeModule("lit/directives/keyed.js",1):new Promise((e,t)=>globalThis.addEventListener("sf-runtime-ready",()=>globalThis.SF.runtimeModule("lit/directives/keyed.js",1).then(e,t),{once:!0}))},"8137feb490e0"(e){e.exports=globalThis.SF&&globalThis.SF.runtimeModule?globalThis.SF.runtimeModule("lit/directives/ref.js",1):new Promise((e,t)=>globalThis.addEventListener("sf-runtime-ready",()=>globalThis.SF.runtimeModule("lit/directives/ref.js",1).then(e,t),{once:!0}))},efa66f8927d1(e){e.exports=globalThis.SF&&globalThis.SF.runtimeModule?globalThis.SF.runtimeModule("lit/directives/repeat.js",1):new Promise((e,t)=>globalThis.addEventListener("sf-runtime-ready",()=>globalThis.SF.runtimeModule("lit/directives/repeat.js",1).then(e,t),{once:!0}))},"073f05ff1a81"(e){e.exports=globalThis.SF&&globalThis.SF.runtimeModule?globalThis.SF.runtimeModule("lit/directives/unsafe-html.js",1):new Promise((e,t)=>globalThis.addEventListener("sf-runtime-ready",()=>globalThis.SF.runtimeModule("lit/directives/unsafe-html.js",1).then(e,t),{once:!0}))},"2a080a730149"(e){e.exports=globalThis.SF&&globalThis.SF.runtimeModule?globalThis.SF.runtimeModule("lit",1):new Promise((e,t)=>globalThis.addEventListener("sf-runtime-ready",()=>globalThis.SF.runtimeModule("lit",1).then(e,t),{once:!0}))},"43090d1c8307"(e){e.exports=globalThis.SF&&globalThis.SF.runtimeModule?globalThis.SF.runtimeModule("page-language",1):new Promise((e,t)=>globalThis.addEventListener("sf-runtime-ready",()=>globalThis.SF.runtimeModule("page-language",1).then(e,t),{once:!0}))},"116963e5e31b"(e){e.exports=globalThis.SF&&globalThis.SF.runtimeModule?globalThis.SF.runtimeModule("position",1):new Promise((e,t)=>globalThis.addEventListener("sf-runtime-ready",()=>globalThis.SF.runtimeModule("position",1).then(e,t),{once:!0}))},deb1a4d61565(e){e.exports=globalThis.SF&&globalThis.SF.runtimeModule?globalThis.SF.runtimeModule("smart-base",1):new Promise((e,t)=>globalThis.addEventListener("sf-runtime-ready",()=>globalThis.SF.runtimeModule("smart-base",1).then(e,t),{once:!0}))},f8651e83c6c6(e){e.exports=JSON.parse('{"$comment":"Dated aliases of sf-view-table for the shim (core/js/aliases.js, standard §16 item 20, vocabulary §9). mode: same-detail (the shim sends the new and the old name), detail-adds (the old name gets the larger new detail), split (the old detail from the element\'s adapter, sfAliasAdapters), host-attribute (no shim).","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","aliases":[{"from":"aria-label","to":null,"kind":"attribute","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","mode":"host-attribute","section":"§3.1, §4.8","note":"stays a host attribute, read for the accessible name; no shim"},{"from":"sf-table-action-intent","to":"sf-table-apply","kind":"event","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","mode":"split","cancelable":false,"section":"§8, §16 item 20, vocabulary §9","note":"vocabulary §5 apply {action, scope, ids, revisions}; the old detail {action_id, record_ids} is made by the element\'s adapter (vocabulary §9: sf-table-action-intent → sf-table-apply)"},{"from":"sf-table-create-intent","to":"sf-table-create","kind":"event","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","mode":"same-detail","cancelable":false,"section":"§8, §16 item 20, vocabulary §9","note":"vocabulary §5 create; the detail {item} is unchanged"},{"from":"sf-port-output","to":"sf-table-select","kind":"event","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","mode":"split","cancelable":false,"section":"§8, §16 item 20, vocabulary §9","note":"vocabulary §5 select {ids}; the composition port\'s old detail {port: selection, value} is made by the element\'s adapter"},{"from":"sf-table-query-intent","to":"sf-table-query","kind":"event","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","mode":"same-detail","cancelable":false,"section":"§8, §16 item 20, vocabulary §9","note":"vocabulary §5.1: sf-table-query-intent → sf-table-query; the detail {reason, context, sequence} is unchanged"},{"from":"sf-table-retry","to":"sf-table-refresh","kind":"event","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","mode":"same-detail","cancelable":false,"section":"§8, §16 item 20, vocabulary §9","note":"vocabulary §5 refresh (table-retry)"},{"from":"sf-table-tree-toggle","to":"sf-table-expand","kind":"event","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","mode":"same-detail","cancelable":false,"section":"§8, §16 item 20, vocabulary §9","note":"vocabulary §5 expand; the detail {id, expanded} is unchanged"},{"from":"sf-table-tree-more","to":"sf-table-load-more","kind":"event","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","mode":"detail-adds","cancelable":false,"section":"§8, §16 item 20, vocabulary §9","note":"vocabulary §5 load-more; the new detail adds direction: after to {parent, cursor}"},{"from":"sf-table-rows-reorder","to":"sf-table-move","kind":"event","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","mode":"same-detail","cancelable":false,"section":"§8, §16 item 20, vocabulary §9","note":"vocabulary §5 move; the detail {ids, before, order} is unchanged"},{"from":"sf-table-column-settings-change","to":"sf-table-save","kind":"event","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","mode":"detail-adds","cancelable":false,"section":"§8, §16 item 20, vocabulary §9","note":"vocabulary §5 save {kind: columns}; the new detail adds kind to {reason, columnSettings, tableSettingsKey}","when":{"kind":"columns"}},{"from":"sf-table:column-settings-change","to":"sf-table-save","kind":"event","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","mode":"detail-adds","cancelable":false,"section":"§8, §16 item 20, vocabulary §9","note":"vocabulary §5.1: sf-table:column-settings-change → sf-table-save {kind: columns}; a colon name (§8)","when":{"kind":"columns"}},{"from":"onColumnSettingsChange","to":"sf-table-save","kind":"event","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","mode":"detail-adds","cancelable":false,"section":"§8, §16 item 20, vocabulary §9","note":"a camelCase name outside §8 (simai/ui-pro#1); ui-admin listens to it (src/main.ts, src/smart-component-catalog.ts)","when":{"kind":"columns"}},{"from":"onSearchEnd","to":"sf-table-search-change","kind":"event","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","mode":"split","cancelable":false,"section":"§8, §16 item 20, vocabulary §9","note":"a camelCase name outside §8 (simai/ui-pro#1); its detail was the search text itself, made by the element\'s adapter; ui-admin listens to it (src/main.ts, src/smart-component-catalog.ts)"},{"from":"onTemplateSave","to":"sf-table-template-save","kind":"event","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","mode":"same-detail","cancelable":false,"section":"§8, §16 item 20, vocabulary §9","note":"a camelCase name outside §8 (simai/ui-pro#1); ui-admin listens to it"},{"from":"onFilterUpdate","to":"sf-table-filter-change","kind":"event","component":"sf-view-table","since":"2026-10-27","remove_after":"2026-12-01","mode":"same-detail","cancelable":false,"section":"§8, §16 item 20, vocabulary §9","note":"a camelCase name outside §8 (simai/ui-pro#1); ui-admin listens to it"},{"from":"sf-table","to":"sf-view-table","kind":"tag","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","section":"rename plan R2 (ui-control RENAME-PLAN-2026-11-03), naming decision 2026-11-02","note":"the element is sf-view-table; sf-table is a subclass defined beside it until the date"},{"from":"sf-table-select","to":"sf-view-table-select","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-apply","to":"sf-view-table-apply","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-save","to":"sf-view-table-save","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-column-settings-reset","to":"sf-view-table-column-settings-reset","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-create","to":"sf-view-table-create","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-filter-change","to":"sf-view-table-filter-change","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-query","to":"sf-view-table-query","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-refresh","to":"sf-view-table-refresh","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-search-change","to":"sf-view-table-search-change","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-sort-change","to":"sf-view-table-sort-change","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-template-delete","to":"sf-view-table-template-delete","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-template-save","to":"sf-view-table-template-save","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-template-select","to":"sf-view-table-template-select","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-toolbar-action","to":"sf-view-table-toolbar-action","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-reference-open","to":"sf-view-table-reference-open","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-expand","to":"sf-view-table-expand","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-load-more","to":"sf-view-table-load-more","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-rows-drag","to":"sf-view-table-rows-drag","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-move","to":"sf-view-table-move","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-cell-set","to":"sf-view-table-cell-set","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-view-change","to":"sf-view-table-view-change","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"},{"from":"sf-table-window","to":"sf-view-table-window","kind":"event","component":"sf-view-table","since":"2026-11-03","remove_after":"2027-01-01","mode":"same-detail","section":"§8","note":"the event name carries the tag"}]}')},c1f17ed5a348(e){e.exports=JSON.parse('{"id":"smart.view-table","tag":"sf-view-table","version":"1.15.0","kind":"leaf","settings":{"selectable":{"type":"boolean","default":true},"settings":{"type":"boolean","default":true},"actions":{"type":"boolean","default":true},"row-actions":{"type":"boolean","default":true},"creatable":{"type":"boolean","default":true},"filter-templates":{"type":"boolean","default":true},"settings-menu":{"type":"boolean","default":true},"pagin":{"type":"boolean","default":false},"filter-text":{"type":"string","default-from":"runtime.filter-text"},"clear-text":{"type":"string","default-from":"runtime.clear-text"},"search-placeholder":{"type":"string","default-from":"runtime.search-placeholder"},"create-text":{"type":"string","default-from":"runtime.create-text"},"pagination-total":{"type":"number","default":10,"integer":true,"min":0},"pagination-page-size":{"type":"number","default":10,"integer":true,"min":1,"max":100},"page-sizes":{"type":"string","default":"10,20,30,40"},"context-menu-columns":{"type":"number","default":1,"integer":true,"min":1,"max":4},"remember-widths":{"type":"boolean","default":false},"table-settings-key":{"type":"string","default":""},"data-state":{"type":"enum","values":["auto","loading","ready","populated","empty","error"],"default":"auto","x-alias":{"populated":"ready"}},"loading-text":{"type":"string","default-from":"runtime.loading-text"},"empty-text":{"type":"string","default-from":"runtime.empty-text"},"empty-description":{"type":"string"},"error-text":{"type":"string","default-from":"runtime.error-text"},"retry-text":{"type":"string","default-from":"runtime.retry-text"},"toolbar":{"type":"boolean","default":true},"pin-column-label":{"type":"string","default-from":"runtime.pin-column-label"},"unpin-column-label":{"type":"string","default-from":"runtime.unpin-column-label"},"column-move-label":{"type":"string","default-from":"runtime.column-move-label"},"column-search-placeholder":{"type":"string","default-from":"runtime.column-search-placeholder"},"column-search-empty-text":{"type":"string","default-from":"runtime.column-search-empty-text"},"vertical-scroll":{"type":"enum","values":["self","page"],"default":"self"},"filter-apply-text":{"type":"string","default-from":"runtime.filter-apply-text"},"layout":{"type":"enum","values":["auto","table","list"],"default":"table"},"list-below":{"type":"number","default":600},"list-fields":{"type":"number","default":3},"size":{"type":"enum","values":["1/2","1"],"default":"1"},"preferences-key":{"type":"string","default":""},"row-actions-visible":{"type":"enum","values":["hover","always"],"default":"hover"},"drag-rows":{"type":"boolean","default":false},"row-reorder":{"type":"boolean","default":false},"inline-edit":{"type":"boolean","default":false},"active-filter-fields":{"type":"list","entries":{"key":"id"}},"bulk-actions":{"type":"list"},"columns":{"type":"list","of":{"key":"string","label":"string"}},"create-items":{"type":"list"},"filter-fields":{"type":"list"},"rows":{"type":"list","entries":{"key":"id","changes":"revision"},"of":{"id":"id","revision":{"type":"string","optional":true}}},"table-data":{"type":"object"},"table-settings":{"type":"object"},"templates":{"type":"list"},"toolbar-actions":{"type":"list"},"sort":{"type":"list","of":{"key":"string","direction":{"type":"enum","values":["asc","desc"]}},"controlled":true},"current":{"type":"string","default":""}},"values":{"selected":{"type":"id","optional":true},"selection":{"type":"list","default":[]}},"events":{"select":{"carries":{"ids":"list"}},"apply":{"carries":{"action":"string","scope":{"type":"enum","values":["entry","selection","filter"]},"ids":"list","revisions":{"type":"object","optional":true}}},"save":{"carries":{"kind":{"type":"enum","values":["columns"]},"reason":"string","column-settings":{"type":"object"},"table-settings-key":{"type":"string"}}},"column-settings-reset":{"carries":{"target":{"type":"enum","values":["personal"]},"table-settings-key":{"type":"string","nullable":true}},"own-verb":true},"create":{"carries":{"item":{"type":"string","nullable":true,"optional":true}}},"filter-change":{"carries":{"template-key":{"type":"string"},"template-label":{"type":"string"},"values":{"type":"object"},"tags":{"type":"object"}},"own-verb":true},"query":{"carries":{"reason":"string","context":"object","sequence":{"type":"number","integer":true}}},"refresh":{"carries":{}},"search-change":{"carries":{"search":"string"},"own-verb":true},"sort-change":{"carries":{"key":{"type":"string","schema":{"minLength":1}},"direction":{"type":"enum","values":["asc","desc",null],"nullable":true}},"own-verb":true},"template-delete":{"carries":{"key":{"type":"string","schema":{"minLength":1}}},"own-verb":true},"template-save":{"carries":{},"own-verb":true},"template-select":{"carries":{"key":{"type":"string","schema":{"minLength":1}}},"own-verb":true},"toolbar-action":{"carries":{"action":"string","href":{"type":"string","nullable":true,"optional":true}},"cancelable":true,"own-verb":true},"reference-open":{"carries":{"field":"string","value":"object","href":"string"},"cancelable":true,"own-verb":true},"expand":{"carries":{"id":"id","expanded":{"type":"boolean","optional":true}}},"load-more":{"carries":{"direction":{"type":"enum","values":["after"]},"parent":{"type":"id","nullable":true},"cursor":{"type":"string","nullable":true}}},"rows-drag":{"carries":{"ids":{"type":"list","schema":{"items":{"type":"string"},"minItems":1}},"source":{"type":"string","nullable":true}},"own-verb":true},"move":{"carries":{"ids":"list","before":{"type":"id","nullable":true},"order":"list"}},"cell-set":{"carries":{"id":"object","key":"string","value":"object","revision":"object"},"own-verb":true},"view-change":{"carries":{"view":"object","everywhere":"boolean"},"own-verb":true},"window":{"carries":{"first":{"type":"number","integer":true},"last":{"type":"number","integer":true}},"own-verb":true}},"actions":{"add-rows":{"with":{"rows":"list"}},"apply-query-result":{"with":{"sequence":{"type":"number","integer":true,"schema":{"minimum":1}},"rows":"list"}},"clear-selection":{},"request-action-intent":{"with":{"action-id":{"type":"string","schema":{"minLength":1}},"record-ids":{"type":"list","schema":{"items":{"type":["string","integer"],"minLength":1},"minItems":1}}},"emits":"apply"},"request-create-intent":{"with":{"item-id":{"type":"string","optional":true,"nullable":true}},"emits":"create"},"request-retry":{"emits":"refresh"},"set-sort":{"with":{"key":{"type":"string","nullable":true},"direction":{"type":"enum","values":["asc","desc"],"nullable":true}}},"toggle-tree-row":{"with":{"row":"object"},"emits":"expand"},"request-tree-more":{"with":{"row":"object"},"emits":"load-more"},"focus-row":{"with":{"id":"id"}}},"port":{"id":"simai.dataview-port","version":"1.0.0","contract":"src/core/contracts/ports/simai.dataview-port/1.0.0/port.json"},"presentation":{"skeleton":{"late":["rows"]}},"host-states":{"data-sf-view-stripes":"boolean","data-sf-page-scroll":"boolean"},"css-variables":{"--sf-table-row-block-size-1/2":{"type":"length","state":"default"},"--sf-table-row-block-size-1":{"type":"length","state":"default"},"--sf-table-row-2-lines-block-size-1/2":{"type":"length","state":"default"},"--sf-table-row-2-lines-block-size-1":{"type":"length","state":"default"},"--sf-table-head-block-size-1/2":{"type":"length","state":"default"},"--sf-table-head-block-size-1":{"type":"length","state":"default"},"--sf-table-toolbar-block-size-1/2":{"type":"length","state":"default"},"--sf-table-toolbar-block-size-1":{"type":"length","state":"default"},"--sf-table-toolbar-gap":{"type":"length","state":"default"},"--sf-table-head--background-color":{"type":"color","state":"default"},"--sf-table-row--background-color":{"type":"color","state":"default"},"--sf-table--cell-spacing":{"type":"length","state":"default"},"--sf-table-cell--line-clamp":{"type":"number","state":"default"},"--sf-table-context-menu--z-index":{"type":"number","state":"open"},"--sf-table-context-menu--max-width":{"type":"length","state":"open"}}}')},"678dc07d76bf"(e){e.exports=JSON.parse('{"title":"Table","events":{"column-settings-reset":{"label":"Column settings reset"},"filter-change":{"label":"Filter changed"},"search-change":{"label":"Search changed"},"sort-change":{"label":"Order changed"},"template-delete":{"label":"Template deleted"},"template-save":{"label":"Template saved"},"template-select":{"label":"Template chosen"},"toolbar-action":{"label":"Toolbar action"},"reference-open":{"label":"Open the linked record"},"rows-drag":{"label":"Rows dragged"},"cell-set":{"label":"Cell value changed"},"view-change":{"label":"Table view changed"},"window":{"label":"Rows shown"}},"runtime":{"actions-column-label":"Actions","apply-text":"Apply","clear-text":"Clear","close-text":"Close","column-move-label":"Move the column","column-search-empty-text":"No field matches","column-search-placeholder":"Search the fields","context-create-options-label":"Ways to create","context-field-filter-label":"Filtering by","context-filter-settings-label":"Filter settings","context-row-actions-label":"Row actions","context-save-template-label":"Saving the filter as a template","context-table-settings-label":"Table settings","context-template-actions-label":"Template actions","context-view-actions-label":"View actions","create-options-label":"Ways to create","create-text":"Create","default-template-text":"Default","delete-action-text":"Delete","edit-action-text":"Edit","empty-text":"No data","error-text":"The data could not be loaded","field-word-text":"field","fields-tab-text":"Fields","filter-apply-text":"Apply","filter-settings-label":"Filter settings","filter-text":"Filter","list-filter-label":"Filter, {count} active","loading-text":"Loading","make-default-label":"Make it the default","menu-label":"Menu","operator-any":"Any date","operator-between":"Range","operator-contains":"Contains","operator-eq":"Exactly","operator-gt":"Greater than","operator-gte":"Greater or equal","operator-in":"In the list","operator-lt":"Less than","operator-lte":"Less or equal","operator-month":"This month","operator-starts-with":"Starts with","operator-today":"Today","operator-week":"This week","pin-column-label":"Pin the column","rename-text":"Rename","reset-both-text":"Reset the search and filters","reset-filters-text":"Reset the filters","reset-search-text":"Clear the search","reset-text":"Reset","restore-text":"Restore","retry-text":"Try again","row-actions-label":"Row actions","save-for-everyone-label":"Save for everyone","save-template-label":"Save the filter as a template","search-placeholder":"Search","select-all-label":"Select every row","select-row-label":"Select the row","settings-column-label":"Settings","settings-fields-tab":"Fields","settings-view-tab":"View","sort-ascending":"ascending","sort-descending":"descending","sort-label":"Sort","sort-none":"As the host orders it","template-actions-label":"Template actions","template-move-label":"Move the template","template-name-placeholder":"Name","template-pin-label":"Keep the template at the top","templates-tab-text":"Templates","tree-collapse":"Collapse","tree-expand":"Expand","tree-more":"Show more","unpin-column-label":"Unpin the column","untitled-template-text":"All records","view-action-text":"View","view-density":"Rows","view-density-compact":"Compact","view-density-normal":"Normal","view-density-spacious":"Spacious","view-everywhere":"For all my tables","view-lines":"Lines between columns","view-reset":"Reset the view","view-single-line":"Text on one line","view-sticky-head":"Keep the filter and the head in view","view-stripes":"Alternate rows"}}')},"32294b89604f"(e){e.exports=JSON.parse('{"title":"Таблица","events":{"column-settings-reset":{"label":"Настройки столбцов сброшены"},"filter-change":{"label":"Фильтр изменён"},"search-change":{"label":"Поиск изменён"},"sort-change":{"label":"Порядок изменён"},"template-delete":{"label":"Шаблон удалён"},"template-save":{"label":"Шаблон сохранён"},"template-select":{"label":"Шаблон выбран"},"toolbar-action":{"label":"Действие панели"},"reference-open":{"label":"Открыть связанную запись"},"rows-drag":{"label":"Строки перетащены"},"cell-set":{"label":"Значение в ячейке изменено"},"view-change":{"label":"Вид таблицы изменён"},"window":{"label":"Показаны строки"}},"runtime":{"actions-column-label":"Действия","apply-text":"Применить","clear-text":"Очистить","close-text":"Закрыть","column-move-label":"Переместить столбец","column-search-empty-text":"Поля не найдены","column-search-placeholder":"Поиск по полям","context-create-options-label":"Варианты создания","context-field-filter-label":"Настройка фильтра","context-filter-settings-label":"Настройки фильтра","context-row-actions-label":"Действия со строкой","context-save-template-label":"Сохранение шаблона фильтра","context-table-settings-label":"Настройки таблицы","context-template-actions-label":"Действия с шаблоном","context-view-actions-label":"Действия с представлением","create-options-label":"Варианты создания","create-text":"Создать","default-template-text":"По умолчанию","delete-action-text":"Удалить","edit-action-text":"Редактировать","empty-text":"Нет данных","error-text":"Не удалось загрузить данные","field-word-text":"поле","fields-tab-text":"Поля","filter-apply-text":"Применить","filter-settings-label":"Настройки фильтра","filter-text":"Фильтр","list-filter-label":"Фильтр, активных условий: {count}","loading-text":"Загрузка данных","make-default-label":"Сделать по умолчанию","menu-label":"Меню","operator-any":"Любая дата","operator-between":"Диапазон","operator-contains":"Содержит","operator-eq":"Точно","operator-gt":"Больше чем","operator-gte":"Больше или равно","operator-in":"В списке","operator-lt":"Меньше чем","operator-lte":"Меньше или равно","operator-month":"Месяц","operator-starts-with":"Начинается с","operator-today":"Сегодня","operator-week":"Неделя","pin-column-label":"Закрепить столбец","rename-text":"Переименовать","reset-both-text":"Сбросить поиск и фильтры","reset-filters-text":"Сбросить фильтры","reset-search-text":"Очистить поиск","reset-text":"Сбросить","restore-text":"Восстановить","retry-text":"Повторить","row-actions-label":"Действия со строкой","save-for-everyone-label":"Сохранить для всех","save-template-label":"Сохранение шаблона фильтра","search-placeholder":"Поиск","select-all-label":"Выбрать все строки","select-row-label":"Выбрать строку","settings-column-label":"Настройки","settings-fields-tab":"Поля","settings-view-tab":"Вид","sort-ascending":"по возрастанию","sort-descending":"по убыванию","sort-label":"Сортировка","sort-none":"Как задано источником","template-actions-label":"Действия с шаблоном","template-move-label":"Переместить шаблон","template-name-placeholder":"Название","template-pin-label":"Закрепить шаблон сверху","templates-tab-text":"Шаблоны","tree-collapse":"Свернуть","tree-expand":"Развернуть","tree-more":"Показать ещё","unpin-column-label":"Открепить столбец","untitled-template-text":"Все записи","view-action-text":"Посмотреть","view-density":"Строки","view-density-compact":"Компактно","view-density-normal":"Обычно","view-density-spacious":"Просторно","view-everywhere":"Для всех моих таблиц","view-lines":"Линии между столбцами","view-reset":"Сбросить вид","view-single-line":"Текст в одну строку","view-sticky-head":"Закреплять фильтр и шапку","view-stripes":"Чередовать строки"}}')}};const t={};function n(s){const i=t[s];if(void 0!==i)return i.exports;const r=t[s]={exports:{}};return e[s](r,r.exports,n),r.exports}(()=>{const e="function"==typeof Symbol,t=e?Symbol("webpack queues"):"__webpack_queues__",s=e?Symbol("webpack exports"):"__webpack_exports__",i=e?Symbol("webpack error"):"__webpack_error__",r=e=>{e?.d<1&&(e.d=1,e.forEach(e=>e.r--),e.forEach(e=>e.r--?e.r++:e()))};n.a=(e,n,a)=>{let o;a&&((o=[]).d=-1);const l=new Set,c=e.exports;let u,d,h;const p=new Promise((e,t)=>{h=t,d=e});p[s]=c,p[t]=e=>(o&&e(o),l.forEach(e),p.catch(e=>{})),e.exports=p;n(e=>{let n;u=(e=>e.map(e=>{if(null!==e&&"object"==typeof e){if(e[t])return e;if(e.then){const n=[];n.d=0,e.then(e=>{a[s]=e,r(n)},e=>{a[i]=e,r(n)});const a={};return a[t]=e=>e(n),a}}const n={};return n[t]=e=>{},n[s]=e,n}))(e);const a=()=>u.map(e=>{if(e[i])throw e[i];return e[s]}),c=new Promise(e=>{n=()=>e(a),n.r=0;const s=e=>e!==o&&!l.has(e)&&(l.add(e),e&&!e.d&&(n.r++,e.push(n)));u.map(e=>e[t](s))});return n.r?c:a()},e=>(e?h(p[i]=e):d(c),r(o))),o?.d<0&&(o.d=0)}})(),n.n=e=>{const t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{if(Array.isArray(t))for(var s=0;s<t.length;){var i=t[s++],r=t[s++];n.o(e,i)?0===r&&s++:0===r?Object.defineProperty(e,i,{enumerable:!0,value:t[s++]}):Object.defineProperty(e,i,{enumerable:!0,get:r})}else for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);n("94d60d3691b5")})();