@scaleflex/asset-picker 0.2.11 → 0.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +38 -52
- package/README.md +195 -11
- package/dist/{asset-picker-BvXr_8iN.cjs → asset-picker-CMsm4Ewp.cjs} +51 -51
- package/dist/{asset-picker-Cd9cgAZ6.js → asset-picker-DCcLalcQ.js} +2 -1
- package/dist/define.cjs +1 -1
- package/dist/define.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +68 -2
- package/dist/react.cjs +1 -1
- package/dist/react.d.ts +82 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +75 -31
- package/dist/types/asset.types.d.ts +6 -1
- package/dist/types/asset.types.d.ts.map +1 -1
- package/dist/utils/asset-helpers.d.ts +80 -0
- package/dist/utils/asset-helpers.d.ts.map +1 -0
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Ts=Object.create;var Gt=Object.defineProperty;var Ms=Object.getOwnPropertyDescriptor;var Ls=Object.getOwnPropertyNames;var Os=Object.getPrototypeOf,Ps=Object.prototype.hasOwnProperty;var Is=(t,e,s,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Ls(e))!Ps.call(t,a)&&a!==s&&Gt(t,a,{get:()=>e[a],enumerable:!(i=Ms(e,a))||i.enumerable});return t};var Ds=(t,e,s)=>(s=t!=null?Ts(Os(t)):{},Is(e||!t||!t.__esModule?Gt(s,"default",{value:t,enumerable:!0}):s,t));const o=require("lit"),c=require("lit/decorators.js");class zs{constructor(e){this.listeners=new Set,this._notifying=!1,this._pendingState=null,this.state=e}getState(){return this.state}setState(e){if(this._notifying){this._pendingState={...this._pendingState||{},...e};return}const s=this.state;this.state={...s,...e},this._notifying=!0;try{this.listeners.forEach(i=>i(this.state,s))}finally{this._notifying=!1}if(this._pendingState){const i=this._pendingState;this._pendingState=null,this.setState(i)}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}destroy(){this.listeners.clear()}}function Rs(){return new zs({config:null,projectToken:"",sassKey:"",brandColor:"",isOpen:!1,activeTab:"assets",viewMode:"grid",searchQuery:"",sortBy:"modified_at",sortDirection:"desc",previewAsset:null,isPreviewOpen:!1,assets:[],folders:[],folderPreviews:{},labels:[],tags:[],currentFolder:null,currentFolderPath:"/",breadcrumb:[],offset:0,limit:100,totalCount:0,totalFolderCount:0,isLoading:!1,isSelectingAll:!1,hasMore:!1,filters:{metadata:{pinned:[],visible:[],applied:{}},pinned:[],visible:[],applied:{}},fileTypes:[],metadataFields:[],regionalVariantGroups:[],regionalFilters:{},selectedAssets:new Map,selectedFolders:new Map,isResolvingFolders:!1})}class js{constructor(e,s){this.host=e,this.store=s,e.addController(this)}get state(){return this.store.getState()}setState(e){this.store.setState(e)}hostConnected(){this.unsubscribe=this.store.subscribe(()=>{this.host.requestUpdate()})}hostDisconnected(){var e;(e=this.unsubscribe)==null||e.call(this)}}function Ns(t){return"extension"in t&&!("path"in t)}class Bs{constructor(e,s){this.lastClickedIndex=-1,this.host=e,this.store=s,e.addController(this)}hostConnected(){}hostDisconnected(){}get _folderSelectionEnabled(){var e;return((e=this.store.getState().config)==null?void 0:e.folderSelection)===!0}_getCombinedList(){const e=this.store.getState();return this._folderSelectionEnabled?[...e.folders,...e.assets]:e.assets}_applyRangeSelection(e,s,i,a){const r=this._getCombinedList();for(let n=e;n<=s;n++){const l=r[n];l&&(Ns(l)?i.set(l.uuid,l):a.set(l.uuid,l))}}handleSelect(e,s,i){var l,d,h,u;const a=this.store.getState(),r=new Map(a.selectedAssets);if(!(((l=a.config)==null?void 0:l.multiSelect)??!0)){r.clear(),r.set(e.uuid,e),this.store.setState({selectedAssets:r,selectedFolders:new Map}),this.lastClickedIndex=s;return}if(i.shiftKey&&this.lastClickedIndex>=0)if(this._folderSelectionEnabled){const f=Math.min(this.lastClickedIndex,s),p=Math.max(this.lastClickedIndex,s),g=new Map(a.selectedFolders);this._applyRangeSelection(f,p,r,g);const m=(d=a.config)==null?void 0:d.maxSelections;if(m&&r.size+g.size>m)return;this.store.setState({selectedAssets:r,selectedFolders:g})}else{const f=Math.min(this.lastClickedIndex,s),p=Math.max(this.lastClickedIndex,s),g=a.assets;for(let _=f;_<=p;_++)g[_]&&r.set(g[_].uuid,g[_]);const m=(h=a.config)==null?void 0:h.maxSelections;if(m&&r.size>m)return;this.store.setState({selectedAssets:r})}else if(i.metaKey||i.ctrlKey){r.has(e.uuid)?r.delete(e.uuid):r.set(e.uuid,e);const f=(u=a.config)==null?void 0:u.maxSelections,p=r.size+(this._folderSelectionEnabled?a.selectedFolders.size:0);if(f&&p>f)return;this.store.setState({selectedAssets:r})}else r.clear(),r.set(e.uuid,e),this.store.setState({selectedAssets:r,selectedFolders:new Map});this.lastClickedIndex=s}handleFolderSelect(e,s,i){var l,d,h;if(!this._folderSelectionEnabled)return;const a=this.store.getState(),r=new Map(a.selectedFolders);if(!(((l=a.config)==null?void 0:l.multiSelect)??!0)){r.clear(),r.set(e.uuid,e),this.store.setState({selectedFolders:r,selectedAssets:new Map}),this.lastClickedIndex=s;return}if(i.shiftKey&&this.lastClickedIndex>=0){const u=Math.min(this.lastClickedIndex,s),f=Math.max(this.lastClickedIndex,s),p=new Map(a.selectedAssets);this._applyRangeSelection(u,f,p,r);const g=(d=a.config)==null?void 0:d.maxSelections;if(g&&p.size+r.size>g)return;this.store.setState({selectedAssets:p,selectedFolders:r})}else if(i.metaKey||i.ctrlKey){r.has(e.uuid)?r.delete(e.uuid):r.set(e.uuid,e);const u=(h=a.config)==null?void 0:h.maxSelections,f=r.size+a.selectedAssets.size;if(u&&f>u)return;this.store.setState({selectedFolders:r})}else r.clear(),r.set(e.uuid,e),this.store.setState({selectedFolders:r,selectedAssets:new Map});this.lastClickedIndex=s}isSelected(e){return this.store.getState().selectedAssets.has(e)}isFolderSelected(e){return this.store.getState().selectedFolders.has(e)}resetRange(){this.lastClickedIndex=-1}selectAll(e){var l;const s=this.store.getState(),i=(l=s.config)==null?void 0:l.maxSelections,a=this._folderSelectionEnabled?s.selectedFolders.size:0,r=new Map,n=i?Math.max(0,Math.min(e.length,i-a)):e.length;for(let d=0;d<n;d++)r.set(e[d].uuid,e[d]);return this.store.setState({selectedAssets:r}),this.lastClickedIndex=-1,r.size}selectAllFolders(e){var n;if(!this._folderSelectionEnabled)return;const s=this.store.getState(),i=(n=s.config)==null?void 0:n.maxSelections,a=new Map,r=i?Math.max(0,Math.min(e.length,i-s.selectedAssets.size)):e.length;for(let l=0;l<r;l++)a.set(e[l].uuid,e[l]);this.store.setState({selectedFolders:a})}clearSelection(){this.store.setState({selectedAssets:new Map,selectedFolders:new Map}),this.lastClickedIndex=-1}getSelectedAssets(){return Array.from(this.store.getState().selectedAssets.values())}getSelectedFolders(){return Array.from(this.store.getState().selectedFolders.values())}}class Us{constructor(e,s){this.host=e,this.onLoadMore=s,e.addController(this)}hostConnected(){}hostDisconnected(){this.disconnect()}observe(e,s){this.disconnect(),this.sentinel=e,this.observer=new IntersectionObserver(i=>{var a;(a=i[0])!=null&&a.isIntersecting&&this.onLoadMore()},{root:s??null,rootMargin:"200px"}),this.observer.observe(e)}disconnect(){this.observer&&this.sentinel&&(this.observer.unobserve(this.sentinel),this.observer.disconnect()),this.observer=void 0,this.sentinel=void 0}}const Kt=5,Me=40,Yt=15;class Vs{constructor(e,s){this.startX=0,this.startY=0,this.startClientX=0,this.startClientY=0,this.preMarqueeSelection=new Map,this.preMarqueeFolderSelection=new Map,this._dragging=!1,this._scrollRAF=null,this._lastMouseEvent=null,this.isActive=!1,this.rect={x:0,y:0,width:0,height:0},this.handleMouseDown=i=>this.onMouseDown(i),this.handleMouseMove=i=>this.onMouseMove(i),this.handleMouseUp=()=>this.onMouseUp(),this.preventSelect=i=>i.preventDefault(),this.host=e,this.store=s,e.addController(this)}hostConnected(){}hostDisconnected(){this.detach()}attach(e){this.detach(),this.container=e,e.addEventListener("mousedown",this.handleMouseDown)}detach(){this.container&&this.container.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("selectstart",this.preventSelect),this.stopAutoScroll(),this._lastMouseEvent=null}isInteractiveTarget(e){return e.composedPath().some(i=>{if(!(i instanceof HTMLElement))return!1;if(i instanceof HTMLButtonElement||i instanceof HTMLInputElement)return!0;const a=i.tagName.toLowerCase();return!!(a.startsWith("ap-asset-")||a.startsWith("ap-folder-")||i.classList.contains("check")||i.classList.contains("check-box"))})}onMouseDown(e){var a;if(e.button!==0||this.isInteractiveTarget(e)||!(((a=this.store.getState().config)==null?void 0:a.multiSelect)??!0))return;const i=this.container.getBoundingClientRect();this.startX=e.clientX-i.left+this.container.scrollLeft,this.startY=e.clientY-i.top+this.container.scrollTop,this.startClientX=e.clientX,this.startClientY=e.clientY,this._dragging=!1,this.isActive=!1,document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}onMouseMove(e){var s;if(this.container){if(!this._dragging){const i=Math.abs(e.clientX-this.startClientX),a=Math.abs(e.clientY-this.startClientY);if(i<Kt&&a<Kt)return;this._dragging=!0,this.isActive=!0,document.addEventListener("selectstart",this.preventSelect),(s=window.getSelection())==null||s.removeAllRanges(),this.preMarqueeSelection=new Map(this.store.getState().selectedAssets),this.preMarqueeFolderSelection=new Map(this.store.getState().selectedFolders)}this._lastMouseEvent=e,this.updateMarqueeRect(e),this.startAutoScroll(e)}}updateMarqueeRect(e){if(!this.container)return;const s=this.container.getBoundingClientRect(),i=e.clientX-s.left+this.container.scrollLeft,a=e.clientY-s.top+this.container.scrollTop;let r=Math.min(this.startX,i),n=Math.min(this.startY,a),l=Math.abs(i-this.startX),d=Math.abs(a-this.startY);const h=this.container.scrollWidth,u=this.container.scrollHeight;r+l>h&&(l=h-r),n+d>u&&(d=u-n),r<0&&(l+=r,r=0),n<0&&(d+=n,n=0),this.rect={x:r,y:n,width:l,height:d},this.host.requestUpdate(),this.selectIntersecting()}startAutoScroll(e){if(!this.container)return;if(this.container.scrollHeight<=this.container.clientHeight){this.stopAutoScroll();return}const s=this.container.getBoundingClientRect(),i=e.clientY-s.top,a=s.bottom-e.clientY,r=i<Me||a<Me;r&&!this._scrollRAF?this._scrollRAF=requestAnimationFrame(()=>this.autoScrollTick()):r||this.stopAutoScroll()}autoScrollTick(){if(this._scrollRAF=null,!this.container||!this._dragging||!this._lastMouseEvent||this.container.scrollHeight<=this.container.clientHeight)return;const e=this.container.getBoundingClientRect(),s=this._lastMouseEvent,i=s.clientY-e.top,a=e.bottom-s.clientY;let r=0;i<Me?r=-Yt*(1-i/Me):a<Me&&(r=Yt*(1-a/Me)),r!==0&&(this.container.scrollTop+=r,this.updateMarqueeRect(s),this._scrollRAF=requestAnimationFrame(()=>this.autoScrollTick()))}stopAutoScroll(){this._scrollRAF&&(cancelAnimationFrame(this._scrollRAF),this._scrollRAF=null)}onMouseUp(){document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("selectstart",this.preventSelect),this.stopAutoScroll(),this._lastMouseEvent=null,this._dragging&&(this.isActive=!1,this._dragging=!1,this.rect={x:0,y:0,width:0,height:0},this.host.requestUpdate())}querySelectableElements(){const e=[],s=[];for(const i of Array.from(this.container.children))if(i.shadowRoot){const a=i.shadowRoot.querySelectorAll("[data-asset-uuid]");a.length>0&&e.push(...Array.from(a));const r=i.shadowRoot.querySelectorAll("[data-folder-uuid]");r.length>0&&s.push(...Array.from(r))}return e.length===0&&e.push(...Array.from(this.container.querySelectorAll("[data-asset-uuid]"))),s.length===0&&s.push(...Array.from(this.container.querySelectorAll("[data-folder-uuid]"))),{assetCards:e,folderCards:s}}getCardRelativeRect(e){const s=e.getBoundingClientRect(),i=this.container.getBoundingClientRect();return{x:s.left-i.left+this.container.scrollLeft,y:s.top-i.top+this.container.scrollTop,width:s.width,height:s.height}}intersectsMarquee(e){return this.rect.x<e.x+e.width&&this.rect.x+this.rect.width>e.x&&this.rect.y<e.y+e.height&&this.rect.y+this.rect.height>e.y}selectIntersecting(){var h,u;if(!this.container)return;const e=this.store.getState(),s=((h=e.config)==null?void 0:h.folderSelection)===!0,{assetCards:i,folderCards:a}=this.querySelectableElements(),r=new Map(this.preMarqueeSelection),n=s?new Map(this.preMarqueeFolderSelection):e.selectedFolders;i.forEach(f=>{const p=this.getCardRelativeRect(f),g=f.dataset.assetUuid;if(this.intersectsMarquee(p)){const m=e.assets.find(_=>_.uuid===g);m&&r.set(g,m)}}),s&&a.forEach(f=>{const p=this.getCardRelativeRect(f),g=f.dataset.folderUuid;if(this.intersectsMarquee(p)){const m=e.folders.find(_=>_.uuid===g);m&&n.set(g,m)}});const l=(u=e.config)==null?void 0:u.maxSelections,d=r.size+(s?n.size:0);if(l&&d>l){const f=Array.from(r.entries()).slice(0,Math.max(0,l-n.size));this.store.setState({selectedAssets:new Map(f),...s?{selectedFolders:n}:{}})}else this.store.setState({selectedAssets:r,...s?{selectedFolders:n}:{}})}}class qs{constructor(e,s){this.auth=e;const i=e.projectToken;this.baseUrl=s||`https://api.filerobot.com/${i}/v5`,e.mode==="sassKey"&&(this.sassKey=e.sassKey)}setSassKey(e){this.sassKey=e}getSecurityTemplateKey(){if(this.auth.mode==="securityTemplate")return this.auth.securityTemplateKey}_applyAuthHeaders(e){this.sassKey?e["X-Filerobot-Key"]=this.sassKey:this.auth.mode==="securityTemplate"&&(e["X-Filerobot-Key"]=this.auth.securityTemplateKey)}async request(e,s){const i=new URL(`${this.baseUrl}${e}`);s&&Object.entries(s).forEach(([l,d])=>{d!=null&&(Array.isArray(d)?i.searchParams.set(l,d.join(",")):i.searchParams.set(l,String(d)))});const a={};this._applyAuthHeaders(a);const r=new AbortController,n=setTimeout(()=>r.abort(),3e4);try{const l=await fetch(i.toString(),{headers:a,signal:r.signal});if(clearTimeout(n),!l.ok){let h=`API error: ${l.status} ${l.statusText}`;try{const u=await l.json();u.msg&&(h=`API error: ${l.status} - ${u.msg}`)}catch{}throw new Error(h)}const d=await l.json();if(d.status==="error")throw new Error(`API error: ${d.msg||"Unknown error"}`);return d}catch(l){throw clearTimeout(n),l instanceof DOMException&&l.name==="AbortError"?new Error("API request timed out"):l}}async post(e,s){const i=new URL(`${this.baseUrl}${e}`),a={"Content-Type":"application/json"};this._applyAuthHeaders(a);const r=new AbortController,n=setTimeout(()=>r.abort(),3e4);try{const l=await fetch(i.toString(),{method:"POST",headers:a,body:JSON.stringify(s),signal:r.signal});if(clearTimeout(n),!l.ok){let h=`API error: ${l.status} ${l.statusText}`;try{const u=await l.json();u.msg&&(h=`API error: ${l.status} - ${u.msg}`)}catch{}throw new Error(h)}const d=await l.json();if(d.status==="error")throw new Error(`API error: ${d.msg||"Unknown error"}`);return d}catch(l){throw clearTimeout(n),l instanceof DOMException&&l.name==="AbortError"?new Error("API request timed out"):l}}}function Hs(t){const e={offset:t.offset??0,limit:t.limit??100,format:"json,regvar:api,select:internal",preview:2301,recursive:t.recursive??1},s=t.sort_by??"created_at",i=t.sort_direction??"desc",a={created_at:"created_at",modified_at:"modified_at",name:"name",size:"size",type:"type"};e.sort=`${a[s]||s}:${i}`,t.folder&&(e.folder=t.folder);const r=[];return t.search&&r.push(t.search),t.q&&r.push(t.q),r.length>0&&(e.q=r.join(" ")),e}async function qe(t,e){const s=Hs(e);return t.request("/files",s)}async function Xt(t,e){const s={folder:e.folder,recursive:e.recursive??1},i=[];return e.search&&i.push(e.search),e.q&&i.push(e.q),i.length>0&&(s.q=i.join(" ")),t.request("/files/stats",s)}async function Gs(t,e){const s={recursive:(e==null?void 0:e.recursive)??0,folder:(e==null?void 0:e.folderPath)??"/",limit:(e==null?void 0:e.limit)??1e3,offset:(e==null?void 0:e.offset)??0};e!=null&&e.q&&(s.q=e.q);const i=(e==null?void 0:e.sort_by)??"created_at",a=(e==null?void 0:e.sort_direction)??"asc",r={created_at:"created_at",modified_at:"modified_at",name:"name"};return s.sort=`${r[i]||i}:${a}`,await t.request("/folders",s)}async function Ks(t,e){return e.length===0?{}:(await t.post("/folders/previews",{folders:e})).folders||{}}async function Ys(t){return await t.request("/labels")}async function Xs(t){return((await t.request("/tags")).tags||[]).map(i=>({...i,label:i.names.en||Object.values(i.names)[0]||""})).filter(i=>i.label).sort((i,a)=>i.label.localeCompare(a.label))}async function Ws(t){const e=t.getSecurityTemplateKey();if(!e)throw new Error("Security template key is required for SASS key exchange");return(await t.request(`/key/${e}`)).key}const v={TYPE:"type",MIME_TYPE:"mimetype",METADATA:"metadata",DATE:"date",APPROVAL:"approval",SIZE:"size",LICENSE_EXPIRY:"asset_expiration",TAGS:"tags",IMAGE:"image",LABELS:"labels",PRODUCT_REF:"product_ref",FACES:"faces",COLOR:"color"},R={STATUS:"approval_status",APPROVER:"task_approver",REQUESTOR:"task_requester",DUE_DATE:"task_duedate"},x={IS:":",RANGE:"..",IS_NOT:":-",IS_EXACT:":=",CONTAINS:"~",CONTAINS_IN_TEXT:"~~~",GREATER_THAN_OR_EQUAL:">=",LESS_THAN_OR_EQUAL:"<="},Qs={AND:"AND"},b={NUMERIC:"numeric",SELECT_ONE:"select-one",MULTI_SELECT:"multi-select",TEXT_AREA:"textarea",TEXT:"text",SUPERTAGS:"tags",DATE:"date",BOOLEAN:"boolean",ATTACHMENTS_ASSETS:"attachments-assets",ATTACHMENT_URI:"attachment-uri",GEO_POINT:"geopoint",DECIMAL2:"decimal2",INTEGER_LIST:"integer-list"},vt={[b.DATE]:"date_",[b.BOOLEAN]:"bool_",[b.NUMERIC]:"num_",[b.DECIMAL2]:"dec_",[b.ATTACHMENTS_ASSETS]:"attach_",[b.ATTACHMENT_URI]:"uri_",[b.SELECT_ONE]:"one_",[b.MULTI_SELECT]:"multi_",[b.SUPERTAGS]:"tags_",[b.TEXT]:"text_",[b.TEXT_AREA]:"area_",[b.GEO_POINT]:"geo_",[b.INTEGER_LIST]:"intlist_"};Object.fromEntries(Object.entries(vt).map(([t,e])=>[e,t]));const os=Object.values(vt),He={PRESET:"preset",AFTER:"after",BEFORE:"before",BETWEEN:"between",SPECIFIC:"specific"},Wt={EMPTY:"empty",NOT_EMPTY:"non-empty"},H="empty",G="non-empty",be="specific",kt=10,St=10,at=10,ns="filters:pinned:",ls="metadata:pinned:",Qt=[v.DATE,v.TYPE,v.SIZE],cs=x.IS,ot="20",nt="1",Zs=0,Js=[{key:v.DATE,label:"Date",icon:"calendar",type:"date"},{key:v.TYPE,label:"Format",icon:"file-type",type:"string"},{key:v.SIZE,label:"Size",icon:"scaling",type:"string"},{key:v.LICENSE_EXPIRY,label:"License expiry",icon:"history",type:"date"},{key:v.TAGS,label:"Tags",icon:"hash",type:"string"},{key:v.LABELS,label:"Labels",icon:"tag",type:"string"},{key:v.PRODUCT_REF,label:"Products",icon:"box",type:"string"},{key:v.IMAGE,label:"Image",icon:"image",type:"string"},{key:v.COLOR,label:"Color",icon:"swatch-book",type:"string"}],ei={key:v.METADATA,label:"Metadata",icon:"file-text",type:"string"},ti={key:v.APPROVAL,label:"Approval",icon:"badge-check",type:"string"},Pt=[ei,...Js,ti],Le={[v.TYPE]:"Format",[v.DATE]:"Date",[v.SIZE]:"Size",[v.LICENSE_EXPIRY]:"License expiry",[v.TAGS]:"Tags",[v.LABELS]:"Labels",[v.PRODUCT_REF]:"Products",[v.IMAGE]:"Image",[v.COLOR]:"Color",[v.METADATA]:"Metadata",[v.APPROVAL]:"Approval"},j={IMAGE:"image",VIDEO:"video",AUDIO:"audio",DOCUMENT:"document",ARCHIVE:"archive",DESIGN_TEMPLATE:"template_fdt",OTHER:"other",FONTS:"font"},ct=[{value:j.IMAGE,label:"Image",icon:"image"},{value:j.VIDEO,label:"Video",icon:"clapperboard"},{value:j.AUDIO,label:"Audio",icon:"music"},{value:j.DOCUMENT,label:"Document",icon:"document"},{value:j.ARCHIVE,label:"Archive",icon:"archive"},{value:j.DESIGN_TEMPLATE,label:"Design template",icon:"layout-template"},{value:j.FONTS,label:"Fonts",icon:"text"},{value:j.OTHER,label:"Other",icon:"layout-grid"}],si={[j.IMAGE]:["jpg","jpeg","png","gif","webp","svg","bmp","ico","tiff","tif","avif","heic","heif","psd","eps"],[j.VIDEO]:["mp4","webm","ogg","mov","avi","mkv","flv","wmv","m4v"],[j.AUDIO]:["mp3","wav","ogg","flac","aac","wma","m4a","opus"],[j.DOCUMENT]:["pdf","doc","docx","xls","xlsx","ppt","pptx","txt","csv","rtf","odt","ods","odp","html"],[j.ARCHIVE]:["zip","rar","7z","tar","gz","bz2","xz"],[j.FONTS]:["ttf","otf","woff","woff2","eot"]},Ct={RESOLUTION:0,ORIENTATION:1,FACES:2},ii=[{value:"small",label:"Small"},{value:"medium",label:"Medium"},{value:"large",label:"Large"}],ai=[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"},{value:"square",label:"Square"},{value:"panorama",label:"Panorama"}],ri=[{value:"none",label:"None"},{value:"1",label:"1"},{value:"2",label:"2"},{value:"3..",label:"3+"}],ds=[{value:"created",label:"Created at"},{value:"updated",label:"Updated at"}],Dt=[{value:"today",label:"Today"},{value:"before",label:"Before date"},{value:"last_week",label:"Last week"},{value:"after",label:"After date"},{value:"last_month",label:"Last month"},{value:"between",label:"Between dates"},{value:"last_year",label:"Last year"}],ps=[{value:"today",label:"Today"},{value:"before",label:"Before date"},{value:"within_week",label:"Within week"},{value:"after",label:"After date"},{value:"within_month",label:"Within month"},{value:"between",label:"Between dates"},{value:"within_year",label:"Within year"},{value:"specific",label:"Specific date"}],oi=[{value:"today",label:"Today"},{value:"before",label:"Before date"},{value:"within_week",label:"Within week"},{value:"after",label:"After date"},{value:"within_month",label:"Within month"},{value:"between",label:"Between dates"},{value:"within_year",label:"Within year"},{value:"specific",label:"Specific date"}],ni=["#ffffff","#99a1af","#000000","#894b00","#e7000b","#ff8904","#fdc700","#9ae600","#008236","#00bcff","#1447e6","#7f22fe","#e60076"],li=[{label:"None (Exact)",value:"0"},{label:"Small",value:"1"},{label:"Medium",value:"2"},{label:"Large",value:"4"}],Et=[{label:"Is",value:x.IS},{label:"Contains",value:x.CONTAINS_IN_TEXT}],ae=[{label:"Is",value:x.IS},{label:"Is not",value:x.IS_NOT}],Ft=[{label:"Is",value:x.IS_EXACT},{label:"Contains",value:x.IS},{label:"Does not contain",value:x.IS_NOT}],At=[{label:"Is",value:x.IS},{label:"Greater than",value:x.GREATER_THAN_OR_EQUAL},{label:"Is not",value:x.IS_NOT},{label:"Less than",value:x.LESS_THAN_OR_EQUAL},{label:"Between",value:x.RANGE}],ci=[{label:"Is",value:x.IS_EXACT},{label:"Is not",value:x.IS_NOT}],Zt=[{label:"Contains",value:x.CONTAINS},{label:"Does not contain",value:x.IS_NOT}],di=[{value:"APPROVED",label:"Approved",icon:"circle-check-big",iconColor:"var(--ap-success, oklch(0.637 0.17 151.295))"},{value:"PENDING",label:"Pending",icon:"clock",iconColor:"var(--ap-warning, oklch(0.734 0.157 69.419))"},{value:"REJECTED",label:"Rejected",icon:"x-circle",iconColor:"var(--ap-destructive, oklch(0.577 0.215 27.325))"},{value:"CANCELLED",label:"Cancelled",icon:"ban",iconColor:"var(--ap-muted-foreground, oklch(0.685 0.033 249.82))"}],ye=[{label:"Empty",value:H},{label:"Not empty",value:G}],Tt=[...ye,{label:"Specific",value:be}],pi=[{label:"Empty",value:H},{label:"Not empty",value:G},{label:"True",value:"true"},{label:"False",value:"false"}],lt={[b.DATE]:"calendar",[b.BOOLEAN]:"toggle-left",[b.NUMERIC]:"file-digit",[b.DECIMAL2]:"decimals-arrow-right",[b.ATTACHMENTS_ASSETS]:"paperclip",[b.ATTACHMENT_URI]:"link-2",[b.SELECT_ONE]:"circle-dot",[b.MULTI_SELECT]:"square-check",[b.SUPERTAGS]:"hash",[b.TEXT]:"text-initial",[b.TEXT_AREA]:"text-align-justify",[b.GEO_POINT]:"locate",[b.INTEGER_LIST]:"list-ordered"},hi={[b.TEXT]:"text",[b.TEXT_AREA]:"text",[b.NUMERIC]:"number",[b.DECIMAL2]:"number",[b.BOOLEAN]:"boolean",[b.SELECT_ONE]:"select-one",[b.MULTI_SELECT]:"multi-select",[b.SUPERTAGS]:"tags",[b.DATE]:"date",[b.GEO_POINT]:"geo",[b.ATTACHMENTS_ASSETS]:"attachment",[b.ATTACHMENT_URI]:"attachment",[b.INTEGER_LIST]:"attachment"};async function ui(t){var i;return(((i=(await t.request("/filters",{filter_by:"filetype",format:"list",limit:200})).filters)==null?void 0:i.file_types)??[]).map(a=>({name:a.name,value:a.value,count:a.count,category:a.category??a.value.split("_")[0],label:gi(a.name)}))}function gi(t){const e=t.indexOf("›");return(e!==-1?t.slice(e+1).trim():t).toUpperCase()}async function fi(t){var m,_;const e=await t.request("/settings"),s=e.settings??e,i=(s==null?void 0:s.metadata)??e.metadata,r=((i==null?void 0:i.model)??[])[Zs],n=i==null?void 0:i.store,d=((n==null?void 0:n.regional_variants_groups)??[]).map(y=>({uuid:y.uuid,label:y.label??y.name??"",variants:(y.variants??[]).map(S=>({api_value:S.api_value??S.value??"",internal_unique_value:S.internal_unique_value??S.api_value??"",label:S.label??S.name??""}))})).filter(y=>y.variants.length>1),h={};for(const y of d)h[y.uuid]=((m=y.variants[0])==null?void 0:m.api_value)??"";const u=(s==null?void 0:s.project_branding)??((_=e.settings)==null?void 0:_.project_branding),f=u==null?void 0:u.brandColor;if(!r)return{fields:[],regionalVariantGroups:d,regionalFilters:h,brandColor:f};const p=r.groups??[],g=[];for(const y of p){const S=y.name||"Root fields";for(const w of y.fields??[]){const E=w.possible_values,M=E==null?void 0:E.map($=>({api_value:$.api_value??$.value??"",internal_unique_value:$.internal_unique_value??$.api_value??"",label:$.label??$.name??$.api_value??""}));g.push({key:w.key??w.ckey,label:w.title??w.label??w.key??"",type:w.type??"text",slug:w.slug,ckey:w.ckey,possible_values:M,group:S,regionalVariantsGroupUuid:w.regional_variants_group_uuid})}}return{fields:g,regionalVariantGroups:d,regionalFilters:h,brandColor:f}}function _e(t){return t.toLocaleDateString("en-CA")}function rt(){return _e(new Date)}function hs(t){const e=new Date;switch(t){case"today":return{from:rt(),to:null};case"last_week":{const s=new Date(e);return s.setDate(s.getDate()-7),{from:_e(s),to:null}}case"within_week":{const s=new Date(e);return s.setDate(s.getDate()+7),{from:rt(),to:_e(s)}}case"last_month":{const s=new Date(e);return s.setDate(s.getDate()-30),{from:_e(s),to:null}}case"within_month":{const s=new Date(e);return s.setDate(s.getDate()+30),{from:rt(),to:_e(s)}}case"last_year":{const s=new Date(e);return s.setDate(s.getDate()-365),{from:_e(s),to:null}}case"within_year":{const s=new Date(e);return s.setDate(s.getDate()+365),{from:rt(),to:_e(s)}}default:return null}}function Jt(t,e){return e?e.type==="date"?mi(e):e.type==="string"?vi(e):!0:!1}function mi(t){return!(!t.kind&&!t.preset||t.kind==="preset"&&!t.preset||t.kind==="between"&&!t.from&&!t.to||t.kind==="after"&&!t.from||t.kind==="before"&&!t.to||t.kind==="specific"&&!t.from||t.from&&t.to&&new Date(t.from)>new Date(t.to))}function vi(t){return!t.values||!Array.isArray(t.values)?!1:t.values.filter(Boolean).length>0}function bi(t,e={}){const s=[];for(const[i,a]of Object.entries(t)){if(!a||!Jt(i,a))continue;const r=yi(i,a);s.push(...r)}for(const[i,a]of Object.entries(e)){if(!a||!Jt(i,a))continue;const r=Ei(i,a);s.push(...r)}return _i(s)}function _i(t){const e=[],s=[],i=[];for(const a of t)a.startsWith("type:")||a.startsWith("type=")?e.push(a):a.startsWith("mimetype:")||a.startsWith("mimetype=")?s.push(a):i.push(a);if(e.length>0&&s.length>0){const a=[...e,...s].join(" , ");i.push(a)}else i.push(...e,...s);return i}function yi(t,e){if(e.type==="date")return us(t,e);if(t===v.IMAGE)return Ci(e);const s=e,{operator:i=cs,values:a=[],logic:r}=s;if(a.length===0)return[];switch(t){case v.SIZE:return xi(t,a,"..");case v.FACES:return wi(t,i,a);case v.TAGS:return xe(t,i,es(a),",",r);case v.LABELS:return xe(t,i,es(a),",",r);case v.COLOR:return $i(i,a,r);case v.TYPE:return ki(a,i);case v.MIME_TYPE:return Si(t,a,i);case v.PRODUCT_REF:return xe(t,"=%",a,",",r);default:return xe(t,i,a,",",r)}}function us(t,e){const s=e.field||"created";if(e.kind===He.PRESET&&e.preset){if(e.preset===Wt.EMPTY)return[`${s}:"empty"`];if(e.preset===Wt.NOT_EMPTY)return[`${s}:"non-empty"`];const i=hs(e.preset);return i?i.to===null?[`${s}>"${i.from}"`]:[`${s}:"${i.from}..${i.to}"`]:[]}if(e.kind===He.AFTER&&e.from)return[`${s}:>"${e.from}"`];if(e.kind===He.BEFORE&&e.to)return[`${s}:<"${e.to}"`];if(e.kind===He.BETWEEN){if(e.from&&e.to)return[`${s}:"${e.from}..${e.to}"`];if(e.from&&!e.to)return[`${s}:>"${e.from}"`];if(!e.from&&e.to)return[`${s}:<"${e.to}"`]}return e.kind===He.SPECIFIC&&e.from?[`${s}:"${e.from}"`]:[]}function xi(t,e,s){return e.length===0?[]:[`${t}:"${e.join(s)}"`]}function wi(t,e,s){return s.length===0?[]:[`${t}${e}"${s.join(",")}"`]}function xe(t,e,s,i,a){if(s.length===0)return[];if(a===Qs.AND)return s.map(n=>`${t}${e}"${n}"`);const r=s.map(n=>`"${n}"`).join(i);return[`${t}${e}${r}`]}function $i(t,e,s){const i=[],a=xe("color_search",t,e,",",s);return i.push(...a),i.push('color_operator:"AND"'),i}function ki(t,e){if(t.length===0)return[];const s=new Set,i=[];for(const r of t){const n=si[r];if(n)for(const l of n){const d=`${r}_${l}`;s.has(d)||(s.add(d),i.push(d))}else s.has(r)||(s.add(r),i.push(r))}const a=i.map(r=>`"${r}"`).join(",");return[`type${e}${a}`]}function Si(t,e,s,i){if(e.length===0)return[];const a=e.map(r=>`"${r}"`).join(",");return[`${t}${s}${a}`]}function Ci(t){const e=[];if(typeof t=="object"&&t!==null&&!Array.isArray(t)){const n=t,l=n.resolution,d=n.orientation,h=n.faces;return l!=null&&l.length&&e.push(`resolution:"${l.join(",")}"`),d!=null&&d.length&&e.push(`orientation:"${d.join(",")}"`),h!=null&&h.length&&e.push(`faces:"${h.join(",")}"`),e}const s=t,i=s[Ct.RESOLUTION],a=s[Ct.ORIENTATION],r=s[Ct.FACES];return i&&e.push(`resolution:"${i}"`),a&&e.push(`orientation:"${a}"`),r&&e.push(`faces:"${r}"`),e}function Ei(t,e){const s=Ti(t),i=Ai(t);if(e.type==="date")return Fi(s,e,i);const a=e,{operator:r=cs,values:n=[],logic:l,metadataType:d}=a;if(n.length===0)return[];if(n.length===1&&(n[0]===H||n[0]===G)){const h=d===b.GEO_POINT?x.IS+"~":x.IS;return[`${s}${h}"${n[0]}"`]}if((d===b.NUMERIC||d===b.DECIMAL2)&&r===x.RANGE)return[`${s}${x.IS}"${n.join('","')}"`];if(d===b.GEO_POINT){const h=n.map(u=>{const f=u.indexOf("..");if(f===-1)return`(${u})`;const p=u.slice(0,f),g=u.slice(f);return`(${p})${g}`});return xe(s,r+"~",h,",",l)}return xe(s,r,n,",",l)}function Fi(t,e,s){const i=us(t,e);return!s||i.length===0?i:i.map(a=>{const r=a.search(/[^a-zA-Z0-9_]/);if(r===-1)return`"${a}"`;const n=a.slice(0,r),d=a.slice(r).replace(/"/g,"");return`"${n}${d}"`})}function Ai(t){return t.startsWith("date_")}function Ti(t){for(const e of os)if(t.startsWith(e))return t.slice(e.length);return t}function es(t){return t.map(e=>e.replace(/#/g,""))}const Mi=new Set([v.DATE,v.LICENSE_EXPIRY,R.DUE_DATE]);function Ge(t){if(!t)return{};const e={};for(const[s,i]of Object.entries(t))i&&(e[s]=Li(s,i));return e}function Li(t,e){return e.type==="string"||e.type==="date"?e:Mi.has(t)?{type:"date",field:e.field??"created",kind:e.kind??null,preset:e.preset??null,from:e.from??null,to:e.to??null}:{type:"string",values:e.values,...e.operator!==void 0&&{operator:e.operator},...e.logic!==void 0&&{logic:e.logic}}}function Oi(t){const e=localStorage.getItem(ns+t),s=localStorage.getItem(ls+t);let i;try{i=e?JSON.parse(e):[...Qt]}catch{i=[...Qt]}let a;try{a=s?JSON.parse(s):[]}catch{a=[]}return{pinnedFilters:i,pinnedMetadata:a}}function Pi(t,e){localStorage.setItem(ns+t,JSON.stringify(e))}function Ii(t,e){localStorage.setItem(ls+t,JSON.stringify(e))}const gs="sort-by",fs="sort-order";function ts(t,e){try{localStorage.setItem(gs,t),localStorage.setItem(fs,e)}catch{}}function Di(){try{const t=localStorage.getItem(gs),e=localStorage.getItem(fs);return{sortBy:t,sortDirection:e}}catch{return{sortBy:null,sortDirection:null}}}const ms="ap-last-folder",vs="ap-last-view",bs="ap-last-tab";function ss(t){try{localStorage.setItem(ms,t)}catch{}}function is(){try{return localStorage.getItem(ms)}catch{return null}}function zi(t){try{localStorage.setItem(vs,t)}catch{}}function Ri(){try{return localStorage.getItem(vs)}catch{return null}}function ji(t){try{localStorage.setItem(bs,t)}catch{}}function Ni(){try{const t=localStorage.getItem(bs);return t==="assets"||t==="folders"?t:null}catch{return null}}function Bi(t){const e=t.replace("#",""),s=e.length===3?e[0]+e[0]+e[1]+e[1]+e[2]+e[2]:e,i=parseInt(s.slice(0,2),16)/255,a=parseInt(s.slice(2,4),16)/255,r=parseInt(s.slice(4,6),16)/255;return[i,a,r]}function Mt(t){return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Ui(t,e,s){const i=Mt(t),a=Mt(e),r=Mt(s),n=.4122214708*i+.5363325363*a+.0514459929*r,l=.2119034982*i+.6806995451*a+.1073969566*r,d=.0883024619*i+.2817188376*a+.6299787005*r,h=Math.cbrt(n),u=Math.cbrt(l),f=Math.cbrt(d),p=.2104542553*h+.793617785*u-.0040720468*f,g=1.9779984951*h-2.428592205*u+.4505937099*f,m=.0259040371*h+.7827717662*u-.808675766*f,_=Math.sqrt(g*g+m*m);let y=Math.atan2(m,g)*(180/Math.PI);return y<0&&(y+=360),[p,_,y]}function Vi(t){return t>.7}function qi(t,e){const s=["--ap-primary","--ap-primary-foreground","--ap-primary-10","--ap-primary-20","--ap-accent","--ap-accent-foreground","--ap-ring","--ap-selection-bg"];if(!e){for(const f of s)t.style.removeProperty(f);return}const[i,a,r]=Bi(e),[n,l,d]=Ui(i,a,r),h=`oklch(${n.toFixed(3)} ${l.toFixed(3)} ${d.toFixed(1)})`,u=Vi(n)?"#000":"#fff";t.style.setProperty("--ap-primary",h),t.style.setProperty("--ap-primary-foreground",u),t.style.setProperty("--ap-primary-10",`oklch(${n.toFixed(3)} ${l.toFixed(3)} ${d.toFixed(1)} / 0.1)`),t.style.setProperty("--ap-primary-20",`oklch(${n.toFixed(3)} ${l.toFixed(3)} ${d.toFixed(1)} / 0.2)`),t.style.setProperty("--ap-accent",`oklch(${n.toFixed(3)} ${l.toFixed(3)} ${d.toFixed(1)} / 0.07)`),t.style.setProperty("--ap-accent-foreground",h),t.style.setProperty("--ap-ring",`oklch(${n.toFixed(3)} ${l.toFixed(3)} ${d.toFixed(1)} / 0.7)`),t.style.setProperty("--ap-selection-bg",`oklch(${n.toFixed(3)} ${l.toFixed(3)} ${d.toFixed(1)} / 0.08)`)}const zt=[{value:"name",label:"Name"},{value:"created_at",label:"Uploaded"},{value:"modified_at",label:"Modified"},{value:"size",label:"Size"},{value:"type",label:"Format"}],Hi=[{value:"relevance",label:"Relevance"},...zt],Gi=[{value:"name",label:"Name"},{value:"created_at",label:"Uploaded"},{value:"modified_at",label:"Modified"},{value:"files_count_recursive",label:"Assets count"},{value:"files_size_recursive",label:"Assets size"}];var Ki=Object.defineProperty,Yi=Object.getOwnPropertyDescriptor,Rt=(t,e,s,i)=>{for(var a=i>1?void 0:i?Yi(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&Ki(e,s,a),a};let Ye=class extends o.LitElement{constructor(){super(...arguments),this.open=!1}updated(t){var e;super.updated(t),t.has("open")&&(this.open?this.dialog&&!this.dialog.open&&this.dialog.showModal():(e=this.dialog)!=null&&e.open&&this._animateClose())}_animateClose(){const t=this.dialog;if(t){if(window.matchMedia("(prefers-reduced-motion: reduce)").matches){t.close();return}t.classList.add("closing"),t.addEventListener("animationend",()=>{t.classList.remove("closing"),t.close()},{once:!0})}}_handleBackdropClick(t){t.target===this.dialog&&this.dispatchEvent(new CustomEvent("ap-cancel",{detail:{reason:"backdrop"},bubbles:!0,composed:!0}))}_handleCancel(t){t.preventDefault(),this.dispatchEvent(new CustomEvent("ap-cancel",{detail:{reason:"escape"},bubbles:!0,composed:!0}))}render(){return o.html`
|
|
1
|
+
"use strict";var Ms=Object.create;var Gt=Object.defineProperty;var Ls=Object.getOwnPropertyDescriptor;var Os=Object.getOwnPropertyNames;var Ps=Object.getPrototypeOf,Is=Object.prototype.hasOwnProperty;var Ds=(t,e,s,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Os(e))!Is.call(t,a)&&a!==s&&Gt(t,a,{get:()=>e[a],enumerable:!(i=Ls(e,a))||i.enumerable});return t};var zs=(t,e,s)=>(s=t!=null?Ms(Ps(t)):{},Ds(e||!t||!t.__esModule?Gt(s,"default",{value:t,enumerable:!0}):s,t));const o=require("lit"),c=require("lit/decorators.js");class Rs{constructor(e){this.listeners=new Set,this._notifying=!1,this._pendingState=null,this.state=e}getState(){return this.state}setState(e){if(this._notifying){this._pendingState={...this._pendingState||{},...e};return}const s=this.state;this.state={...s,...e},this._notifying=!0;try{this.listeners.forEach(i=>i(this.state,s))}finally{this._notifying=!1}if(this._pendingState){const i=this._pendingState;this._pendingState=null,this.setState(i)}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}destroy(){this.listeners.clear()}}function js(){return new Rs({config:null,projectToken:"",sassKey:"",brandColor:"",isOpen:!1,activeTab:"assets",viewMode:"grid",searchQuery:"",sortBy:"modified_at",sortDirection:"desc",previewAsset:null,isPreviewOpen:!1,assets:[],folders:[],folderPreviews:{},labels:[],tags:[],currentFolder:null,currentFolderPath:"/",breadcrumb:[],offset:0,limit:100,totalCount:0,totalFolderCount:0,isLoading:!1,isSelectingAll:!1,hasMore:!1,filters:{metadata:{pinned:[],visible:[],applied:{}},pinned:[],visible:[],applied:{}},fileTypes:[],metadataFields:[],regionalVariantGroups:[],regionalFilters:{},selectedAssets:new Map,selectedFolders:new Map,isResolvingFolders:!1})}class Ns{constructor(e,s){this.host=e,this.store=s,e.addController(this)}get state(){return this.store.getState()}setState(e){this.store.setState(e)}hostConnected(){this.unsubscribe=this.store.subscribe(()=>{this.host.requestUpdate()})}hostDisconnected(){var e;(e=this.unsubscribe)==null||e.call(this)}}function Bs(t){return"extension"in t&&!("path"in t)}class Us{constructor(e,s){this.lastClickedIndex=-1,this.host=e,this.store=s,e.addController(this)}hostConnected(){}hostDisconnected(){}get _folderSelectionEnabled(){var e;return((e=this.store.getState().config)==null?void 0:e.folderSelection)===!0}_getCombinedList(){const e=this.store.getState();return this._folderSelectionEnabled?[...e.folders,...e.assets]:e.assets}_applyRangeSelection(e,s,i,a){const r=this._getCombinedList();for(let n=e;n<=s;n++){const l=r[n];l&&(Bs(l)?i.set(l.uuid,l):a.set(l.uuid,l))}}handleSelect(e,s,i){var l,d,h,u;const a=this.store.getState(),r=new Map(a.selectedAssets);if(!(((l=a.config)==null?void 0:l.multiSelect)??!0)){r.clear(),r.set(e.uuid,e),this.store.setState({selectedAssets:r,selectedFolders:new Map}),this.lastClickedIndex=s;return}if(i.shiftKey&&this.lastClickedIndex>=0)if(this._folderSelectionEnabled){const f=Math.min(this.lastClickedIndex,s),p=Math.max(this.lastClickedIndex,s),g=new Map(a.selectedFolders);this._applyRangeSelection(f,p,r,g);const m=(d=a.config)==null?void 0:d.maxSelections;if(m&&r.size+g.size>m)return;this.store.setState({selectedAssets:r,selectedFolders:g})}else{const f=Math.min(this.lastClickedIndex,s),p=Math.max(this.lastClickedIndex,s),g=a.assets;for(let _=f;_<=p;_++)g[_]&&r.set(g[_].uuid,g[_]);const m=(h=a.config)==null?void 0:h.maxSelections;if(m&&r.size>m)return;this.store.setState({selectedAssets:r})}else if(i.metaKey||i.ctrlKey){r.has(e.uuid)?r.delete(e.uuid):r.set(e.uuid,e);const f=(u=a.config)==null?void 0:u.maxSelections,p=r.size+(this._folderSelectionEnabled?a.selectedFolders.size:0);if(f&&p>f)return;this.store.setState({selectedAssets:r})}else r.clear(),r.set(e.uuid,e),this.store.setState({selectedAssets:r,selectedFolders:new Map});this.lastClickedIndex=s}handleFolderSelect(e,s,i){var l,d,h;if(!this._folderSelectionEnabled)return;const a=this.store.getState(),r=new Map(a.selectedFolders);if(!(((l=a.config)==null?void 0:l.multiSelect)??!0)){r.clear(),r.set(e.uuid,e),this.store.setState({selectedFolders:r,selectedAssets:new Map}),this.lastClickedIndex=s;return}if(i.shiftKey&&this.lastClickedIndex>=0){const u=Math.min(this.lastClickedIndex,s),f=Math.max(this.lastClickedIndex,s),p=new Map(a.selectedAssets);this._applyRangeSelection(u,f,p,r);const g=(d=a.config)==null?void 0:d.maxSelections;if(g&&p.size+r.size>g)return;this.store.setState({selectedAssets:p,selectedFolders:r})}else if(i.metaKey||i.ctrlKey){r.has(e.uuid)?r.delete(e.uuid):r.set(e.uuid,e);const u=(h=a.config)==null?void 0:h.maxSelections,f=r.size+a.selectedAssets.size;if(u&&f>u)return;this.store.setState({selectedFolders:r})}else r.clear(),r.set(e.uuid,e),this.store.setState({selectedFolders:r,selectedAssets:new Map});this.lastClickedIndex=s}isSelected(e){return this.store.getState().selectedAssets.has(e)}isFolderSelected(e){return this.store.getState().selectedFolders.has(e)}resetRange(){this.lastClickedIndex=-1}selectAll(e){var l;const s=this.store.getState(),i=(l=s.config)==null?void 0:l.maxSelections,a=this._folderSelectionEnabled?s.selectedFolders.size:0,r=new Map,n=i?Math.max(0,Math.min(e.length,i-a)):e.length;for(let d=0;d<n;d++)r.set(e[d].uuid,e[d]);return this.store.setState({selectedAssets:r}),this.lastClickedIndex=-1,r.size}selectAllFolders(e){var n;if(!this._folderSelectionEnabled)return;const s=this.store.getState(),i=(n=s.config)==null?void 0:n.maxSelections,a=new Map,r=i?Math.max(0,Math.min(e.length,i-s.selectedAssets.size)):e.length;for(let l=0;l<r;l++)a.set(e[l].uuid,e[l]);this.store.setState({selectedFolders:a})}clearSelection(){this.store.setState({selectedAssets:new Map,selectedFolders:new Map}),this.lastClickedIndex=-1}getSelectedAssets(){return Array.from(this.store.getState().selectedAssets.values())}getSelectedFolders(){return Array.from(this.store.getState().selectedFolders.values())}}class Vs{constructor(e,s){this.host=e,this.onLoadMore=s,e.addController(this)}hostConnected(){}hostDisconnected(){this.disconnect()}observe(e,s){this.disconnect(),this.sentinel=e,this.observer=new IntersectionObserver(i=>{var a;(a=i[0])!=null&&a.isIntersecting&&this.onLoadMore()},{root:s??null,rootMargin:"200px"}),this.observer.observe(e)}disconnect(){this.observer&&this.sentinel&&(this.observer.unobserve(this.sentinel),this.observer.disconnect()),this.observer=void 0,this.sentinel=void 0}}const Kt=5,Me=40,Yt=15;class qs{constructor(e,s){this.startX=0,this.startY=0,this.startClientX=0,this.startClientY=0,this.preMarqueeSelection=new Map,this.preMarqueeFolderSelection=new Map,this._dragging=!1,this._scrollRAF=null,this._lastMouseEvent=null,this.isActive=!1,this.rect={x:0,y:0,width:0,height:0},this.handleMouseDown=i=>this.onMouseDown(i),this.handleMouseMove=i=>this.onMouseMove(i),this.handleMouseUp=()=>this.onMouseUp(),this.preventSelect=i=>i.preventDefault(),this.host=e,this.store=s,e.addController(this)}hostConnected(){}hostDisconnected(){this.detach()}attach(e){this.detach(),this.container=e,e.addEventListener("mousedown",this.handleMouseDown)}detach(){this.container&&this.container.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("selectstart",this.preventSelect),this.stopAutoScroll(),this._lastMouseEvent=null}isInteractiveTarget(e){return e.composedPath().some(i=>{if(!(i instanceof HTMLElement))return!1;if(i instanceof HTMLButtonElement||i instanceof HTMLInputElement)return!0;const a=i.tagName.toLowerCase();return!!(a.startsWith("ap-asset-")||a.startsWith("ap-folder-")||i.classList.contains("check")||i.classList.contains("check-box"))})}onMouseDown(e){var a;if(e.button!==0||this.isInteractiveTarget(e)||!(((a=this.store.getState().config)==null?void 0:a.multiSelect)??!0))return;const i=this.container.getBoundingClientRect();this.startX=e.clientX-i.left+this.container.scrollLeft,this.startY=e.clientY-i.top+this.container.scrollTop,this.startClientX=e.clientX,this.startClientY=e.clientY,this._dragging=!1,this.isActive=!1,document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}onMouseMove(e){var s;if(this.container){if(!this._dragging){const i=Math.abs(e.clientX-this.startClientX),a=Math.abs(e.clientY-this.startClientY);if(i<Kt&&a<Kt)return;this._dragging=!0,this.isActive=!0,document.addEventListener("selectstart",this.preventSelect),(s=window.getSelection())==null||s.removeAllRanges(),this.preMarqueeSelection=new Map(this.store.getState().selectedAssets),this.preMarqueeFolderSelection=new Map(this.store.getState().selectedFolders)}this._lastMouseEvent=e,this.updateMarqueeRect(e),this.startAutoScroll(e)}}updateMarqueeRect(e){if(!this.container)return;const s=this.container.getBoundingClientRect(),i=e.clientX-s.left+this.container.scrollLeft,a=e.clientY-s.top+this.container.scrollTop;let r=Math.min(this.startX,i),n=Math.min(this.startY,a),l=Math.abs(i-this.startX),d=Math.abs(a-this.startY);const h=this.container.scrollWidth,u=this.container.scrollHeight;r+l>h&&(l=h-r),n+d>u&&(d=u-n),r<0&&(l+=r,r=0),n<0&&(d+=n,n=0),this.rect={x:r,y:n,width:l,height:d},this.host.requestUpdate(),this.selectIntersecting()}startAutoScroll(e){if(!this.container)return;if(this.container.scrollHeight<=this.container.clientHeight){this.stopAutoScroll();return}const s=this.container.getBoundingClientRect(),i=e.clientY-s.top,a=s.bottom-e.clientY,r=i<Me||a<Me;r&&!this._scrollRAF?this._scrollRAF=requestAnimationFrame(()=>this.autoScrollTick()):r||this.stopAutoScroll()}autoScrollTick(){if(this._scrollRAF=null,!this.container||!this._dragging||!this._lastMouseEvent||this.container.scrollHeight<=this.container.clientHeight)return;const e=this.container.getBoundingClientRect(),s=this._lastMouseEvent,i=s.clientY-e.top,a=e.bottom-s.clientY;let r=0;i<Me?r=-Yt*(1-i/Me):a<Me&&(r=Yt*(1-a/Me)),r!==0&&(this.container.scrollTop+=r,this.updateMarqueeRect(s),this._scrollRAF=requestAnimationFrame(()=>this.autoScrollTick()))}stopAutoScroll(){this._scrollRAF&&(cancelAnimationFrame(this._scrollRAF),this._scrollRAF=null)}onMouseUp(){document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("selectstart",this.preventSelect),this.stopAutoScroll(),this._lastMouseEvent=null,this._dragging&&(this.isActive=!1,this._dragging=!1,this.rect={x:0,y:0,width:0,height:0},this.host.requestUpdate())}querySelectableElements(){const e=[],s=[];for(const i of Array.from(this.container.children))if(i.shadowRoot){const a=i.shadowRoot.querySelectorAll("[data-asset-uuid]");a.length>0&&e.push(...Array.from(a));const r=i.shadowRoot.querySelectorAll("[data-folder-uuid]");r.length>0&&s.push(...Array.from(r))}return e.length===0&&e.push(...Array.from(this.container.querySelectorAll("[data-asset-uuid]"))),s.length===0&&s.push(...Array.from(this.container.querySelectorAll("[data-folder-uuid]"))),{assetCards:e,folderCards:s}}getCardRelativeRect(e){const s=e.getBoundingClientRect(),i=this.container.getBoundingClientRect();return{x:s.left-i.left+this.container.scrollLeft,y:s.top-i.top+this.container.scrollTop,width:s.width,height:s.height}}intersectsMarquee(e){return this.rect.x<e.x+e.width&&this.rect.x+this.rect.width>e.x&&this.rect.y<e.y+e.height&&this.rect.y+this.rect.height>e.y}selectIntersecting(){var h,u;if(!this.container)return;const e=this.store.getState(),s=((h=e.config)==null?void 0:h.folderSelection)===!0,{assetCards:i,folderCards:a}=this.querySelectableElements(),r=new Map(this.preMarqueeSelection),n=s?new Map(this.preMarqueeFolderSelection):e.selectedFolders;i.forEach(f=>{const p=this.getCardRelativeRect(f),g=f.dataset.assetUuid;if(this.intersectsMarquee(p)){const m=e.assets.find(_=>_.uuid===g);m&&r.set(g,m)}}),s&&a.forEach(f=>{const p=this.getCardRelativeRect(f),g=f.dataset.folderUuid;if(this.intersectsMarquee(p)){const m=e.folders.find(_=>_.uuid===g);m&&n.set(g,m)}});const l=(u=e.config)==null?void 0:u.maxSelections,d=r.size+(s?n.size:0);if(l&&d>l){const f=Array.from(r.entries()).slice(0,Math.max(0,l-n.size));this.store.setState({selectedAssets:new Map(f),...s?{selectedFolders:n}:{}})}else this.store.setState({selectedAssets:r,...s?{selectedFolders:n}:{}})}}class Hs{constructor(e,s){this.auth=e;const i=e.projectToken;this.baseUrl=s||`https://api.filerobot.com/${i}/v5`,e.mode==="sassKey"&&(this.sassKey=e.sassKey)}setSassKey(e){this.sassKey=e}getSecurityTemplateKey(){if(this.auth.mode==="securityTemplate")return this.auth.securityTemplateKey}_applyAuthHeaders(e){this.sassKey?e["X-Filerobot-Key"]=this.sassKey:this.auth.mode==="securityTemplate"&&(e["X-Filerobot-Key"]=this.auth.securityTemplateKey)}async request(e,s){const i=new URL(`${this.baseUrl}${e}`);s&&Object.entries(s).forEach(([l,d])=>{d!=null&&(Array.isArray(d)?i.searchParams.set(l,d.join(",")):i.searchParams.set(l,String(d)))});const a={};this._applyAuthHeaders(a);const r=new AbortController,n=setTimeout(()=>r.abort(),3e4);try{const l=await fetch(i.toString(),{headers:a,signal:r.signal});if(clearTimeout(n),!l.ok){let h=`API error: ${l.status} ${l.statusText}`;try{const u=await l.json();u.msg&&(h=`API error: ${l.status} - ${u.msg}`)}catch{}throw new Error(h)}const d=await l.json();if(d.status==="error")throw new Error(`API error: ${d.msg||"Unknown error"}`);return d}catch(l){throw clearTimeout(n),l instanceof DOMException&&l.name==="AbortError"?new Error("API request timed out"):l}}async post(e,s){const i=new URL(`${this.baseUrl}${e}`),a={"Content-Type":"application/json"};this._applyAuthHeaders(a);const r=new AbortController,n=setTimeout(()=>r.abort(),3e4);try{const l=await fetch(i.toString(),{method:"POST",headers:a,body:JSON.stringify(s),signal:r.signal});if(clearTimeout(n),!l.ok){let h=`API error: ${l.status} ${l.statusText}`;try{const u=await l.json();u.msg&&(h=`API error: ${l.status} - ${u.msg}`)}catch{}throw new Error(h)}const d=await l.json();if(d.status==="error")throw new Error(`API error: ${d.msg||"Unknown error"}`);return d}catch(l){throw clearTimeout(n),l instanceof DOMException&&l.name==="AbortError"?new Error("API request timed out"):l}}}function Gs(t){const e={offset:t.offset??0,limit:t.limit??100,format:"json,regvar:api,select:internal",preview:2301,recursive:t.recursive??1},s=t.sort_by??"created_at",i=t.sort_direction??"desc",a={created_at:"created_at",modified_at:"modified_at",name:"name",size:"size",type:"type"};e.sort=`${a[s]||s}:${i}`,t.folder&&(e.folder=t.folder);const r=[];return t.search&&r.push(t.search),t.q&&r.push(t.q),r.length>0&&(e.q=r.join(" ")),e}async function qe(t,e){const s=Gs(e);return t.request("/files",s)}async function Xt(t,e){const s={folder:e.folder,recursive:e.recursive??1},i=[];return e.search&&i.push(e.search),e.q&&i.push(e.q),i.length>0&&(s.q=i.join(" ")),t.request("/files/stats",s)}async function Ks(t,e){const s={recursive:(e==null?void 0:e.recursive)??0,folder:(e==null?void 0:e.folderPath)??"/",limit:(e==null?void 0:e.limit)??1e3,offset:(e==null?void 0:e.offset)??0};e!=null&&e.q&&(s.q=e.q);const i=(e==null?void 0:e.sort_by)??"created_at",a=(e==null?void 0:e.sort_direction)??"asc",r={created_at:"created_at",modified_at:"modified_at",name:"name"};return s.sort=`${r[i]||i}:${a}`,await t.request("/folders",s)}async function Ys(t,e){return e.length===0?{}:(await t.post("/folders/previews",{folders:e})).folders||{}}async function Xs(t){return await t.request("/labels")}async function Ws(t){return((await t.request("/tags")).tags||[]).map(i=>({...i,label:i.names.en||Object.values(i.names)[0]||""})).filter(i=>i.label).sort((i,a)=>i.label.localeCompare(a.label))}async function Qs(t){const e=t.getSecurityTemplateKey();if(!e)throw new Error("Security template key is required for SASS key exchange");return(await t.request(`/key/${e}`)).key}const v={TYPE:"type",MIME_TYPE:"mimetype",METADATA:"metadata",DATE:"date",APPROVAL:"approval",SIZE:"size",LICENSE_EXPIRY:"asset_expiration",TAGS:"tags",IMAGE:"image",LABELS:"labels",PRODUCT_REF:"product_ref",FACES:"faces",COLOR:"color"},R={STATUS:"approval_status",APPROVER:"task_approver",REQUESTOR:"task_requester",DUE_DATE:"task_duedate"},x={IS:":",RANGE:"..",IS_NOT:":-",IS_EXACT:":=",CONTAINS:"~",CONTAINS_IN_TEXT:"~~~",GREATER_THAN_OR_EQUAL:">=",LESS_THAN_OR_EQUAL:"<="},Zs={AND:"AND"},b={NUMERIC:"numeric",SELECT_ONE:"select-one",MULTI_SELECT:"multi-select",TEXT_AREA:"textarea",TEXT:"text",SUPERTAGS:"tags",DATE:"date",BOOLEAN:"boolean",ATTACHMENTS_ASSETS:"attachments-assets",ATTACHMENT_URI:"attachment-uri",GEO_POINT:"geopoint",DECIMAL2:"decimal2",INTEGER_LIST:"integer-list"},vt={[b.DATE]:"date_",[b.BOOLEAN]:"bool_",[b.NUMERIC]:"num_",[b.DECIMAL2]:"dec_",[b.ATTACHMENTS_ASSETS]:"attach_",[b.ATTACHMENT_URI]:"uri_",[b.SELECT_ONE]:"one_",[b.MULTI_SELECT]:"multi_",[b.SUPERTAGS]:"tags_",[b.TEXT]:"text_",[b.TEXT_AREA]:"area_",[b.GEO_POINT]:"geo_",[b.INTEGER_LIST]:"intlist_"};Object.fromEntries(Object.entries(vt).map(([t,e])=>[e,t]));const os=Object.values(vt),He={PRESET:"preset",AFTER:"after",BEFORE:"before",BETWEEN:"between",SPECIFIC:"specific"},Wt={EMPTY:"empty",NOT_EMPTY:"non-empty"},H="empty",G="non-empty",be="specific",kt=10,St=10,at=10,ns="filters:pinned:",ls="metadata:pinned:",Qt=[v.DATE,v.TYPE,v.SIZE],cs=x.IS,ot="20",nt="1",Js=0,ei=[{key:v.DATE,label:"Date",icon:"calendar",type:"date"},{key:v.TYPE,label:"Format",icon:"file-type",type:"string"},{key:v.SIZE,label:"Size",icon:"scaling",type:"string"},{key:v.LICENSE_EXPIRY,label:"License expiry",icon:"history",type:"date"},{key:v.TAGS,label:"Tags",icon:"hash",type:"string"},{key:v.LABELS,label:"Labels",icon:"tag",type:"string"},{key:v.PRODUCT_REF,label:"Products",icon:"box",type:"string"},{key:v.IMAGE,label:"Image",icon:"image",type:"string"},{key:v.COLOR,label:"Color",icon:"swatch-book",type:"string"}],ti={key:v.METADATA,label:"Metadata",icon:"file-text",type:"string"},si={key:v.APPROVAL,label:"Approval",icon:"badge-check",type:"string"},Pt=[ti,...ei,si],Le={[v.TYPE]:"Format",[v.DATE]:"Date",[v.SIZE]:"Size",[v.LICENSE_EXPIRY]:"License expiry",[v.TAGS]:"Tags",[v.LABELS]:"Labels",[v.PRODUCT_REF]:"Products",[v.IMAGE]:"Image",[v.COLOR]:"Color",[v.METADATA]:"Metadata",[v.APPROVAL]:"Approval"},j={IMAGE:"image",VIDEO:"video",AUDIO:"audio",DOCUMENT:"document",ARCHIVE:"archive",DESIGN_TEMPLATE:"template_fdt",OTHER:"other",FONTS:"font"},ct=[{value:j.IMAGE,label:"Image",icon:"image"},{value:j.VIDEO,label:"Video",icon:"clapperboard"},{value:j.AUDIO,label:"Audio",icon:"music"},{value:j.DOCUMENT,label:"Document",icon:"document"},{value:j.ARCHIVE,label:"Archive",icon:"archive"},{value:j.DESIGN_TEMPLATE,label:"Design template",icon:"layout-template"},{value:j.FONTS,label:"Fonts",icon:"text"},{value:j.OTHER,label:"Other",icon:"layout-grid"}],ii={[j.IMAGE]:["jpg","jpeg","png","gif","webp","svg","bmp","ico","tiff","tif","avif","heic","heif","psd","eps"],[j.VIDEO]:["mp4","webm","ogg","mov","avi","mkv","flv","wmv","m4v"],[j.AUDIO]:["mp3","wav","ogg","flac","aac","wma","m4a","opus"],[j.DOCUMENT]:["pdf","doc","docx","xls","xlsx","ppt","pptx","txt","csv","rtf","odt","ods","odp","html"],[j.ARCHIVE]:["zip","rar","7z","tar","gz","bz2","xz"],[j.FONTS]:["ttf","otf","woff","woff2","eot"]},Ct={RESOLUTION:0,ORIENTATION:1,FACES:2},ai=[{value:"small",label:"Small"},{value:"medium",label:"Medium"},{value:"large",label:"Large"}],ri=[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"},{value:"square",label:"Square"},{value:"panorama",label:"Panorama"}],oi=[{value:"none",label:"None"},{value:"1",label:"1"},{value:"2",label:"2"},{value:"3..",label:"3+"}],ds=[{value:"created",label:"Created at"},{value:"updated",label:"Updated at"}],Dt=[{value:"today",label:"Today"},{value:"before",label:"Before date"},{value:"last_week",label:"Last week"},{value:"after",label:"After date"},{value:"last_month",label:"Last month"},{value:"between",label:"Between dates"},{value:"last_year",label:"Last year"}],ps=[{value:"today",label:"Today"},{value:"before",label:"Before date"},{value:"within_week",label:"Within week"},{value:"after",label:"After date"},{value:"within_month",label:"Within month"},{value:"between",label:"Between dates"},{value:"within_year",label:"Within year"},{value:"specific",label:"Specific date"}],ni=[{value:"today",label:"Today"},{value:"before",label:"Before date"},{value:"within_week",label:"Within week"},{value:"after",label:"After date"},{value:"within_month",label:"Within month"},{value:"between",label:"Between dates"},{value:"within_year",label:"Within year"},{value:"specific",label:"Specific date"}],li=["#ffffff","#99a1af","#000000","#894b00","#e7000b","#ff8904","#fdc700","#9ae600","#008236","#00bcff","#1447e6","#7f22fe","#e60076"],ci=[{label:"None (Exact)",value:"0"},{label:"Small",value:"1"},{label:"Medium",value:"2"},{label:"Large",value:"4"}],Et=[{label:"Is",value:x.IS},{label:"Contains",value:x.CONTAINS_IN_TEXT}],ae=[{label:"Is",value:x.IS},{label:"Is not",value:x.IS_NOT}],Ft=[{label:"Is",value:x.IS_EXACT},{label:"Contains",value:x.IS},{label:"Does not contain",value:x.IS_NOT}],At=[{label:"Is",value:x.IS},{label:"Greater than",value:x.GREATER_THAN_OR_EQUAL},{label:"Is not",value:x.IS_NOT},{label:"Less than",value:x.LESS_THAN_OR_EQUAL},{label:"Between",value:x.RANGE}],di=[{label:"Is",value:x.IS_EXACT},{label:"Is not",value:x.IS_NOT}],Zt=[{label:"Contains",value:x.CONTAINS},{label:"Does not contain",value:x.IS_NOT}],pi=[{value:"APPROVED",label:"Approved",icon:"circle-check-big",iconColor:"var(--ap-success, oklch(0.637 0.17 151.295))"},{value:"PENDING",label:"Pending",icon:"clock",iconColor:"var(--ap-warning, oklch(0.734 0.157 69.419))"},{value:"REJECTED",label:"Rejected",icon:"x-circle",iconColor:"var(--ap-destructive, oklch(0.577 0.215 27.325))"},{value:"CANCELLED",label:"Cancelled",icon:"ban",iconColor:"var(--ap-muted-foreground, oklch(0.685 0.033 249.82))"}],ye=[{label:"Empty",value:H},{label:"Not empty",value:G}],Tt=[...ye,{label:"Specific",value:be}],hi=[{label:"Empty",value:H},{label:"Not empty",value:G},{label:"True",value:"true"},{label:"False",value:"false"}],lt={[b.DATE]:"calendar",[b.BOOLEAN]:"toggle-left",[b.NUMERIC]:"file-digit",[b.DECIMAL2]:"decimals-arrow-right",[b.ATTACHMENTS_ASSETS]:"paperclip",[b.ATTACHMENT_URI]:"link-2",[b.SELECT_ONE]:"circle-dot",[b.MULTI_SELECT]:"square-check",[b.SUPERTAGS]:"hash",[b.TEXT]:"text-initial",[b.TEXT_AREA]:"text-align-justify",[b.GEO_POINT]:"locate",[b.INTEGER_LIST]:"list-ordered"},ui={[b.TEXT]:"text",[b.TEXT_AREA]:"text",[b.NUMERIC]:"number",[b.DECIMAL2]:"number",[b.BOOLEAN]:"boolean",[b.SELECT_ONE]:"select-one",[b.MULTI_SELECT]:"multi-select",[b.SUPERTAGS]:"tags",[b.DATE]:"date",[b.GEO_POINT]:"geo",[b.ATTACHMENTS_ASSETS]:"attachment",[b.ATTACHMENT_URI]:"attachment",[b.INTEGER_LIST]:"attachment"};async function gi(t){var i;return(((i=(await t.request("/filters",{filter_by:"filetype",format:"list",limit:200})).filters)==null?void 0:i.file_types)??[]).map(a=>({name:a.name,value:a.value,count:a.count,category:a.category??a.value.split("_")[0],label:fi(a.name)}))}function fi(t){const e=t.indexOf("›");return(e!==-1?t.slice(e+1).trim():t).toUpperCase()}async function mi(t){var m,_;const e=await t.request("/settings"),s=e.settings??e,i=(s==null?void 0:s.metadata)??e.metadata,r=((i==null?void 0:i.model)??[])[Js],n=i==null?void 0:i.store,d=((n==null?void 0:n.regional_variants_groups)??[]).map(y=>({uuid:y.uuid,label:y.label??y.name??"",variants:(y.variants??[]).map(S=>({api_value:S.api_value??S.value??"",internal_unique_value:S.internal_unique_value??S.api_value??"",label:S.label??S.name??""}))})).filter(y=>y.variants.length>1),h={};for(const y of d)h[y.uuid]=((m=y.variants[0])==null?void 0:m.api_value)??"";const u=(s==null?void 0:s.project_branding)??((_=e.settings)==null?void 0:_.project_branding),f=u==null?void 0:u.brandColor;if(!r)return{fields:[],regionalVariantGroups:d,regionalFilters:h,brandColor:f};const p=r.groups??[],g=[];for(const y of p){const S=y.name||"Root fields";for(const w of y.fields??[]){const E=w.possible_values,M=E==null?void 0:E.map($=>({api_value:$.api_value??$.value??"",internal_unique_value:$.internal_unique_value??$.api_value??"",label:$.label??$.name??$.api_value??""}));g.push({key:w.key??w.ckey,label:w.title??w.label??w.key??"",type:w.type??"text",slug:w.slug,ckey:w.ckey,possible_values:M,group:S,regionalVariantsGroupUuid:w.regional_variants_group_uuid})}}return{fields:g,regionalVariantGroups:d,regionalFilters:h,brandColor:f}}function _e(t){return t.toLocaleDateString("en-CA")}function rt(){return _e(new Date)}function hs(t){const e=new Date;switch(t){case"today":return{from:rt(),to:null};case"last_week":{const s=new Date(e);return s.setDate(s.getDate()-7),{from:_e(s),to:null}}case"within_week":{const s=new Date(e);return s.setDate(s.getDate()+7),{from:rt(),to:_e(s)}}case"last_month":{const s=new Date(e);return s.setDate(s.getDate()-30),{from:_e(s),to:null}}case"within_month":{const s=new Date(e);return s.setDate(s.getDate()+30),{from:rt(),to:_e(s)}}case"last_year":{const s=new Date(e);return s.setDate(s.getDate()-365),{from:_e(s),to:null}}case"within_year":{const s=new Date(e);return s.setDate(s.getDate()+365),{from:rt(),to:_e(s)}}default:return null}}function Jt(t,e){return e?e.type==="date"?vi(e):e.type==="string"?bi(e):!0:!1}function vi(t){return!(!t.kind&&!t.preset||t.kind==="preset"&&!t.preset||t.kind==="between"&&!t.from&&!t.to||t.kind==="after"&&!t.from||t.kind==="before"&&!t.to||t.kind==="specific"&&!t.from||t.from&&t.to&&new Date(t.from)>new Date(t.to))}function bi(t){return!t.values||!Array.isArray(t.values)?!1:t.values.filter(Boolean).length>0}function _i(t,e={}){const s=[];for(const[i,a]of Object.entries(t)){if(!a||!Jt(i,a))continue;const r=xi(i,a);s.push(...r)}for(const[i,a]of Object.entries(e)){if(!a||!Jt(i,a))continue;const r=Fi(i,a);s.push(...r)}return yi(s)}function yi(t){const e=[],s=[],i=[];for(const a of t)a.startsWith("type:")||a.startsWith("type=")?e.push(a):a.startsWith("mimetype:")||a.startsWith("mimetype=")?s.push(a):i.push(a);if(e.length>0&&s.length>0){const a=[...e,...s].join(" , ");i.push(a)}else i.push(...e,...s);return i}function xi(t,e){if(e.type==="date")return us(t,e);if(t===v.IMAGE)return Ei(e);const s=e,{operator:i=cs,values:a=[],logic:r}=s;if(a.length===0)return[];switch(t){case v.SIZE:return wi(t,a,"..");case v.FACES:return $i(t,i,a);case v.TAGS:return xe(t,i,es(a),",",r);case v.LABELS:return xe(t,i,es(a),",",r);case v.COLOR:return ki(i,a,r);case v.TYPE:return Si(a,i);case v.MIME_TYPE:return Ci(t,a,i);case v.PRODUCT_REF:return xe(t,"=%",a,",",r);default:return xe(t,i,a,",",r)}}function us(t,e){const s=e.field||"created";if(e.kind===He.PRESET&&e.preset){if(e.preset===Wt.EMPTY)return[`${s}:"empty"`];if(e.preset===Wt.NOT_EMPTY)return[`${s}:"non-empty"`];const i=hs(e.preset);return i?i.to===null?[`${s}>"${i.from}"`]:[`${s}:"${i.from}..${i.to}"`]:[]}if(e.kind===He.AFTER&&e.from)return[`${s}:>"${e.from}"`];if(e.kind===He.BEFORE&&e.to)return[`${s}:<"${e.to}"`];if(e.kind===He.BETWEEN){if(e.from&&e.to)return[`${s}:"${e.from}..${e.to}"`];if(e.from&&!e.to)return[`${s}:>"${e.from}"`];if(!e.from&&e.to)return[`${s}:<"${e.to}"`]}return e.kind===He.SPECIFIC&&e.from?[`${s}:"${e.from}"`]:[]}function wi(t,e,s){return e.length===0?[]:[`${t}:"${e.join(s)}"`]}function $i(t,e,s){return s.length===0?[]:[`${t}${e}"${s.join(",")}"`]}function xe(t,e,s,i,a){if(s.length===0)return[];if(a===Zs.AND)return s.map(n=>`${t}${e}"${n}"`);const r=s.map(n=>`"${n}"`).join(i);return[`${t}${e}${r}`]}function ki(t,e,s){const i=[],a=xe("color_search",t,e,",",s);return i.push(...a),i.push('color_operator:"AND"'),i}function Si(t,e){if(t.length===0)return[];const s=new Set,i=[];for(const r of t){const n=ii[r];if(n)for(const l of n){const d=`${r}_${l}`;s.has(d)||(s.add(d),i.push(d))}else s.has(r)||(s.add(r),i.push(r))}const a=i.map(r=>`"${r}"`).join(",");return[`type${e}${a}`]}function Ci(t,e,s,i){if(e.length===0)return[];const a=e.map(r=>`"${r}"`).join(",");return[`${t}${s}${a}`]}function Ei(t){const e=[];if(typeof t=="object"&&t!==null&&!Array.isArray(t)){const n=t,l=n.resolution,d=n.orientation,h=n.faces;return l!=null&&l.length&&e.push(`resolution:"${l.join(",")}"`),d!=null&&d.length&&e.push(`orientation:"${d.join(",")}"`),h!=null&&h.length&&e.push(`faces:"${h.join(",")}"`),e}const s=t,i=s[Ct.RESOLUTION],a=s[Ct.ORIENTATION],r=s[Ct.FACES];return i&&e.push(`resolution:"${i}"`),a&&e.push(`orientation:"${a}"`),r&&e.push(`faces:"${r}"`),e}function Fi(t,e){const s=Mi(t),i=Ti(t);if(e.type==="date")return Ai(s,e,i);const a=e,{operator:r=cs,values:n=[],logic:l,metadataType:d}=a;if(n.length===0)return[];if(n.length===1&&(n[0]===H||n[0]===G)){const h=d===b.GEO_POINT?x.IS+"~":x.IS;return[`${s}${h}"${n[0]}"`]}if((d===b.NUMERIC||d===b.DECIMAL2)&&r===x.RANGE)return[`${s}${x.IS}"${n.join('","')}"`];if(d===b.GEO_POINT){const h=n.map(u=>{const f=u.indexOf("..");if(f===-1)return`(${u})`;const p=u.slice(0,f),g=u.slice(f);return`(${p})${g}`});return xe(s,r+"~",h,",",l)}return xe(s,r,n,",",l)}function Ai(t,e,s){const i=us(t,e);return!s||i.length===0?i:i.map(a=>{const r=a.search(/[^a-zA-Z0-9_]/);if(r===-1)return`"${a}"`;const n=a.slice(0,r),d=a.slice(r).replace(/"/g,"");return`"${n}${d}"`})}function Ti(t){return t.startsWith("date_")}function Mi(t){for(const e of os)if(t.startsWith(e))return t.slice(e.length);return t}function es(t){return t.map(e=>e.replace(/#/g,""))}const Li=new Set([v.DATE,v.LICENSE_EXPIRY,R.DUE_DATE]);function Ge(t){if(!t)return{};const e={};for(const[s,i]of Object.entries(t))i&&(e[s]=Oi(s,i));return e}function Oi(t,e){return e.type==="string"||e.type==="date"?e:Li.has(t)?{type:"date",field:e.field??"created",kind:e.kind??null,preset:e.preset??null,from:e.from??null,to:e.to??null}:{type:"string",values:e.values,...e.operator!==void 0&&{operator:e.operator},...e.logic!==void 0&&{logic:e.logic}}}function Pi(t){const e=localStorage.getItem(ns+t),s=localStorage.getItem(ls+t);let i;try{i=e?JSON.parse(e):[...Qt]}catch{i=[...Qt]}let a;try{a=s?JSON.parse(s):[]}catch{a=[]}return{pinnedFilters:i,pinnedMetadata:a}}function Ii(t,e){localStorage.setItem(ns+t,JSON.stringify(e))}function Di(t,e){localStorage.setItem(ls+t,JSON.stringify(e))}const gs="sort-by",fs="sort-order";function ts(t,e){try{localStorage.setItem(gs,t),localStorage.setItem(fs,e)}catch{}}function zi(){try{const t=localStorage.getItem(gs),e=localStorage.getItem(fs);return{sortBy:t,sortDirection:e}}catch{return{sortBy:null,sortDirection:null}}}const ms="ap-last-folder",vs="ap-last-view",bs="ap-last-tab";function ss(t){try{localStorage.setItem(ms,t)}catch{}}function is(){try{return localStorage.getItem(ms)}catch{return null}}function Ri(t){try{localStorage.setItem(vs,t)}catch{}}function ji(){try{return localStorage.getItem(vs)}catch{return null}}function Ni(t){try{localStorage.setItem(bs,t)}catch{}}function Bi(){try{const t=localStorage.getItem(bs);return t==="assets"||t==="folders"?t:null}catch{return null}}function Ui(t){const e=t.replace("#",""),s=e.length===3?e[0]+e[0]+e[1]+e[1]+e[2]+e[2]:e,i=parseInt(s.slice(0,2),16)/255,a=parseInt(s.slice(2,4),16)/255,r=parseInt(s.slice(4,6),16)/255;return[i,a,r]}function Mt(t){return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Vi(t,e,s){const i=Mt(t),a=Mt(e),r=Mt(s),n=.4122214708*i+.5363325363*a+.0514459929*r,l=.2119034982*i+.6806995451*a+.1073969566*r,d=.0883024619*i+.2817188376*a+.6299787005*r,h=Math.cbrt(n),u=Math.cbrt(l),f=Math.cbrt(d),p=.2104542553*h+.793617785*u-.0040720468*f,g=1.9779984951*h-2.428592205*u+.4505937099*f,m=.0259040371*h+.7827717662*u-.808675766*f,_=Math.sqrt(g*g+m*m);let y=Math.atan2(m,g)*(180/Math.PI);return y<0&&(y+=360),[p,_,y]}function qi(t){return t>.7}function Hi(t,e){const s=["--ap-primary","--ap-primary-foreground","--ap-primary-10","--ap-primary-20","--ap-accent","--ap-accent-foreground","--ap-ring","--ap-selection-bg"];if(!e){for(const f of s)t.style.removeProperty(f);return}const[i,a,r]=Ui(e),[n,l,d]=Vi(i,a,r),h=`oklch(${n.toFixed(3)} ${l.toFixed(3)} ${d.toFixed(1)})`,u=qi(n)?"#000":"#fff";t.style.setProperty("--ap-primary",h),t.style.setProperty("--ap-primary-foreground",u),t.style.setProperty("--ap-primary-10",`oklch(${n.toFixed(3)} ${l.toFixed(3)} ${d.toFixed(1)} / 0.1)`),t.style.setProperty("--ap-primary-20",`oklch(${n.toFixed(3)} ${l.toFixed(3)} ${d.toFixed(1)} / 0.2)`),t.style.setProperty("--ap-accent",`oklch(${n.toFixed(3)} ${l.toFixed(3)} ${d.toFixed(1)} / 0.07)`),t.style.setProperty("--ap-accent-foreground",h),t.style.setProperty("--ap-ring",`oklch(${n.toFixed(3)} ${l.toFixed(3)} ${d.toFixed(1)} / 0.7)`),t.style.setProperty("--ap-selection-bg",`oklch(${n.toFixed(3)} ${l.toFixed(3)} ${d.toFixed(1)} / 0.08)`)}const zt=[{value:"name",label:"Name"},{value:"created_at",label:"Uploaded"},{value:"modified_at",label:"Modified"},{value:"size",label:"Size"},{value:"type",label:"Format"}],Gi=[{value:"relevance",label:"Relevance"},...zt],Ki=[{value:"name",label:"Name"},{value:"created_at",label:"Uploaded"},{value:"modified_at",label:"Modified"},{value:"files_count_recursive",label:"Assets count"},{value:"files_size_recursive",label:"Assets size"}];var Yi=Object.defineProperty,Xi=Object.getOwnPropertyDescriptor,Rt=(t,e,s,i)=>{for(var a=i>1?void 0:i?Xi(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&Yi(e,s,a),a};let Ye=class extends o.LitElement{constructor(){super(...arguments),this.open=!1}updated(t){var e;super.updated(t),t.has("open")&&(this.open?this.dialog&&!this.dialog.open&&this.dialog.showModal():(e=this.dialog)!=null&&e.open&&this._animateClose())}_animateClose(){const t=this.dialog;if(t){if(window.matchMedia("(prefers-reduced-motion: reduce)").matches){t.close();return}t.classList.add("closing"),t.addEventListener("animationend",()=>{t.classList.remove("closing"),t.close()},{once:!0})}}_handleBackdropClick(t){t.target===this.dialog&&this.dispatchEvent(new CustomEvent("ap-cancel",{detail:{reason:"backdrop"},bubbles:!0,composed:!0}))}_handleCancel(t){t.preventDefault(),this.dispatchEvent(new CustomEvent("ap-cancel",{detail:{reason:"escape"},bubbles:!0,composed:!0}))}render(){return o.html`
|
|
2
2
|
<dialog
|
|
3
3
|
@click=${this._handleBackdropClick}
|
|
4
4
|
@cancel=${this._handleCancel}
|
|
@@ -88,11 +88,11 @@
|
|
|
88
88
|
animation: none;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
`;Rt([c.property({type:Boolean})],Ye.prototype,"open",2);Rt([c.query("dialog")],Ye.prototype,"dialog",2);Ye=Rt([c.customElement("ap-modal")],Ye);function
|
|
91
|
+
`;Rt([c.property({type:Boolean})],Ye.prototype,"open",2);Rt([c.query("dialog")],Ye.prototype,"dialog",2);Ye=Rt([c.customElement("ap-modal")],Ye);function Wi(t,e){let s;const i=((...a)=>{clearTimeout(s),s=setTimeout(()=>t(...a),e)});return i.cancel=()=>clearTimeout(s),i}const ee=o.css`
|
|
92
92
|
*, *::before, *::after {
|
|
93
93
|
box-sizing: border-box;
|
|
94
94
|
}
|
|
95
|
-
`;var
|
|
95
|
+
`;var Qi=Object.defineProperty,Zi=Object.getOwnPropertyDescriptor,bt=(t,e,s,i)=>{for(var a=i>1?void 0:i?Zi(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&Qi(e,s,a),a};let Pe=class extends o.LitElement{constructor(){super(...arguments),this.groups=[],this.selectedFilters={},this._open=!1,this._handleOutsideClick=t=>{this._open&&!t.composedPath().includes(this)&&(this._open=!1)}}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this._handleOutsideClick)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this._handleOutsideClick)}_selectVariant(t,e){this.dispatchEvent(new CustomEvent("regional-change",{detail:{groupUuid:t,value:e},bubbles:!0,composed:!0}))}render(){const t=this.groups.length>0;return o.html`
|
|
96
96
|
<button
|
|
97
97
|
class="trigger ${this._open?"active":""}"
|
|
98
98
|
@click=${()=>this._open=!this._open}
|
|
@@ -208,7 +208,7 @@
|
|
|
208
208
|
width: 16px;
|
|
209
209
|
flex-shrink: 0;
|
|
210
210
|
}
|
|
211
|
-
`;bt([c.property({type:Array})],Pe.prototype,"groups",2);bt([c.property({type:Object})],Pe.prototype,"selectedFilters",2);bt([c.state()],Pe.prototype,"_open",2);Pe=bt([c.customElement("ap-regional-settings")],Pe);var
|
|
211
|
+
`;bt([c.property({type:Array})],Pe.prototype,"groups",2);bt([c.property({type:Object})],Pe.prototype,"selectedFilters",2);bt([c.state()],Pe.prototype,"_open",2);Pe=bt([c.customElement("ap-regional-settings")],Pe);var Ji=Object.defineProperty,ea=Object.getOwnPropertyDescriptor,le=(t,e,s,i)=>{for(var a=i>1?void 0:i?ea(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&Ji(e,s,a),a};const ta=[{value:"assets",label:"Assets",icon:"gallery-vertical-end"},{value:"folders",label:"Folders",icon:"folder-open"}];let Q=class extends o.LitElement{constructor(){super(...arguments),this.activeTab="assets",this.tabs=["assets","folders"],this.viewMode="grid",this.searchQuery="",this.regionalGroups=[],this.regionalFilters={},this.hideClose=!1,this._localSearch="",this._debouncedSearch=Wi(t=>{(t.length===0||t.length>=3)&&this.dispatchEvent(new CustomEvent("search-change",{detail:{value:t},bubbles:!0,composed:!0}))},300)}disconnectedCallback(){super.disconnectedCallback(),this._debouncedSearch.cancel()}willUpdate(t){t.has("searchQuery")&&(this._localSearch=this.searchQuery)}_handleInput(t){const e=t.target.value;this._localSearch=e,this._debouncedSearch(e)}_clearSearch(){this._localSearch="",this._debouncedSearch.cancel(),this.dispatchEvent(new CustomEvent("search-change",{detail:{value:""},bubbles:!0,composed:!0}))}_toggleView(){const t=this.viewMode==="grid"?"list":"grid";this.dispatchEvent(new CustomEvent("view-change",{detail:{mode:t},bubbles:!0,composed:!0}))}_handleTabChange(t){this.dispatchEvent(new CustomEvent("tab-change",{detail:{tab:t.detail.value},bubbles:!0,composed:!0}))}_handleRegionalChange(t){this.dispatchEvent(new CustomEvent("regional-change",{detail:t.detail,bubbles:!0,composed:!0}))}_handleClose(){this.dispatchEvent(new CustomEvent("ap-close",{bubbles:!0,composed:!0}))}render(){var e,s;const t=ta.filter(i=>this.tabs.includes(i.value));return((e=t.find(i=>i.value===this.activeTab))==null?void 0:e.label)??((s=t[0])==null||s.label),o.html`
|
|
212
212
|
<div class="header-row">
|
|
213
213
|
${t.length>1?o.html`<ap-dropdown
|
|
214
214
|
.value=${this.activeTab}
|
|
@@ -362,7 +362,7 @@
|
|
|
362
362
|
height: 24px;
|
|
363
363
|
background: var(--ap-border, oklch(92.86% 0.009 247.92));
|
|
364
364
|
}
|
|
365
|
-
`];le([c.property()],Q.prototype,"activeTab",2);le([c.property({type:Array})],Q.prototype,"tabs",2);le([c.property()],Q.prototype,"viewMode",2);le([c.property()],Q.prototype,"searchQuery",2);le([c.property({type:Array})],Q.prototype,"regionalGroups",2);le([c.property({type:Object})],Q.prototype,"regionalFilters",2);le([c.property({type:Boolean})],Q.prototype,"hideClose",2);le([c.state()],Q.prototype,"_localSearch",2);Q=le([c.customElement("ap-header")],Q);var
|
|
365
|
+
`];le([c.property()],Q.prototype,"activeTab",2);le([c.property({type:Array})],Q.prototype,"tabs",2);le([c.property()],Q.prototype,"viewMode",2);le([c.property()],Q.prototype,"searchQuery",2);le([c.property({type:Array})],Q.prototype,"regionalGroups",2);le([c.property({type:Object})],Q.prototype,"regionalFilters",2);le([c.property({type:Boolean})],Q.prototype,"hideClose",2);le([c.state()],Q.prototype,"_localSearch",2);Q=le([c.customElement("ap-header")],Q);var sa=Object.defineProperty,ia=Object.getOwnPropertyDescriptor,_s=(t,e,s,i)=>{for(var a=i>1?void 0:i?ia(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&sa(e,s,a),a};let dt=class extends o.LitElement{constructor(){super(...arguments),this.items=[]}_navigate(t){this.dispatchEvent(new CustomEvent("breadcrumb-navigate",{detail:{uuid:t},bubbles:!0,composed:!0}))}render(){return this.items.length===0?o.html``:o.html`
|
|
366
366
|
<nav class="breadcrumb" aria-label="Breadcrumb">
|
|
367
367
|
<button @click=${()=>this._navigate("")}>Root</button>
|
|
368
368
|
${this.items.map((t,e)=>o.html`
|
|
@@ -406,7 +406,7 @@
|
|
|
406
406
|
ap-icon {
|
|
407
407
|
color: var(--ap-muted-foreground, oklch(0.685 0.033 249.82));
|
|
408
408
|
}
|
|
409
|
-
`;_s([c.property({type:Array})],dt.prototype,"items",2);dt=_s([c.customElement("ap-breadcrumb")],dt);var
|
|
409
|
+
`;_s([c.property({type:Array})],dt.prototype,"items",2);dt=_s([c.customElement("ap-breadcrumb")],dt);var aa=Object.defineProperty,ra=Object.getOwnPropertyDescriptor,jt=(t,e,s,i)=>{for(var a=i>1?void 0:i?ra(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&aa(e,s,a),a};let Xe=class extends o.LitElement{constructor(){super(...arguments),this.title="",this.open=!1}render(){return this.open?o.html`
|
|
410
410
|
<div class="popover">
|
|
411
411
|
${this.title?o.html`<div class="title">${this.title}</div>`:""}
|
|
412
412
|
<slot></slot>
|
|
@@ -436,7 +436,7 @@
|
|
|
436
436
|
color: var(--ap-foreground, oklch(0.37 0.022 248.413));
|
|
437
437
|
margin-bottom: 12px;
|
|
438
438
|
}
|
|
439
|
-
`;jt([c.property()],Xe.prototype,"title",2);jt([c.property({type:Boolean})],Xe.prototype,"open",2);Xe=jt([c.customElement("ap-filter-popover")],Xe);var
|
|
439
|
+
`;jt([c.property()],Xe.prototype,"title",2);jt([c.property({type:Boolean})],Xe.prototype,"open",2);Xe=jt([c.customElement("ap-filter-popover")],Xe);var oa=Object.defineProperty,na=Object.getOwnPropertyDescriptor,Ze=(t,e,s,i)=>{for(var a=i>1?void 0:i?na(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&oa(e,s,a),a};function as(t){var i;const e=new Map;for(const a of t){const r=a.category||a.value.split("_")[0];if(!e.has(r)){const l=ct.find(d=>d.value===r);e.set(r,{key:r,label:(l==null?void 0:l.label)||r.charAt(0).toUpperCase()+r.slice(1),icon:(l==null?void 0:l.icon)||"file",extensions:[],totalCount:0})}const n=e.get(r);n.extensions.push({value:a.value,label:a.label||((i=a.value.split("_").pop())==null?void 0:i.toUpperCase())||a.value,count:a.count}),n.totalCount+=a.count}const s=ct.map(a=>a.value);return[...e.values()].sort((a,r)=>{const n=s.indexOf(a.key),l=s.indexOf(r.key);return(n===-1?999:n)-(l===-1?999:l)})}let we=class extends o.LitElement{constructor(){super(...arguments),this.selected=[],this.fileTypes=[],this._search="",this._expanded=new Set}_extValues(t){return t.extensions.map(e=>e.value)}_isGroupFullySelected(t){if(this.selected.includes(t.key))return!0;const e=this._extValues(t);return e.length>0&&e.every(s=>this.selected.includes(s))}_isGroupPartial(t){if(this.selected.includes(t.key))return!1;const e=this._extValues(t),s=e.filter(i=>this.selected.includes(i)).length;return s>0&&s<e.length}_isExtSelected(t,e){return this.selected.includes(e)||this.selected.includes(t)}_toggleGroup(t){const e=this._extValues(t),s=this._isGroupFullySelected(t);let i;if(s){const a=new Set([t.key,...e]);i=this.selected.filter(r=>!a.has(r))}else{const a=new Set(e);i=this.selected.filter(r=>!a.has(r)),i.push(t.key)}this._emit(i)}_toggleExt(t,e){const s=this._extValues(e);let i=[...this.selected];i.includes(e.key)&&(i=i.filter(a=>a!==e.key),i.push(...s)),i.includes(t)?i=i.filter(a=>a!==t):(i.push(t),s.every(a=>i.includes(a))&&(i=i.filter(a=>!s.includes(a)),i.push(e.key))),this._emit(i)}_clearAll(){this._emit([])}_emit(t){this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:v.TYPE,values:t,operator:x.IS},bubbles:!0,composed:!0}))}_toggleExpand(t){const e=new Set(this._expanded);e.has(t)?e.delete(t):e.add(t),this._expanded=e}_filteredGroups(t){const e=this._search.toLowerCase().trim();return e?t.map(s=>{if(s.label.toLowerCase().includes(e)||s.key.toLowerCase().includes(e))return s;const a=s.extensions.filter(r=>r.label.toLowerCase().includes(e)||r.value.toLowerCase().includes(e));return a.length===0?null:{...s,extensions:a}}).filter(s=>s!==null):t}_toggleCategory(t){const e=this.selected.includes(t)?this.selected.filter(s=>s!==t):[...this.selected,t];this._emit(e)}updated(t){if(t.has("fileTypes")&&this.fileTypes.length>0){const e=as(this.fileTypes),s=new Set(this._expanded);for(const i of e)(this._isGroupFullySelected(i)||this._isGroupPartial(i))&&s.add(i.key);this._expanded=s}}render(){if(this.fileTypes.length===0)return this._renderFallback();const t=as(this.fileTypes),e=this._filteredGroups(t),s=this.selected.length>0;return o.html`
|
|
440
440
|
<input
|
|
441
441
|
class="search-input"
|
|
442
442
|
type="text"
|
|
@@ -929,7 +929,7 @@
|
|
|
929
929
|
font-size: var(--ap-font-size-sm, 0.875rem);
|
|
930
930
|
color: var(--ap-muted-foreground, oklch(0.685 0.033 249.82));
|
|
931
931
|
}
|
|
932
|
-
`;var
|
|
932
|
+
`;var la=Object.defineProperty,ca=Object.getOwnPropertyDescriptor,Ee=(t,e,s,i)=>{for(var a=i>1?void 0:i?ca(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&la(e,s,a),a};function Lt(t){return t.toISOString().split("T")[0]}let re=class extends o.LitElement{constructor(){super(...arguments),this.filterKey=v.DATE,this.field="created",this.kind=null,this.preset="",this.from="",this.to=""}get _isLicenseExpiry(){return this.filterKey===v.LICENSE_EXPIRY}get _rangeOptions(){return this._isLicenseExpiry?ps:Dt}get _todayStr(){return Lt(new Date)}get _hasFilter(){return!!(this.kind||this.preset||this.from||this.to)}_kindFromValue(t){return["before","after","between","specific"].includes(t)?t:"preset"}_selectField(t){this.field=t,this._dispatchChange()}_selectPreset(t){const e=this._kindFromValue(t);if(this.kind=e,this.preset=t,["before","after","between","specific"].includes(t)){this.from="",this.to="",this.requestUpdate();return}const s=hs(t);s&&(this.from=s.from,this.to=s.to??""),this._dispatchChange()}_clearAll(){this.field="created",this.kind=null,this.preset="",this.from="",this.to="",this._dispatchChange()}_dispatchChange(){this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:this.filterKey,values:{field:this.field,kind:this.kind,preset:this.preset,from:this.from,to:this.to}},bubbles:!0,composed:!0}))}_handleDateInput(t,e){const s=e.target.value,i=s?new Date(s+"T00:00:00").toISOString():"";if(t==="from"?this.from=i:this.to=i,this.preset==="specific"&&t==="from"&&i){const a=new Date(s+"T23:59:59");this.to=a.toISOString()}this.preset==="after"&&t==="from"&&i&&(this.to=new Date().toISOString()),this.preset==="before"&&t==="to"&&i&&(this.from=new Date(0).toISOString()),this._dispatchChange()}_renderDateTypeSection(){return this._isLicenseExpiry?o.nothing:o.html`
|
|
933
933
|
<div class="filter-section">
|
|
934
934
|
<span class="section-label">Date type</span>
|
|
935
935
|
<ap-radio-group
|
|
@@ -1028,7 +1028,7 @@
|
|
|
1028
1028
|
.date-inputs {
|
|
1029
1029
|
margin-top: 4px;
|
|
1030
1030
|
}
|
|
1031
|
-
`];Ee([c.property()],re.prototype,"filterKey",2);Ee([c.property()],re.prototype,"field",2);Ee([c.property()],re.prototype,"kind",2);Ee([c.property()],re.prototype,"preset",2);Ee([c.property()],re.prototype,"from",2);Ee([c.property()],re.prototype,"to",2);re=Ee([c.customElement("ap-filter-date")],re);var
|
|
1031
|
+
`];Ee([c.property()],re.prototype,"filterKey",2);Ee([c.property()],re.prototype,"field",2);Ee([c.property()],re.prototype,"kind",2);Ee([c.property()],re.prototype,"preset",2);Ee([c.property()],re.prototype,"from",2);Ee([c.property()],re.prototype,"to",2);re=Ee([c.customElement("ap-filter-date")],re);var da=Object.defineProperty,pa=Object.getOwnPropertyDescriptor,Ne=(t,e,s,i)=>{for(var a=i>1?void 0:i?pa(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&da(e,s,a),a};let de=class extends o.LitElement{constructor(){super(...arguments),this.tags=[],this.selected=[],this.filterKey=v.TAGS,this._search=""}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>{var t;return(t=this._searchInput)==null?void 0:t.focus()})}get _suggestedTags(){return this.tags.filter(t=>t.primary)}get _otherTags(){return this.tags.filter(t=>!t.primary)}get _atLimit(){return this.selected.length>=kt}get _isSearching(){return this._search.trim().length>0}_toggle(t){const e=this.selected.includes(t);if(!e&&this._atLimit)return;const s=e?this.selected.filter(i=>i!==t):[...this.selected,t];this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:this.filterKey,values:s,operator:x.IS},bubbles:!0,composed:!0}))}_remove(t){const e=this.selected.filter(s=>s!==t);this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:this.filterKey,values:e,operator:x.IS},bubbles:!0,composed:!0}))}_clearAll(){this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:this.filterKey,values:[],operator:x.IS},bubbles:!0,composed:!0}))}_onSearchInput(t){this._search=t.target.value}_clearSearch(){this._search=""}_getTagBySid(t){return this.tags.find(e=>e.sid===t)}_renderTagItem(t){const e=this.selected.includes(t.sid),s=!e&&this._atLimit;return o.html`
|
|
1032
1032
|
<div
|
|
1033
1033
|
class="tag-item ${s?"disabled":""}"
|
|
1034
1034
|
title=${s?`You can select up to ${kt} tags`:o.nothing}
|
|
@@ -1217,7 +1217,7 @@
|
|
|
1217
1217
|
max-height: none;
|
|
1218
1218
|
overflow-y: visible;
|
|
1219
1219
|
}
|
|
1220
|
-
`];Ne([c.property({type:Array})],de.prototype,"tags",2);Ne([c.property({type:Array})],de.prototype,"selected",2);Ne([c.property()],de.prototype,"filterKey",2);Ne([c.query(".tag-search")],de.prototype,"_searchInput",2);Ne([c.state()],de.prototype,"_search",2);de=Ne([c.customElement("ap-filter-tags")],de);var
|
|
1220
|
+
`];Ne([c.property({type:Array})],de.prototype,"tags",2);Ne([c.property({type:Array})],de.prototype,"selected",2);Ne([c.property()],de.prototype,"filterKey",2);Ne([c.query(".tag-search")],de.prototype,"_searchInput",2);Ne([c.state()],de.prototype,"_search",2);de=Ne([c.customElement("ap-filter-tags")],de);var ha=Object.defineProperty,ua=Object.getOwnPropertyDescriptor,Je=(t,e,s,i)=>{for(var a=i>1?void 0:i?ua(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&ha(e,s,a),a};let $e=class extends o.LitElement{constructor(){super(...arguments),this.labels=[],this.selected=[],this._search=""}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>{var t;return(t=this._searchInput)==null?void 0:t.focus()})}get _atLimit(){return this.selected.length>=St}get _isSearching(){return this._search.trim().length>0}_toggle(t){const e=this.selected.includes(t);if(!e&&this._atLimit)return;const s=e?this.selected.filter(i=>i!==t):[...this.selected,t];this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:v.LABELS,values:s,operator:x.IS},bubbles:!0,composed:!0}))}_remove(t){const e=this.selected.filter(s=>s!==t);this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:v.LABELS,values:e,operator:x.IS},bubbles:!0,composed:!0}))}_clearAll(){this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:v.LABELS,values:[],operator:x.IS},bubbles:!0,composed:!0}))}_onSearchInput(t){this._search=t.target.value}_clearSearch(){this._search=""}_getLabelBySid(t){return this.labels.find(e=>e.sid===t)}_renderLabelItem(t){const e=this.selected.includes(t.sid),s=!e&&this._atLimit;return o.html`
|
|
1221
1221
|
<div
|
|
1222
1222
|
class="label-item ${s?"disabled":""}"
|
|
1223
1223
|
title=${s?`You can select up to ${St} labels`:o.nothing}
|
|
@@ -1340,9 +1340,9 @@
|
|
|
1340
1340
|
flex-shrink: 0;
|
|
1341
1341
|
line-height: 0;
|
|
1342
1342
|
}
|
|
1343
|
-
`];Je([c.property({type:Array})],$e.prototype,"labels",2);Je([c.property({type:Array})],$e.prototype,"selected",2);Je([c.query(".search-input")],$e.prototype,"_searchInput",2);Je([c.state()],$e.prototype,"_search",2);$e=Je([c.customElement("ap-filter-labels")],$e);var
|
|
1343
|
+
`];Je([c.property({type:Array})],$e.prototype,"labels",2);Je([c.property({type:Array})],$e.prototype,"selected",2);Je([c.query(".search-input")],$e.prototype,"_searchInput",2);Je([c.state()],$e.prototype,"_search",2);$e=Je([c.customElement("ap-filter-labels")],$e);var ga=Object.defineProperty,fa=Object.getOwnPropertyDescriptor,Be=(t,e,s,i)=>{for(var a=i>1?void 0:i?fa(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&ga(e,s,a),a};const Ot=3,It=/^#[0-9A-Fa-f]{6}$/;function ma(t){const e=t.trim().split(/\s+/);return e.length<1||!It.test(e[0])?null:{hex:e[0],tolerance:e[1]||nt,coverage:e[3]||ot}}let pe=class extends o.LitElement{constructor(){super(...arguments),this.values=[],this._colors=[],this._advanced=!1,this._showPalette=!1,this._initialized=!1}get _hasSelection(){return this._colors.length>0}get _selectedHexes(){return new Set(this._colors.map(t=>t.hex))}willUpdate(t){if(t.has("values")){const e=[];for(const s of this.values){const i=ma(s);i&&e.push(i)}(!this._initialized||this.values.length===0&&this._colors.length>0)&&(this._colors=e,e.length>0&&(this._advanced=e.some(s=>s.tolerance!==nt||s.coverage!==ot)),this._initialized=!0)}}_selectColor(t){if(!It.test(t))return;const e=this._colors.findIndex(s=>s.hex.toLowerCase()===t.toLowerCase());if(e>=0){this._removeColor(e);return}this._colors.length>=Ot||(this._colors=[...this._colors,{hex:t,tolerance:nt,coverage:ot}],this._showPalette=!1,this._dispatchChange())}_removeColor(t){this._colors=this._colors.filter((e,s)=>s!==t),this._dispatchChange()}_clearAll(){this._colors=[],this._showPalette=!1,this._dispatchChange()}_toggleAdvanced(){this._advanced=!this._advanced,this._colors.length>0&&this._dispatchChange()}_handleHexInput(t,e){let i=e.target.value.trim();if(i.startsWith("#")||(i="#"+i),!It.test(i)||this._colors.some((n,l)=>l!==t&&n.hex.toLowerCase()===i.toLowerCase()))return;const r=[...this._colors];r[t]={...r[t],hex:i},this._colors=r,this._dispatchChange()}_handleToleranceChange(t,e){const s=[...this._colors];s[t]={...s[t],tolerance:e.detail.value},this._colors=s,this._dispatchChange()}_handleCoverageInput(t,e){const s=e.target.value,i=parseInt(s,10);if(!isNaN(i)&&i>=1&&i<=100){const a=[...this._colors];a[t]={...a[t],coverage:String(i)},this._colors=a,this._dispatchChange()}}_showAddPalette(){this._showPalette=!0}_dispatchChange(){if(this._colors.length===0){this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:"color",values:"",operator:":"},bubbles:!0,composed:!0}));return}const t=this._colors.map(e=>{const s=this._advanced?e.tolerance:nt,i=this._advanced?e.coverage:ot;return`${e.hex} ${s} ${s} ${i}`});this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:"color",values:t,operator:":"},bubbles:!0,composed:!0}))}_renderPalette(){const t=this._selectedHexes,e=this._colors.length>=Ot;return o.html`
|
|
1344
1344
|
<div class="palette">
|
|
1345
|
-
${
|
|
1345
|
+
${li.map(s=>{const i=t.has(s),a=e&&!i;return o.html`
|
|
1346
1346
|
<button
|
|
1347
1347
|
class="swatch ${i?"selected":""} ${a?"disabled":""}"
|
|
1348
1348
|
style="background:${s};${s==="#ffffff"?" border: 1px solid #e4e4e7;":""}"
|
|
@@ -1371,7 +1371,7 @@
|
|
|
1371
1371
|
<span class="adv-field-label">Difference</span>
|
|
1372
1372
|
<ap-dropdown
|
|
1373
1373
|
.value=${t.tolerance}
|
|
1374
|
-
.options=${
|
|
1374
|
+
.options=${ci}
|
|
1375
1375
|
@ap-change=${s=>this._handleToleranceChange(e,s)}
|
|
1376
1376
|
></ap-dropdown>
|
|
1377
1377
|
</div>
|
|
@@ -1689,7 +1689,7 @@
|
|
|
1689
1689
|
.add-color-btn:hover {
|
|
1690
1690
|
opacity: 0.8;
|
|
1691
1691
|
}
|
|
1692
|
-
`];Be([c.property({type:Array})],pe.prototype,"values",2);Be([c.state()],pe.prototype,"_colors",2);Be([c.state()],pe.prototype,"_advanced",2);Be([c.state()],pe.prototype,"_showPalette",2);Be([c.state()],pe.prototype,"_initialized",2);pe=Be([c.customElement("ap-filter-color")],pe);var
|
|
1692
|
+
`];Be([c.property({type:Array})],pe.prototype,"values",2);Be([c.state()],pe.prototype,"_colors",2);Be([c.state()],pe.prototype,"_advanced",2);Be([c.state()],pe.prototype,"_showPalette",2);Be([c.state()],pe.prototype,"_initialized",2);pe=Be([c.customElement("ap-filter-color")],pe);var va=Object.defineProperty,ba=Object.getOwnPropertyDescriptor,Fe=(t,e,s,i)=>{for(var a=i>1?void 0:i?ba(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&va(e,s,a),a};const _a={KB:1/1e3,MB:1,GB:1e3},ya=[{value:"MB",label:"MB"},{value:"GB",label:"GB"}];let oe=class extends o.LitElement{constructor(){super(...arguments),this.min=0,this.max=0,this._minVal="",this._maxVal="",this._unit="MB",this._initialized=!1}willUpdate(t){!this._initialized&&(t.has("min")||t.has("max"))&&(this._initialized=!0,this.min>0&&(this._minVal=String(this.min)),this.max>0&&(this._maxVal=String(this.max)))}get _hasFilter(){return this._minVal!==""||this._maxVal!==""}_clearAll(){this._minVal="",this._maxVal="",this._emitChange()}_setUnit(t){this._unit=t.detail.value,this._emitChange()}_emitChange(){const t=_a[this._unit],e=this._minVal!==""?parseFloat((parseFloat(this._minVal)*t).toFixed(2)).toString():null,s=this._maxVal!==""?parseFloat((parseFloat(this._maxVal)*t).toFixed(2)).toString():null;let i;if(e!==null&&s!==null)i=`${e}..${s}`;else if(e!==null)i=`${e}..`;else if(s!==null)i=`..${s}`;else{this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:v.SIZE,values:[],operator:x.RANGE},bubbles:!0,composed:!0}));return}this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:v.SIZE,values:[i],operator:x.RANGE},bubbles:!0,composed:!0}))}_onMinInput(t){this._minVal=t.target.value,this._emitChange()}_onMaxInput(t){this._maxVal=t.target.value,this._emitChange()}render(){return o.html`
|
|
1693
1693
|
<div class="filter-content">
|
|
1694
1694
|
<span class="section-label">Size</span>
|
|
1695
1695
|
<button
|
|
@@ -1726,7 +1726,7 @@
|
|
|
1726
1726
|
<div>
|
|
1727
1727
|
<span class="input-label">Unit</span>
|
|
1728
1728
|
<ap-dropdown
|
|
1729
|
-
.options=${
|
|
1729
|
+
.options=${ya}
|
|
1730
1730
|
.value=${this._unit}
|
|
1731
1731
|
@ap-change=${this._setUnit}
|
|
1732
1732
|
></ap-dropdown>
|
|
@@ -1752,19 +1752,19 @@
|
|
|
1752
1752
|
display: block;
|
|
1753
1753
|
width: 100%;
|
|
1754
1754
|
}
|
|
1755
|
-
`];Fe([c.property({type:Number})],oe.prototype,"min",2);Fe([c.property({type:Number})],oe.prototype,"max",2);Fe([c.state()],oe.prototype,"_minVal",2);Fe([c.state()],oe.prototype,"_maxVal",2);Fe([c.state()],oe.prototype,"_unit",2);Fe([c.state()],oe.prototype,"_initialized",2);oe=Fe([c.customElement("ap-filter-size")],oe);var
|
|
1755
|
+
`];Fe([c.property({type:Number})],oe.prototype,"min",2);Fe([c.property({type:Number})],oe.prototype,"max",2);Fe([c.state()],oe.prototype,"_minVal",2);Fe([c.state()],oe.prototype,"_maxVal",2);Fe([c.state()],oe.prototype,"_unit",2);Fe([c.state()],oe.prototype,"_initialized",2);oe=Fe([c.customElement("ap-filter-size")],oe);var xa=Object.defineProperty,wa=Object.getOwnPropertyDescriptor,_t=(t,e,s,i)=>{for(var a=i>1?void 0:i?wa(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&xa(e,s,a),a};const $a=o.svg`
|
|
1756
1756
|
<svg width="20" height="20" viewBox="0 0 12 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1757
1757
|
<path d="M2.66666 1.9987C2.29847 1.9987 1.99999 2.29717 1.99999 2.66536L1.99999 13.332C1.99999 13.7002 2.29847 13.9987 2.66666 13.9987L9.33332 13.9987C9.70151 13.9987 9.99999 13.7002 9.99999 13.332L9.99999 2.66536C9.99999 2.29717 9.70151 1.9987 9.33332 1.9987L2.66666 1.9987ZM9.33332 0.665364C10.4379 0.665364 11.3333 1.56079 11.3333 2.66536L11.3333 13.332C11.3333 14.4366 10.4379 15.332 9.33332 15.332L2.66666 15.332C1.56209 15.332 0.666656 14.4366 0.666656 13.332L0.666656 2.66536C0.666656 1.56079 1.56209 0.665364 2.66666 0.665364L9.33332 0.665364Z" fill="#9747FF"/>
|
|
1758
1758
|
<path d="M5.33332 4.65885C5.33332 4.29066 5.6318 3.99219 5.99999 3.99219C6.36818 3.99219 6.66666 4.29066 6.66666 4.65885L6.66666 4.66536C6.66666 5.03355 6.36818 5.33203 5.99999 5.33203C5.6318 5.33203 5.33332 5.03355 5.33332 4.66536L5.33332 4.65885Z" fill="#9747FF"/>
|
|
1759
1759
|
<path d="M5.33332 11.3255C5.33332 10.9573 5.6318 10.6589 5.99999 10.6589C6.36818 10.6589 6.66666 10.9573 6.66666 11.3255L6.66666 11.332C6.66666 11.7002 6.36818 11.9987 5.99999 11.9987C5.6318 11.9987 5.33332 11.7002 5.33332 11.332L5.33332 11.3255Z" fill="#9747FF"/>
|
|
1760
1760
|
</svg>
|
|
1761
|
-
|
|
1761
|
+
`,ka=o.svg`
|
|
1762
1762
|
<svg width="20" height="20" viewBox="0 0 16 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1763
1763
|
<path d="M14 2.66797C14 2.29978 13.7015 2.0013 13.3333 2.0013H2.66666C2.29847 2.0013 1.99999 2.29978 1.99999 2.66797V9.33463C1.99999 9.70282 2.29847 10.0013 2.66666 10.0013H13.3333C13.7015 10.0013 14 9.70282 14 9.33463V2.66797ZM15.3333 9.33463C15.3333 10.4392 14.4379 11.3346 13.3333 11.3346H2.66666C1.56209 11.3346 0.666656 10.4392 0.666656 9.33463V2.66797C0.666656 1.5634 1.56209 0.667969 2.66666 0.667969H13.3333C14.4379 0.667969 15.3333 1.5634 15.3333 2.66797V9.33463Z" fill="#65A30D"/>
|
|
1764
1764
|
<path d="M11.3398 5.33464C11.708 5.33464 12.0065 5.63311 12.0065 6.0013C12.0065 6.36949 11.708 6.66797 11.3398 6.66797H11.3333C10.9651 6.66797 10.6667 6.36949 10.6667 6.0013C10.6667 5.63311 10.9651 5.33464 11.3333 5.33464H11.3398Z" fill="#65A30D"/>
|
|
1765
1765
|
<path d="M4.67317 5.33464C5.04136 5.33464 5.33983 5.63311 5.33983 6.0013C5.33983 6.36949 5.04136 6.66797 4.67317 6.66797H4.66666C4.29847 6.66797 3.99999 6.36949 3.99999 6.0013C3.99999 5.63311 4.29847 5.33464 4.66666 5.33464H4.67317Z" fill="#65A30D"/>
|
|
1766
1766
|
</svg>
|
|
1767
|
-
`,
|
|
1767
|
+
`,Sa=o.svg`
|
|
1768
1768
|
<svg width="20" height="20" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1769
1769
|
<path d="M12.3333 2.33203C12.3333 1.96384 12.0349 1.66536 11.6667 1.66536H2.33334C1.96515 1.66536 1.66668 1.96384 1.66668 2.33203V11.6654C1.66668 12.0336 1.96515 12.332 2.33334 12.332H11.6667C12.0349 12.332 12.3333 12.0336 12.3333 11.6654V2.33203ZM13.6667 11.6654C13.6667 12.7699 12.7712 13.6654 11.6667 13.6654H2.33334C1.22877 13.6654 0.333344 12.7699 0.333344 11.6654V2.33203C0.333344 1.22746 1.22877 0.332031 2.33334 0.332031H11.6667C12.7712 0.332031 13.6667 1.22746 13.6667 2.33203V11.6654Z" fill="#6366F1"/>
|
|
1770
1770
|
<path d="M9.67319 3.66536C10.0414 3.66536 10.3399 3.96384 10.3399 4.33203C10.3399 4.70022 10.0414 4.9987 9.67319 4.9987H9.66668C9.29849 4.9987 9.00001 4.70022 9.00001 4.33203C9.00001 3.96384 9.29849 3.66536 9.66668 3.66536H9.67319Z" fill="#6366F1"/>
|
|
@@ -1772,13 +1772,13 @@
|
|
|
1772
1772
|
<path d="M4.33985 8.9987C4.70804 8.9987 5.00652 9.29718 5.00652 9.66537C5.00652 10.0336 4.70804 10.332 4.33985 10.332H4.33334C3.96515 10.332 3.66668 10.0336 3.66668 9.66537C3.66668 9.29718 3.96515 8.9987 4.33334 8.9987H4.33985Z" fill="#6366F1"/>
|
|
1773
1773
|
<path d="M9.67319 8.9987C10.0414 8.9987 10.3399 9.29718 10.3399 9.66537C10.3399 10.0336 10.0414 10.332 9.67319 10.332H9.66668C9.29849 10.332 9.00001 10.0336 9.00001 9.66537C9.00001 9.29718 9.29849 8.9987 9.66668 8.9987H9.67319Z" fill="#6366F1"/>
|
|
1774
1774
|
</svg>
|
|
1775
|
-
`,
|
|
1775
|
+
`,Ca=o.svg`
|
|
1776
1776
|
<svg width="20" height="20" viewBox="0 0 16 8" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1777
1777
|
<path d="M14 2.33203C14 1.96384 13.7015 1.66536 13.3333 1.66536H2.66666C2.29847 1.66536 1.99999 1.96384 1.99999 2.33203V5.66536C1.99999 6.03355 2.29847 6.33203 2.66666 6.33203H13.3333C13.7015 6.33203 14 6.03355 14 5.66536V2.33203ZM15.3333 5.66536C15.3333 6.76993 14.4379 7.66536 13.3333 7.66536H2.66666C1.56209 7.66536 0.666656 6.76993 0.666656 5.66536V2.33203C0.666656 1.22746 1.56209 0.332031 2.66666 0.332031H13.3333C14.4379 0.332031 15.3333 1.22746 15.3333 2.33203V5.66536Z" fill="#4BA3AD"/>
|
|
1778
1778
|
<path d="M11.3398 3.33203C11.708 3.33203 12.0065 3.63051 12.0065 3.9987C12.0065 4.36689 11.708 4.66536 11.3398 4.66536H11.3333C10.9651 4.66536 10.6667 4.36689 10.6667 3.9987C10.6667 3.63051 10.9651 3.33203 11.3333 3.33203H11.3398Z" fill="#4BA3AD"/>
|
|
1779
1779
|
<path d="M4.67317 3.33203C5.04136 3.33203 5.33983 3.63051 5.33983 3.9987C5.33983 4.36689 5.04136 4.66536 4.67317 4.66536H4.66666C4.29847 4.66536 3.99999 4.36689 3.99999 3.9987C3.99999 3.63051 4.29847 3.33203 4.66666 3.33203H4.67317Z" fill="#4BA3AD"/>
|
|
1780
1780
|
</svg>
|
|
1781
|
-
`,
|
|
1781
|
+
`,Ea={portrait:$a,landscape:ka,square:Sa,panorama:Ca};let Ie=class extends o.LitElement{constructor(){super(...arguments),this.selectedResolution=[],this.selectedOrientation=[],this.selectedFaces=[]}get _hasSelection(){return this.selectedResolution.length>0||this.selectedOrientation.length>0||this.selectedFaces.length>0}_toggle(t,e){return t.includes(e)?t.filter(s=>s!==e):[...t,e]}_toggleResolution(t){this.selectedResolution=this._toggle(this.selectedResolution,t),this._dispatchChange()}_toggleOrientation(t){this.selectedOrientation=this._toggle(this.selectedOrientation,t),this._dispatchChange()}_toggleFaces(t){this.selectedFaces=this._toggle(this.selectedFaces,t),this._dispatchChange()}_clearAll(){this.selectedResolution=[],this.selectedOrientation=[],this.selectedFaces=[],this._dispatchChange()}_dispatchChange(){this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:"image",values:{resolution:this.selectedResolution,orientation:this.selectedOrientation,faces:this.selectedFaces}},bubbles:!0,composed:!0}))}render(){return o.html`
|
|
1782
1782
|
<div class="filter-content">
|
|
1783
1783
|
<button
|
|
1784
1784
|
class="clear-btn"
|
|
@@ -1789,7 +1789,7 @@
|
|
|
1789
1789
|
<div class="filter-section">
|
|
1790
1790
|
<span class="section-label">Resolution</span>
|
|
1791
1791
|
<div class="options-horizontal">
|
|
1792
|
-
${
|
|
1792
|
+
${ai.map(t=>o.html`
|
|
1793
1793
|
<ap-checkbox
|
|
1794
1794
|
?checked=${this.selectedResolution.includes(t.value)}
|
|
1795
1795
|
@ap-toggle=${()=>{this._toggleResolution(t.value)}}
|
|
@@ -1801,11 +1801,11 @@
|
|
|
1801
1801
|
<div class="filter-section">
|
|
1802
1802
|
<span class="section-label">Orientation</span>
|
|
1803
1803
|
<div class="options-vertical">
|
|
1804
|
-
${
|
|
1804
|
+
${ri.map(t=>o.html`
|
|
1805
1805
|
<ap-checkbox
|
|
1806
1806
|
?checked=${this.selectedOrientation.includes(t.value)}
|
|
1807
1807
|
@ap-toggle=${()=>{this._toggleOrientation(t.value)}}
|
|
1808
|
-
><span class="orientation-label">${
|
|
1808
|
+
><span class="orientation-label">${Ea[t.value]}${t.label}</span></ap-checkbox>
|
|
1809
1809
|
`)}
|
|
1810
1810
|
</div>
|
|
1811
1811
|
</div>
|
|
@@ -1813,7 +1813,7 @@
|
|
|
1813
1813
|
<div class="filter-section">
|
|
1814
1814
|
<span class="section-label">Faces</span>
|
|
1815
1815
|
<div class="options-horizontal">
|
|
1816
|
-
${
|
|
1816
|
+
${oi.map(t=>o.html`
|
|
1817
1817
|
<ap-checkbox
|
|
1818
1818
|
?checked=${this.selectedFaces.includes(t.value)}
|
|
1819
1819
|
@ap-toggle=${()=>{this._toggleFaces(t.value)}}
|
|
@@ -1848,7 +1848,7 @@
|
|
|
1848
1848
|
.orientation-label svg {
|
|
1849
1849
|
flex-shrink: 0;
|
|
1850
1850
|
}
|
|
1851
|
-
`];_t([c.property({type:Array})],Ie.prototype,"selectedResolution",2);_t([c.property({type:Array})],Ie.prototype,"selectedOrientation",2);_t([c.property({type:Array})],Ie.prototype,"selectedFaces",2);Ie=_t([c.customElement("ap-filter-image")],Ie);var
|
|
1851
|
+
`];_t([c.property({type:Array})],Ie.prototype,"selectedResolution",2);_t([c.property({type:Array})],Ie.prototype,"selectedOrientation",2);_t([c.property({type:Array})],Ie.prototype,"selectedFaces",2);Ie=_t([c.customElement("ap-filter-image")],Ie);var Fa=Object.defineProperty,Aa=Object.getOwnPropertyDescriptor,L=(t,e,s,i)=>{for(var a=i>1?void 0:i?Aa(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&Fa(e,s,a),a};function k(t){return`${vt[t.type]||""}${t.key}`}let T=class extends o.LitElement{constructor(){super(...arguments),this.fields=[],this.appliedFilters={},this.visibleFields=[],this.mode="full",this.activeFieldKey="",this.pinnedFields=[],this.appliedMetadata={},this._showFieldSelection=!1,this._fieldSearch="",this._collapsedFields=new Set,this._tagInputs={},this._tagSuggestions={},this._tagLoading={},this._datePresets={},this._dateFroms={},this._dateTos={},this._specificModeFields=new Set,this._selectSearches={},this._tagDebounceTimers={}}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>this._focusSearch())}disconnectedCallback(){super.disconnectedCallback();for(const t of Object.values(this._tagDebounceTimers))clearTimeout(t)}_focusSearch(){const t=this.renderRoot.querySelector(".field-search, .search-input");t==null||t.focus()}get _atFieldLimit(){return this.visibleFields.length>=at}_getField(t){return this.fields.find(e=>k(e)===t)}_getUIType(t){return ui[t.type]}_getApplied(t){return this.appliedMetadata[t]||this.appliedFilters[t]||{}}_isSpecialValue(t){return!t||t.length!==1?!1:t[0]===H||t[0]===G}_getContentMode(t){var s,i;const e=this._getApplied(t);return((s=e.values)==null?void 0:s[0])===H?H:((i=e.values)==null?void 0:i[0])===G?G:this._specificModeFields.has(t)||e.values&&e.values.length>0?be:""}_emitFilterChange(t,e,s){const i=k(t);this.dispatchEvent(new CustomEvent("metadata-filter-change",{detail:{fieldKey:i,operator:e,values:s,metadataType:t.type},bubbles:!0,composed:!0}))}_emitFieldToggle(t,e){const s=k(t);this.dispatchEvent(new CustomEvent("metadata-field-toggle",{detail:{fieldKey:s,visible:e},bubbles:!0,composed:!0}))}_emitFieldSelect(t){const e=k(t);!this.visibleFields.includes(e)&&this._atFieldLimit||(this.visibleFields.includes(e)||this._emitFieldToggle(t,!0),this.dispatchEvent(new CustomEvent("metadata-field-select",{detail:{fieldKey:e},bubbles:!0,composed:!0})))}_emitPin(t,e){this.dispatchEvent(new CustomEvent("metadata-pin",{detail:{fieldKey:t,pinned:e},bubbles:!0,composed:!0}))}_openFieldSelection(){this._showFieldSelection=!0,this._fieldSearch=""}_closeFieldSelection(){this._showFieldSelection=!1,this._fieldSearch=""}_addField(t){if(this._atFieldLimit)return;const e=k(t);this.visibleFields.includes(e)||this._emitFieldToggle(t,!0)}_removeField(t){this._emitFieldToggle(t,!1),this._emitFilterChange(t,void 0,[])}_toggleCollapse(t){const e=new Set(this._collapsedFields);e.has(t)?e.delete(t):e.add(t),this._collapsedFields=e}_onOperatorChange(t,e){const i=this._getApplied(k(t)).values||[];this._emitFilterChange(t,e,i)}_onContentModeChange(t,e){const s=k(t);if(e===be){const i=new Set(this._specificModeFields);i.add(s),this._specificModeFields=i;const a=this._getApplied(s);this._isSpecialValue(a.values)&&this._emitFilterChange(t,a.operator,[])}else{if(this._specificModeFields.has(s)){const i=new Set(this._specificModeFields);i.delete(s),this._specificModeFields=i}this._onEmptyOption(t,e)}}_clearFieldFilter(t){const e=k(t);if(this._specificModeFields.has(e)){const p=new Set(this._specificModeFields);p.delete(e),this._specificModeFields=p}const{[e]:s,...i}=this._datePresets;this._datePresets=i;const{[e]:a,...r}=this._dateFroms;this._dateFroms=r;const{[e]:n,...l}=this._dateTos;this._dateTos=l;const{[e]:d,...h}=this._selectSearches;this._selectSearches=h;const{[e]:u,...f}=this._tagInputs;this._tagInputs=f,this._emitFilterChange(t,void 0,[])}_onTextInput(t,e){const s=e.target.value,a=this._getApplied(k(t)).operator||Et[0].value;this._emitFilterChange(t,a,s?[s]:[])}_onNumberInput(t,e,s){const i=e.target.value,a=k(t),r=this._getApplied(a),n=r.operator||At[0].value,l=[...r.values||[]];s===0?l[0]=i:l[1]=i;const d=l.filter(h=>h!==""&&h!==void 0);if(d.length>0){const h=t.type===b.DECIMAL2;if(!d.every(f=>h?!isNaN(parseFloat(f)):/^-?\d+$/.test(f)))return}this._emitFilterChange(t,n,l)}_onBooleanSelect(t,e){var a;const s=this._getApplied(k(t));((a=s.values)==null?void 0:a[0])===e?this._emitFilterChange(t,void 0,[]):this._emitFilterChange(t,s.operator,[e])}_onSelectOneToggle(t,e){const s=k(t),i=this._getApplied(s),a=i.operator||ae[0].value,r=i.values||[];r.length===1&&r[0]===e?this._emitFilterChange(t,a,[]):this._emitFilterChange(t,a,[e])}_onMultiSelectToggle(t,e){const s=k(t),i=this._getApplied(s),a=i.operator||Ft[0].value,r=i.values||[],n=r.includes(e)?r.filter(l=>l!==e):[...r,e];this._emitFilterChange(t,a,n)}_onTagKeydown(t,e){const s=k(t);(e.key==="Enter"||e.key===",")&&(e.preventDefault(),this._commitTagInput(t,s))}_onTagInput(t,e,s){const i=s.target.value;if(i.includes(",")){const a=i.replace(/,/g,"").trim();a&&(this._tagInputs={...this._tagInputs,[e]:a},this._commitTagInput(t,e));return}this._tagInputs={...this._tagInputs,[e]:i},this._fetchTagSuggestions(t,e,i.trim())}_selectTagSuggestion(t,e){const s=k(t),i=this._getApplied(s),a=i.operator||ae[0].value,r=i.values||[];r.includes(e)||this._emitFilterChange(t,a,[...r,e]),this._tagInputs={...this._tagInputs,[s]:""},this._tagSuggestions={...this._tagSuggestions,[s]:[]}}_fetchTagSuggestions(t,e,s){if(this._tagDebounceTimers[e]&&clearTimeout(this._tagDebounceTimers[e]),!s||!this.apiClient){this._tagSuggestions={...this._tagSuggestions,[e]:[]},this._tagLoading={...this._tagLoading,[e]:!1};return}this._tagDebounceTimers[e]=setTimeout(async()=>{this._tagLoading={...this._tagLoading,[e]:!0};try{const i=`_${t.ckey||t.key}`,a=await this.apiClient.request("/metadata/autocomplete",{q:s,meta_key:i});(this._tagInputs[e]||"").trim()===s&&(this._tagSuggestions={...this._tagSuggestions,[e]:(a.tags||[]).map(r=>r.tag)})}catch{this._tagSuggestions={...this._tagSuggestions,[e]:[]}}finally{this._tagLoading={...this._tagLoading,[e]:!1}}},300)}_commitTagInput(t,e){const s=(this._tagInputs[e]||"").trim();if(!s)return;const i=this._getApplied(e),a=i.operator||ae[0].value,r=i.values||[];r.includes(s)||this._emitFilterChange(t,a,[...r,s]),this._tagInputs={...this._tagInputs,[e]:""},this._tagSuggestions={...this._tagSuggestions,[e]:[]}}_removeTag(t,e){const s=k(t),i=this._getApplied(s),a=i.operator||ae[0].value,r=i.values||[];this._emitFilterChange(t,a,r.filter(n=>n!==e))}_onTagOperatorChange(t,e){const s=k(t),a=this._getApplied(s).values||[];this._emitFilterChange(t,e,a)}_onDatePreset(t,e){const s=k(t);if(this._datePresets={...this._datePresets,[s]:e},["before","after","between"].includes(e)){this._dateFroms={...this._dateFroms,[s]:""},this._dateTos={...this._dateTos,[s]:""};return}if(e==="empty"||e==="non-empty"){this._emitFilterChange(t,void 0,[e]);return}const i=new Date;let a="",r="";switch(e){case"today":{const n=new Date(i);n.setHours(0,0,0,0),a=n.toISOString(),r=i.toISOString();break}case"last_week":{const n=new Date(i),l=n.getDay();n.setDate(n.getDate()-(l===0?6:l-1)),n.setHours(0,0,0,0);const d=new Date(n);d.setDate(d.getDate()-7),a=d.toISOString(),r=n.toISOString();break}case"last_month":{const n=new Date(i.getFullYear(),i.getMonth(),1),l=new Date(n);l.setMonth(l.getMonth()-1),a=l.toISOString(),r=n.toISOString();break}case"last_year":{const n=new Date(i.getFullYear(),0,1),l=new Date(n);l.setFullYear(l.getFullYear()-1),a=l.toISOString(),r=n.toISOString();break}}a&&r&&(this._dateFroms={...this._dateFroms,[s]:a},this._dateTos={...this._dateTos,[s]:r},this._emitFilterChange(t,"..",[a,r]))}_onDateInput(t,e,s){const i=s.target.value,a=k(t),r=this._datePresets[a]||"",n=i?new Date(i+"T00:00:00").toISOString():"";e==="from"?this._dateFroms={...this._dateFroms,[a]:n}:this._dateTos={...this._dateTos,[a]:n};let l=this._dateFroms[a]||"",d=this._dateTos[a]||"";r==="after"&&l&&(d=new Date().toISOString(),this._dateTos={...this._dateTos,[a]:d}),r==="before"&&d&&(l=new Date(0).toISOString(),this._dateFroms={...this._dateFroms,[a]:l}),l&&d&&this._emitFilterChange(t,"..",[l,d])}_onGeoLocationInput(t,e){var f;const s=e.target.value.trim(),i=k(t),a=(f=this.shadowRoot)==null?void 0:f.querySelector(`[data-geo-radius="${i}"]`),r=(a==null?void 0:a.value)||"";if(!s){this._emitFilterChange(t,void 0,[]);return}const n=s.split(",").map(p=>p.trim());if(n.length!==2||n.some(p=>isNaN(Number(p))||p===""))return;const[l,d]=n;let u=`${l},${d}..${r||"0"}`;this._emitFilterChange(t,x.IS,[u])}_onGeoRadiusInput(t,e){var d;const s=e.target.value,i=k(t),a=this._getApplied(i);if(!((d=a.values)!=null&&d[0]))return;const r=a.values[0],[n]=r.split("..");let l=n;s&&(l+=`..${s}`),this._emitFilterChange(t,x.IS,[l])}_onEmptyOption(t,e){var a;const s=this._getApplied(k(t));((a=s.values)==null?void 0:a[0])===e?this._emitFilterChange(t,s.operator,[]):this._emitFilterChange(t,s.operator,[e])}_getGroupedFields(t){const e=new Map;for(const s of t){const i=s.group||"Root fields";e.has(i)||e.set(i,[]),e.get(i).push(s)}return e}_renderFieldSelection(){const t=this._fieldSearch.toLowerCase(),e=this.fields.filter(a=>a.label.toLowerCase().includes(t)),s=this._getGroupedFields(e),i=(a,r)=>r.length===0?o.nothing:o.html`
|
|
1852
1852
|
<div class="field-group-label">${a}</div>
|
|
1853
1853
|
${r.map(n=>{const l=k(n),d=this.visibleFields.includes(l),h=!d&&this._atFieldLimit;return o.html`
|
|
1854
1854
|
<div
|
|
@@ -2007,7 +2007,7 @@
|
|
|
2007
2007
|
<div class="filter-section">
|
|
2008
2008
|
<span class="section-label">Value</span>
|
|
2009
2009
|
<ap-radio-group
|
|
2010
|
-
.options=${
|
|
2010
|
+
.options=${hi}
|
|
2011
2011
|
.value=${s}
|
|
2012
2012
|
@ap-change=${r=>this._onBooleanSelect(t,r.detail.value)}
|
|
2013
2013
|
></ap-radio-group>
|
|
@@ -2925,7 +2925,7 @@
|
|
|
2925
2925
|
color: var(--ap-primary, oklch(0.578 0.198 268.129));
|
|
2926
2926
|
background: var(--ap-primary-10, oklch(0.578 0.198 268.129 / 0.1));
|
|
2927
2927
|
}
|
|
2928
|
-
`];L([c.property({type:Array})],T.prototype,"fields",2);L([c.property({type:Object})],T.prototype,"appliedFilters",2);L([c.property({type:Array})],T.prototype,"visibleFields",2);L([c.property()],T.prototype,"mode",2);L([c.property()],T.prototype,"activeFieldKey",2);L([c.property({type:Array})],T.prototype,"pinnedFields",2);L([c.property({type:Object})],T.prototype,"appliedMetadata",2);L([c.property({attribute:!1})],T.prototype,"apiClient",2);L([c.state()],T.prototype,"_showFieldSelection",2);L([c.state()],T.prototype,"_fieldSearch",2);L([c.state()],T.prototype,"_collapsedFields",2);L([c.state()],T.prototype,"_tagInputs",2);L([c.state()],T.prototype,"_tagSuggestions",2);L([c.state()],T.prototype,"_tagLoading",2);L([c.state()],T.prototype,"_datePresets",2);L([c.state()],T.prototype,"_dateFroms",2);L([c.state()],T.prototype,"_dateTos",2);L([c.state()],T.prototype,"_specificModeFields",2);L([c.state()],T.prototype,"_selectSearches",2);T=L([c.customElement("ap-filter-metadata")],T);var
|
|
2928
|
+
`];L([c.property({type:Array})],T.prototype,"fields",2);L([c.property({type:Object})],T.prototype,"appliedFilters",2);L([c.property({type:Array})],T.prototype,"visibleFields",2);L([c.property()],T.prototype,"mode",2);L([c.property()],T.prototype,"activeFieldKey",2);L([c.property({type:Array})],T.prototype,"pinnedFields",2);L([c.property({type:Object})],T.prototype,"appliedMetadata",2);L([c.property({attribute:!1})],T.prototype,"apiClient",2);L([c.state()],T.prototype,"_showFieldSelection",2);L([c.state()],T.prototype,"_fieldSearch",2);L([c.state()],T.prototype,"_collapsedFields",2);L([c.state()],T.prototype,"_tagInputs",2);L([c.state()],T.prototype,"_tagSuggestions",2);L([c.state()],T.prototype,"_tagLoading",2);L([c.state()],T.prototype,"_datePresets",2);L([c.state()],T.prototype,"_dateFroms",2);L([c.state()],T.prototype,"_dateTos",2);L([c.state()],T.prototype,"_specificModeFields",2);L([c.state()],T.prototype,"_selectSearches",2);T=L([c.customElement("ap-filter-metadata")],T);var Ta=Object.defineProperty,Ma=Object.getOwnPropertyDescriptor,te=(t,e,s,i)=>{for(var a=i>1?void 0:i?Ma(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&Ta(e,s,a),a};let K=class extends o.LitElement{constructor(){super(...arguments),this.selectedStatus=[],this.statusOperator=":=",this.approverValue="",this.approverOperator="~",this.requesterValue="",this.requesterOperator="~",this.dueDatePreset="",this.dueDateFrom="",this.dueDateTo=""}get _hasAnySelection(){return this.selectedStatus.length>0||!!this.approverValue||!!this.requesterValue||!!this.dueDatePreset||!!this.dueDateFrom||!!this.dueDateTo}get _statusHasEmptyValue(){return this.selectedStatus.includes(H)||this.selectedStatus.includes(G)}get _statusHasOnlyEmptyValues(){return this.selectedStatus.length>0&&this.selectedStatus.every(t=>t===H||t===G)}get _dueDateNeedsInputs(){return["before","after","between","specific"].includes(this.dueDatePreset)}_toggleStatus(t){const e=this.selectedStatus.includes(t)?this.selectedStatus.filter(s=>s!==t):[...this.selectedStatus,t];this._emitChange(R.STATUS,e,this.statusOperator)}_handleStatusOperator(t){const e=t.detail.value;this._emitChange(R.STATUS,this.selectedStatus,e)}_clearStatus(){this._emitChange(R.STATUS,[],this.statusOperator)}_handleApproverInput(t){const e=t.target.value;this._emitChange(R.APPROVER,e?[e]:[],this.approverOperator)}_handleApproverOperator(t){const e=t.detail.value;this._emitChange(R.APPROVER,this.approverValue?[this.approverValue]:[],e)}_clearApprover(){this._emitChange(R.APPROVER,[],this.approverOperator)}_handleRequesterInput(t){const e=t.target.value;this._emitChange(R.REQUESTOR,e?[e]:[],this.requesterOperator)}_handleRequesterOperator(t){const e=t.detail.value;this._emitChange(R.REQUESTOR,this.requesterValue?[this.requesterValue]:[],e)}_clearRequester(){this._emitChange(R.REQUESTOR,[],this.requesterOperator)}_handleDueDatePreset(t){const e=t.detail.value,s=this.dueDatePreset===e?"":e;this._emitChange(R.DUE_DATE,s?[s]:[],":")}_handleDueDateFrom(t){const e=t.target.value;this._emitDateChange(e,this.dueDateTo)}_handleDueDateTo(t){const e=t.target.value;this._emitDateChange(this.dueDateFrom,e)}_clearDueDate(){this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:R.DUE_DATE,values:[],operator:":"},bubbles:!0,composed:!0}))}_emitDateChange(t,e){const s=[];t&&s.push(t),e&&s.push(e),this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:R.DUE_DATE,values:s,operator:t&&e?"..":t?">=":"<="},bubbles:!0,composed:!0}))}_emitChange(t,e,s){this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:t,values:e,operator:s},bubbles:!0,composed:!0}))}_renderStatusSection(){const t=this.selectedStatus.length>0;return o.html`
|
|
2929
2929
|
<div class="filter-section">
|
|
2930
2930
|
<button
|
|
2931
2931
|
class="clear-btn"
|
|
@@ -2939,7 +2939,7 @@
|
|
|
2939
2939
|
<span class="section-label condition-label">Condition</span>
|
|
2940
2940
|
<ap-radio-group
|
|
2941
2941
|
direction="horizontal"
|
|
2942
|
-
.options=${
|
|
2942
|
+
.options=${di}
|
|
2943
2943
|
.value=${this.statusOperator}
|
|
2944
2944
|
?disabled=${this._statusHasOnlyEmptyValues}
|
|
2945
2945
|
@ap-change=${this._handleStatusOperator}
|
|
@@ -2959,7 +2959,7 @@
|
|
|
2959
2959
|
|
|
2960
2960
|
<!-- Status options -->
|
|
2961
2961
|
<div class="options-list short">
|
|
2962
|
-
${
|
|
2962
|
+
${pi.map(e=>o.html`
|
|
2963
2963
|
<ap-checkbox
|
|
2964
2964
|
?checked=${this.selectedStatus.includes(e.value)}
|
|
2965
2965
|
@ap-toggle=${()=>this._toggleStatus(e.value)}
|
|
@@ -3048,7 +3048,7 @@
|
|
|
3048
3048
|
<!-- Date range options -->
|
|
3049
3049
|
<ap-radio-group
|
|
3050
3050
|
columns="2"
|
|
3051
|
-
.options=${
|
|
3051
|
+
.options=${ni}
|
|
3052
3052
|
.value=${this.dueDatePreset!==H&&this.dueDatePreset!==G?this.dueDatePreset:""}
|
|
3053
3053
|
@ap-change=${this._handleDueDatePreset}
|
|
3054
3054
|
></ap-radio-group>
|
|
@@ -3110,7 +3110,7 @@
|
|
|
3110
3110
|
.mt-12 {
|
|
3111
3111
|
margin-top: 12px;
|
|
3112
3112
|
}
|
|
3113
|
-
`];te([c.property({type:Array})],K.prototype,"selectedStatus",2);te([c.property()],K.prototype,"statusOperator",2);te([c.property()],K.prototype,"approverValue",2);te([c.property()],K.prototype,"approverOperator",2);te([c.property()],K.prototype,"requesterValue",2);te([c.property()],K.prototype,"requesterOperator",2);te([c.property()],K.prototype,"dueDatePreset",2);te([c.property()],K.prototype,"dueDateFrom",2);te([c.property()],K.prototype,"dueDateTo",2);K=te([c.customElement("ap-filter-approval")],K);var
|
|
3113
|
+
`];te([c.property({type:Array})],K.prototype,"selectedStatus",2);te([c.property()],K.prototype,"statusOperator",2);te([c.property()],K.prototype,"approverValue",2);te([c.property()],K.prototype,"approverOperator",2);te([c.property()],K.prototype,"requesterValue",2);te([c.property()],K.prototype,"requesterOperator",2);te([c.property()],K.prototype,"dueDatePreset",2);te([c.property()],K.prototype,"dueDateFrom",2);te([c.property()],K.prototype,"dueDateTo",2);K=te([c.customElement("ap-filter-approval")],K);var La=Object.defineProperty,Oa=Object.getOwnPropertyDescriptor,se=(t,e,s,i)=>{for(var a=i>1?void 0:i?Oa(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&La(e,s,a),a};const Pa=300;function Ia(t){return t.filter(e=>e.toLowerCase().includes("*")||!t.some(s=>s.toLowerCase().includes("*")&&e.toLowerCase().startsWith(s.slice(0,-1).toLowerCase())))}let Y=class extends o.LitElement{constructor(){super(...arguments),this.selected=[],this._search="",this._debouncedSearch="",this._products=[],this._isLoading=!1,this._showAddList=!1,this._addListText=""}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>{var t;return(t=this._searchInput)==null?void 0:t.focus()})}disconnectedCallback(){super.disconnectedCallback(),this._debounceTimer&&clearTimeout(this._debounceTimer)}get _isSearching(){return this._debouncedSearch.length>0}_emit(t){const e=Ia(t);this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:v.PRODUCT_REF,values:e,operator:x.IS},bubbles:!0,composed:!0}))}_toggle(t){const s=this.selected.includes(t)?this.selected.filter(i=>i!==t):[...this.selected,t];this._emit(s)}_remove(t){this._emit(this.selected.filter(e=>e!==t))}_clearAll(){this._emit([]),this._search="",this._debouncedSearch="",this._products=[]}_onSearchInput(t){const e=t.target.value;this._search=e,this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{const s=e.trim().toLowerCase();this._debouncedSearch=s,s?this._fetchProducts(s):(this._products=[],this._isLoading=!1)},Pa)}_clearSearch(){this._search="",this._debouncedSearch="",this._products=[],this._isLoading=!1,this._debounceTimer&&clearTimeout(this._debounceTimer)}async _fetchProducts(t){if(this.apiClient){this._isLoading=!0;try{const e=await this.apiClient.request("/products",{q:`reference~^${t}`});this._debouncedSearch===t&&(this._products=e.products??[])}catch{this._debouncedSearch===t&&(this._products=[])}finally{this._debouncedSearch===t&&(this._isLoading=!1)}}}_openAddList(){this._showAddList=!0,this._addListText=""}_closeAddList(){this._showAddList=!1,this._addListText=""}_onAddListInput(t){this._addListText=t.target.value}_onAddListKeydown(t){t.key==="Enter"&&!t.shiftKey&&t.stopPropagation()}_submitAddList(){const t=this._addListText.split(`
|
|
3114
3114
|
`).map(e=>e.trim()).filter(e=>e!=="");if(t.length>0){const e=new Set(this.selected),s=[...this.selected,...t.filter(i=>!e.has(i))];this._emit(s)}this._closeAddList()}_renderProductItem(t){const e=this.selected.includes(t);return o.html`
|
|
3115
3115
|
<div
|
|
3116
3116
|
class="product-item"
|
|
@@ -3469,7 +3469,7 @@
|
|
|
3469
3469
|
color: var(--ap-muted-foreground, oklch(0.685 0.033 249.82));
|
|
3470
3470
|
margin-left: 4px;
|
|
3471
3471
|
}
|
|
3472
|
-
`];se([c.property({type:Array})],Y.prototype,"selected",2);se([c.property({attribute:!1})],Y.prototype,"apiClient",2);se([c.query(".product-search")],Y.prototype,"_searchInput",2);se([c.state()],Y.prototype,"_search",2);se([c.state()],Y.prototype,"_debouncedSearch",2);se([c.state()],Y.prototype,"_products",2);se([c.state()],Y.prototype,"_isLoading",2);se([c.state()],Y.prototype,"_showAddList",2);se([c.state()],Y.prototype,"_addListText",2);Y=se([c.customElement("ap-filter-product-ref")],Y);var
|
|
3472
|
+
`];se([c.property({type:Array})],Y.prototype,"selected",2);se([c.property({attribute:!1})],Y.prototype,"apiClient",2);se([c.query(".product-search")],Y.prototype,"_searchInput",2);se([c.state()],Y.prototype,"_search",2);se([c.state()],Y.prototype,"_debouncedSearch",2);se([c.state()],Y.prototype,"_products",2);se([c.state()],Y.prototype,"_isLoading",2);se([c.state()],Y.prototype,"_showAddList",2);se([c.state()],Y.prototype,"_addListText",2);Y=se([c.customElement("ap-filter-product-ref")],Y);var Da=Object.defineProperty,za=Object.getOwnPropertyDescriptor,A=(t,e,s,i)=>{for(var a=i>1?void 0:i?za(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&Da(e,s,a),a};let F=class extends o.LitElement{constructor(){super(...arguments),this.totalCount=0,this.totalFolderCount=0,this.isLoading=!1,this.showUpload=!1,this.sortBy="created_at",this.sortDirection="desc",this.sortOptions=zt,this.filters={metadata:{pinned:[],visible:[],applied:{}},pinned:[],visible:[],applied:{}},this.labels=[],this.tags=[],this.fileTypes=[],this.metadataFields=[],this.pinnedFilters=[],this.forcedFilterKeys=[],this._showDropdown=!1,this._showMetadataSelector=!1,this._openFilter=null,this._openMetadataField=null,this._externalTrigger=!1,this._externalLeft=null,this._externalTop=null,this._outsideClickHandler=t=>{const e=t.composedPath();if(this._externalTrigger&&e.some(r=>{var n;return r instanceof HTMLElement&&r.classList.contains("chip")&&((n=r.closest)==null?void 0:n.call(r,"ap-filters-bar"))}))return;const s=this._openFilter&&e.some(a=>a instanceof HTMLElement?a.classList.contains("popover-anchor")||a.classList.contains("popover-panel"):!1),i=(this._showDropdown||this._showMetadataSelector)&&e.some(a=>a instanceof HTMLElement&&(a.classList.contains("dropdown-menu")||a.classList.contains("filter-dropdown")||a.classList.contains("metadata-selector-overlay")));s||i||(this._openFilter&&(this._openFilter=null,this._openMetadataField=null,this._externalTrigger=!1,this._externalLeft=null,this._externalTop=null),(this._showDropdown||this._showMetadataSelector)&&(this._showDropdown=!1,this._showMetadataSelector=!1))}}connectedCallback(){super.connectedCallback(),document.addEventListener("mousedown",this._outsideClickHandler)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("mousedown",this._outsideClickHandler)}updated(t){if((t.has("_openFilter")||t.has("_externalTrigger")||t.has("_openMetadataField"))&&this.dispatchEvent(new CustomEvent("filter-panel-change",{detail:{key:this._externalTrigger?this._openFilter:null,metadataFieldKey:this._externalTrigger?this._openMetadataField:null},bubbles:!0,composed:!0})),this._externalTrigger&&this._externalLeft!=null&&(t.has("_openFilter")||t.has("_externalLeft")||t.has("_openMetadataField"))){const e=this.renderRoot.querySelector(".popover-panel");if(e){const s=e.closest(".popover-anchor"),i=s?s.offsetWidth:this.offsetWidth,a=e.offsetWidth;this._externalLeft+a>i-8&&(e.style.left=`${Math.max(8,i-a-8)}px`)}}}_closeAllDropdowns(){var t;this._showDropdown=!1,this._showMetadataSelector=!1,this._openFilter=null,this._openMetadataField=null,this._externalTrigger=!1,this._externalLeft=null,this._externalTop=null,(t=this._sortDropdown)==null||t.close()}_handleUploadClick(){this.dispatchEvent(new CustomEvent("upload-click",{bubbles:!0,composed:!0}))}_toggleDropdown(){const t=this._showDropdown;this._closeAllDropdowns(),this._showDropdown=!t}_toggleMetadataSelector(){this._showMetadataSelector=!this._showMetadataSelector}closeFilterPanel(){this._openFilter=null,this._openMetadataField=null,this._externalTrigger=!1,this._externalLeft=null,this._externalTop=null}openFilterPanel(t,e=!1,s,i){if(e&&this._externalTrigger&&this._openFilter===t&&!this._openMetadataField){this.closeFilterPanel();return}if(!e&&!this._isFilterActive(t)){this._showDropdown=!1,this._showMetadataSelector=!1,this.dispatchEvent(new CustomEvent("filter-pending",{detail:{key:t},bubbles:!0,composed:!0}));return}this._showDropdown=!1,this._showMetadataSelector=!1,this._openFilter=t,this._openMetadataField=null,this._externalTrigger=e,this._externalLeft=s??null,this._externalTop=i??null}_handleSortOpen(){this._showDropdown=!1,this._showMetadataSelector=!1,this._openFilter=null,this._openMetadataField=null,this._externalTrigger=!1,this._externalLeft=null,this._externalTop=null}_handleSort(t){this.dispatchEvent(new CustomEvent("sort-change",{detail:t.detail,bubbles:!0,composed:!0}))}_toggleSortDirection(){const t=this.sortDirection==="asc"?"desc":"asc";this.dispatchEvent(new CustomEvent("sort-direction-change",{detail:{value:t},bubbles:!0,composed:!0}))}_isFilterActive(t){return t in this.filters.applied&&this.filters.applied[t]!==void 0}_handleFilterChange(t){t.stopPropagation();const{key:e,values:s,operator:i}=t.detail;this.dispatchEvent(new CustomEvent("filter-update",{detail:{key:e,values:s,operator:i},bubbles:!0,composed:!0}))}_handleMetadataFilterChange(t){t.stopPropagation(),this.dispatchEvent(new CustomEvent("metadata-filter-change",{detail:t.detail,bubbles:!0,composed:!0}))}_handleMetadataFieldToggle(t){t.stopPropagation(),this.dispatchEvent(new CustomEvent("metadata-field-toggle",{detail:t.detail,bubbles:!0,composed:!0}))}_handleMetadataFieldSelect(t){t.stopPropagation(),this._openMetadataField=t.detail.fieldKey}_handleMetadataSelectorFieldSelect(t){var s;t.stopPropagation();const e=t.detail.fieldKey;if(this._showMetadataSelector=!1,this._showDropdown=!1,!(e in(((s=this.filters.metadata)==null?void 0:s.applied)||{}))){this.dispatchEvent(new CustomEvent("filter-pending",{detail:{metadataFieldKey:e},bubbles:!0,composed:!0}));return}this._openFilter="metadata",this._openMetadataField=e}_handleMetadataPin(t){t.stopPropagation(),this.dispatchEvent(new CustomEvent("metadata-pin",{detail:t.detail,bubbles:!0,composed:!0}))}openMetadataFieldPanel(t,e=!1,s,i){if(e&&this._externalTrigger&&this._openMetadataField===t){this.closeFilterPanel();return}this._showDropdown=!1,this._showMetadataSelector=!1,this._openFilter="metadata",this._openMetadataField=t,this._externalTrigger=e,this._externalLeft=s??null,this._externalTop=i??null}_getMetadataFieldLabel(t){for(const e of this.metadataFields)if(`${vt[e.type]||""}${e.key}`===t)return e.label;return t}_togglePin(t,e){e.stopPropagation();const s=this.pinnedFilters.includes(t);this.dispatchEvent(new CustomEvent("filter-pin",{detail:{key:t,pinned:!s},bubbles:!0,composed:!0}))}_getFilterIcon(t){const e=Pt.find(s=>s.key===t);return(e==null?void 0:e.icon)||"filter"}_renderFilterContent(t){var s,i,a;const e=this.filters.applied;switch(t){case"type":{const r=e.type;return o.html`<ap-filter-type
|
|
3473
3473
|
.selected=${(r==null?void 0:r.values)||[]}
|
|
3474
3474
|
.fileTypes=${this.fileTypes}
|
|
3475
3475
|
@filter-change=${this._handleFilterChange}
|
|
@@ -3986,7 +3986,7 @@
|
|
|
3986
3986
|
border-radius: 8px;
|
|
3987
3987
|
top: 0;
|
|
3988
3988
|
}
|
|
3989
|
-
`;A([c.property({type:Number})],F.prototype,"totalCount",2);A([c.property({type:Number})],F.prototype,"totalFolderCount",2);A([c.property({type:Boolean})],F.prototype,"isLoading",2);A([c.property({type:Boolean})],F.prototype,"showUpload",2);A([c.property()],F.prototype,"sortBy",2);A([c.property()],F.prototype,"sortDirection",2);A([c.property({type:Array})],F.prototype,"sortOptions",2);A([c.property({type:Object})],F.prototype,"filters",2);A([c.property({type:Array})],F.prototype,"labels",2);A([c.property({type:Array})],F.prototype,"tags",2);A([c.property({type:Array})],F.prototype,"fileTypes",2);A([c.property({type:Array})],F.prototype,"metadataFields",2);A([c.property({type:Array})],F.prototype,"pinnedFilters",2);A([c.property({type:Array})],F.prototype,"forcedFilterKeys",2);A([c.property({attribute:!1})],F.prototype,"apiClient",2);A([c.query("ap-dropdown")],F.prototype,"_sortDropdown",2);A([c.state()],F.prototype,"_showDropdown",2);A([c.state()],F.prototype,"_showMetadataSelector",2);A([c.state()],F.prototype,"_openFilter",2);A([c.state()],F.prototype,"_openMetadataField",2);A([c.state()],F.prototype,"_externalTrigger",2);A([c.state()],F.prototype,"_externalLeft",2);A([c.state()],F.prototype,"_externalTop",2);F=A([c.customElement("ap-content-toolbar")],F);var
|
|
3989
|
+
`;A([c.property({type:Number})],F.prototype,"totalCount",2);A([c.property({type:Number})],F.prototype,"totalFolderCount",2);A([c.property({type:Boolean})],F.prototype,"isLoading",2);A([c.property({type:Boolean})],F.prototype,"showUpload",2);A([c.property()],F.prototype,"sortBy",2);A([c.property()],F.prototype,"sortDirection",2);A([c.property({type:Array})],F.prototype,"sortOptions",2);A([c.property({type:Object})],F.prototype,"filters",2);A([c.property({type:Array})],F.prototype,"labels",2);A([c.property({type:Array})],F.prototype,"tags",2);A([c.property({type:Array})],F.prototype,"fileTypes",2);A([c.property({type:Array})],F.prototype,"metadataFields",2);A([c.property({type:Array})],F.prototype,"pinnedFilters",2);A([c.property({type:Array})],F.prototype,"forcedFilterKeys",2);A([c.property({attribute:!1})],F.prototype,"apiClient",2);A([c.query("ap-dropdown")],F.prototype,"_sortDropdown",2);A([c.state()],F.prototype,"_showDropdown",2);A([c.state()],F.prototype,"_showMetadataSelector",2);A([c.state()],F.prototype,"_openFilter",2);A([c.state()],F.prototype,"_openMetadataField",2);A([c.state()],F.prototype,"_externalTrigger",2);A([c.state()],F.prototype,"_externalLeft",2);A([c.state()],F.prototype,"_externalTop",2);F=A([c.customElement("ap-content-toolbar")],F);var Ra=Object.defineProperty,ja=Object.getOwnPropertyDescriptor,B=(t,e,s,i)=>{for(var a=i>1?void 0:i?ja(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&Ra(e,s,a),a};let D=class extends o.LitElement{constructor(){super(...arguments),this.appliedFilters={},this.appliedMetadata={},this.forcedFilters={},this.metadataFields=[],this.pinnedFilters=[],this.pinnedMetadataFields=[],this.tags=[],this.labels=[],this.activeFilter=null,this.activeMetadataField=null,this.pendingFilter=null,this.pendingMetadataField=null}_mapTypeLabel(t){var i;const e=(i=ct.find(a=>a.value===t))==null?void 0:i.label;if(e)return e;const s=t.indexOf("_");return s!==-1?t.slice(s+1).toUpperCase():t}_getSizeSummary(t){if(t.values.length===0)return"";const e=t.values[0],[s,i]=e.split(".."),a=s?parseFloat(s):null,r=i?parseFloat(i):null,n=l=>l>=1e3?`${(l/1e3).toFixed(l%1e3===0?0:1)} GB`:`${l} MB`;return a!==null&&r!==null?`${n(a)} – ${n(r)}`:a!==null?`> ${n(a)}`:r!==null?`< ${n(r)}`:""}_getFilterSummary(t,e){if(t.type==="string"){const s=t;if(s.values.length===0)return"";if(e===v.SIZE)return this._getSizeSummary(s);if(e===v.COLOR){const a=s.values.map(r=>r.split(" ")[0]).filter(Boolean);return a.length===0?"":a.length===1?a[0]:`${a[0]} +${a.length-1}`}const i=e===v.TYPE?a=>this._mapTypeLabel(a):e===v.TAGS?a=>{var r;return((r=this.tags.find(n=>n.sid===a))==null?void 0:r.label)||a}:e===v.LABELS?a=>{var r;return((r=this.labels.find(n=>n.sid===a))==null?void 0:r.name)||a}:a=>a;return s.values.length===1?i(s.values[0]):`${i(s.values[0])} +${s.values.length-1}`}if(t.type==="date")return this._getDateSummary(t);if(typeof t=="object"&&"resolution"in t){const s=t,i=[...s.resolution,...s.orientation,...s.faces];return i.length===0?"":i.length===1?i[0]:`${i[0]} +${i.length-1}`}return""}_getDateSummary(t){var n,l;const e=((n=ds.find(d=>d.value===t.field))==null?void 0:n.label)||t.field,s=[...Dt,...ps],i=t.preset?((l=s.find(d=>d.value===t.preset))==null?void 0:l.label)||t.preset:"",a=d=>{try{return d.split("T")[0]}catch{return d}};let r="";switch(t.kind){case"preset":r=i;break;case"before":r=t.to?`Before ${a(t.to)}`:i;break;case"after":r=t.from?`After ${a(t.from)}`:i;break;case"between":t.from&&t.to?r=`${a(t.from)} – ${a(t.to)}`:t.from?r=`After ${a(t.from)}`:t.to&&(r=`Before ${a(t.to)}`);break;case"specific":r=t.from?a(t.from):"";break;default:r=i}return r?`${e}: ${r}`:""}_getFilterIcon(t){var e;return((e=Pt.find(s=>s.key===t))==null?void 0:e.icon)||"filter"}_getMetadataLabel(t){const e=this._stripMetadataPrefix(t),s=this.metadataFields.find(i=>i.key===e);return(s==null?void 0:s.label)||e}_getMetadataIcon(t){const e=this._stripMetadataPrefix(t),s=this.metadataFields.find(i=>i.key===e);return s&<[s.type]||"file-text"}_stripMetadataPrefix(t){for(const e of os)if(t.startsWith(e))return t.slice(e.length);return t}_removeFilter(t){this.dispatchEvent(new CustomEvent("filter-remove",{detail:{key:t},bubbles:!0,composed:!0}))}_removeMetadataFilter(t){this.dispatchEvent(new CustomEvent("metadata-filter-remove",{detail:{fieldKey:t},bubbles:!0,composed:!0}))}_clearAll(){this.dispatchEvent(new CustomEvent("filters-clear-all",{bubbles:!0,composed:!0}))}_openFilter(t,e){const i=e.currentTarget.getBoundingClientRect();this.dispatchEvent(new CustomEvent("filter-open",{detail:{key:t,chipRect:{left:i.left,right:i.right,bottom:i.bottom,width:i.width}},bubbles:!0,composed:!0}))}_openMetadataFilter(t,e){const i=e.currentTarget.getBoundingClientRect();this.dispatchEvent(new CustomEvent("metadata-filter-open",{detail:{fieldKey:t,chipRect:{left:i.left,right:i.right,bottom:i.bottom,width:i.width}},bubbles:!0,composed:!0}))}_renderForcedChip(t,e){const s=this._getFilterSummary(e,t),i=e.type==="date";return o.html`
|
|
3990
3990
|
<span class="chip forced">
|
|
3991
3991
|
${(i||t===v.TYPE||t===v.SIZE)&&s?o.html`<span class="chip-label">${s}</span>`:o.html`
|
|
3992
3992
|
<span class="chip-label">${Le[t]||t}</span>
|
|
@@ -4201,7 +4201,7 @@
|
|
|
4201
4201
|
align-items: center;
|
|
4202
4202
|
opacity: 0.6;
|
|
4203
4203
|
}
|
|
4204
|
-
`;B([c.property({type:Object})],D.prototype,"appliedFilters",2);B([c.property({type:Object})],D.prototype,"appliedMetadata",2);B([c.property({type:Object})],D.prototype,"forcedFilters",2);B([c.property({type:Array})],D.prototype,"metadataFields",2);B([c.property({type:Array})],D.prototype,"pinnedFilters",2);B([c.property({type:Array})],D.prototype,"pinnedMetadataFields",2);B([c.property({type:Array})],D.prototype,"tags",2);B([c.property({type:Array})],D.prototype,"labels",2);B([c.property()],D.prototype,"activeFilter",2);B([c.property()],D.prototype,"activeMetadataField",2);B([c.property()],D.prototype,"pendingFilter",2);B([c.property()],D.prototype,"pendingMetadataField",2);D=B([c.customElement("ap-filters-bar")],D);var
|
|
4204
|
+
`;B([c.property({type:Object})],D.prototype,"appliedFilters",2);B([c.property({type:Object})],D.prototype,"appliedMetadata",2);B([c.property({type:Object})],D.prototype,"forcedFilters",2);B([c.property({type:Array})],D.prototype,"metadataFields",2);B([c.property({type:Array})],D.prototype,"pinnedFilters",2);B([c.property({type:Array})],D.prototype,"pinnedMetadataFields",2);B([c.property({type:Array})],D.prototype,"tags",2);B([c.property({type:Array})],D.prototype,"labels",2);B([c.property()],D.prototype,"activeFilter",2);B([c.property()],D.prototype,"activeMetadataField",2);B([c.property()],D.prototype,"pendingFilter",2);B([c.property()],D.prototype,"pendingMetadataField",2);D=B([c.customElement("ap-filters-bar")],D);var Na=Object.defineProperty,Ba=Object.getOwnPropertyDescriptor,ie=(t,e,s,i)=>{for(var a=i>1?void 0:i?Ba(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&Na(e,s,a),a};const Ua=6;let X=class extends o.LitElement{constructor(){super(...arguments),this.assets=[],this.folders=[],this.folderPreviews={},this.selectedIds=[],this.selectedFolderIds=[],this.isLoading=!1,this.multiSelect=!0,this.folderSelectable=!1,this.gridSize="normal",this._prevCount=0}willUpdate(t){if(t.has("assets")){const e=t.get("assets");e&&this.assets.length>e.length?this._prevCount=e.length:this._prevCount=0}}render(){const t=this.gridSize==="large"?"280px":"220px";return o.html`
|
|
4205
4205
|
<div class="grid" role="list" aria-label="Assets" style="--ap-grid-min-col: ${t}">
|
|
4206
4206
|
${this.folders.map((e,s)=>o.html`
|
|
4207
4207
|
<ap-folder-card
|
|
@@ -4229,7 +4229,7 @@
|
|
|
4229
4229
|
@asset-quick-select=${a=>this.dispatchEvent(new CustomEvent("asset-quick-select",{detail:a.detail,bubbles:!0,composed:!0}))}
|
|
4230
4230
|
></ap-asset-card>
|
|
4231
4231
|
`})}
|
|
4232
|
-
${this.isLoading?Array.from({length:
|
|
4232
|
+
${this.isLoading?Array.from({length:Ua},()=>o.html`<div class="ghost-card">
|
|
4233
4233
|
<div class="ghost-thumb"></div>
|
|
4234
4234
|
<div class="ghost-info">
|
|
4235
4235
|
<div class="ghost-line ghost-name"></div>
|
|
@@ -4292,7 +4292,7 @@
|
|
|
4292
4292
|
@media (prefers-reduced-motion: reduce) {
|
|
4293
4293
|
.ghost-thumb, .ghost-line { animation: none; }
|
|
4294
4294
|
}
|
|
4295
|
-
`;ie([c.property({type:Array})],X.prototype,"assets",2);ie([c.property({type:Array})],X.prototype,"folders",2);ie([c.property({type:Object})],X.prototype,"folderPreviews",2);ie([c.property({type:Array})],X.prototype,"selectedIds",2);ie([c.property({type:Array})],X.prototype,"selectedFolderIds",2);ie([c.property({type:Boolean})],X.prototype,"isLoading",2);ie([c.property({type:Boolean})],X.prototype,"multiSelect",2);ie([c.property({type:Boolean})],X.prototype,"folderSelectable",2);ie([c.property({type:String})],X.prototype,"gridSize",2);X=ie([c.customElement("ap-grid-view")],X);var
|
|
4295
|
+
`;ie([c.property({type:Array})],X.prototype,"assets",2);ie([c.property({type:Array})],X.prototype,"folders",2);ie([c.property({type:Object})],X.prototype,"folderPreviews",2);ie([c.property({type:Array})],X.prototype,"selectedIds",2);ie([c.property({type:Array})],X.prototype,"selectedFolderIds",2);ie([c.property({type:Boolean})],X.prototype,"isLoading",2);ie([c.property({type:Boolean})],X.prototype,"multiSelect",2);ie([c.property({type:Boolean})],X.prototype,"folderSelectable",2);ie([c.property({type:String})],X.prototype,"gridSize",2);X=ie([c.customElement("ap-grid-view")],X);var Va=Object.defineProperty,qa=Object.getOwnPropertyDescriptor,W=(t,e,s,i)=>{for(var a=i>1?void 0:i?qa(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&Va(e,s,a),a};const Ha=5;let N=class extends o.LitElement{constructor(){super(...arguments),this.assets=[],this.folders=[],this.selectedIds=[],this.selectedFolderIds=[],this.isLoading=!1,this.multiSelect=!0,this.folderSelectable=!1,this.totalCount=0,this.isSelectingAll=!1,this.folderPreviews={},this._compactLevel=0}connectedCallback(){super.connectedCallback(),this._resizeObserver=new ResizeObserver(t=>{var i;const e=((i=t[0])==null?void 0:i.contentRect.width)??0,s=e<550?2:e<680?1:0;s!==this._compactLevel&&(this._compactLevel=s)}),this._resizeObserver.observe(this)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._resizeObserver)==null||t.disconnect()}_getGridColumns(t){const e=[];return t&&e.push("32px"),e.push("48px"),e.push("minmax(120px, 1fr)"),e.push("72px"),this._compactLevel<2&&e.push("100px"),this._compactLevel<1&&e.push("120px"),e.push("64px"),e.join(" ")}get _allVisibleSelected(){if(this.assets.length===0&&this.folders.length===0||this.selectedIds.length===0&&this.selectedFolderIds.length===0)return!1;const t=new Set(this.selectedIds),e=this.assets.length===0||this.assets.every(a=>t.has(a.uuid));if(!this.folderSelectable)return e&&this.assets.length>0;const s=new Set(this.selectedFolderIds),i=this.folders.length===0||this.folders.every(a=>s.has(a.uuid));return e&&i}_handleHeaderCheckboxClick(){if(this.isSelectingAll)return;const t=this.folderSelectable?this.totalCount+this.folders.length:this.totalCount,e=this.folderSelectable?this.selectedIds.length+this.selectedFolderIds.length:this.selectedIds.length;this._allVisibleSelected&&e>=t?this.dispatchEvent(new CustomEvent("selection-clear",{bubbles:!0,composed:!0})):this.dispatchEvent(new CustomEvent("select-all",{detail:{scope:"all"},bubbles:!0,composed:!0}))}render(){const t=this.folderSelectable?this.totalCount+this.folders.length:this.totalCount,e=this.folderSelectable?this.selectedIds.length+this.selectedFolderIds.length:this.selectedIds.length,s=this._allVisibleSelected&&e>=t;return o.html`
|
|
4296
4296
|
<div class="list-header" style="grid-template-columns: ${this._getGridColumns(this.multiSelect)}" role="row" aria-label="Column headers">
|
|
4297
4297
|
${this.multiSelect?o.html`<span class="header-checkbox" @click=${this._handleHeaderCheckboxClick}>
|
|
4298
4298
|
<div class="header-check-box ${s?"checked":e>0?"indeterminate":""}">
|
|
@@ -4339,7 +4339,7 @@
|
|
|
4339
4339
|
@asset-quick-select=${r=>this.dispatchEvent(new CustomEvent("asset-quick-select",{detail:r.detail,bubbles:!0,composed:!0}))}
|
|
4340
4340
|
></ap-asset-row>
|
|
4341
4341
|
`)}
|
|
4342
|
-
${this.isLoading?Array.from({length:
|
|
4342
|
+
${this.isLoading?Array.from({length:Ha},(i,a)=>{const r=["70%","55%","80%","45%","65%"];return o.html`
|
|
4343
4343
|
<div class="ghost-row" style="grid-template-columns: ${this._getGridColumns(this.multiSelect)}">
|
|
4344
4344
|
${this.multiSelect?o.html`<div class="ghost-el ghost-check"></div>`:o.nothing}
|
|
4345
4345
|
<div class="ghost-el ghost-thumb"></div>
|
|
@@ -4438,7 +4438,7 @@
|
|
|
4438
4438
|
@media (prefers-reduced-motion: reduce) {
|
|
4439
4439
|
.ghost-el { animation: none; }
|
|
4440
4440
|
}
|
|
4441
|
-
`;W([c.property({type:Array})],N.prototype,"assets",2);W([c.property({type:Array})],N.prototype,"folders",2);W([c.property({type:Array})],N.prototype,"selectedIds",2);W([c.property({type:Array})],N.prototype,"selectedFolderIds",2);W([c.property({type:Boolean})],N.prototype,"isLoading",2);W([c.property({type:Boolean})],N.prototype,"multiSelect",2);W([c.property({type:Boolean})],N.prototype,"folderSelectable",2);W([c.property({type:Number})],N.prototype,"totalCount",2);W([c.property({type:Boolean})],N.prototype,"isSelectingAll",2);W([c.property({type:Object})],N.prototype,"folderPreviews",2);W([c.state()],N.prototype,"_compactLevel",2);N=W([c.customElement("ap-list-view")],N);const
|
|
4441
|
+
`;W([c.property({type:Array})],N.prototype,"assets",2);W([c.property({type:Array})],N.prototype,"folders",2);W([c.property({type:Array})],N.prototype,"selectedIds",2);W([c.property({type:Array})],N.prototype,"selectedFolderIds",2);W([c.property({type:Boolean})],N.prototype,"isLoading",2);W([c.property({type:Boolean})],N.prototype,"multiSelect",2);W([c.property({type:Boolean})],N.prototype,"folderSelectable",2);W([c.property({type:Number})],N.prototype,"totalCount",2);W([c.property({type:Boolean})],N.prototype,"isSelectingAll",2);W([c.property({type:Object})],N.prototype,"folderPreviews",2);W([c.state()],N.prototype,"_compactLevel",2);N=W([c.customElement("ap-list-view")],N);const Ga=new Set(["jpg","jpeg","png","gif","webp","svg","bmp","ico","tiff","tif","avif","heic","heif","psd","eps"]),Ka=new Set([...Ga,"pdf","psd","eps","ai","ttf","otf","woff","woff2","eot"]);function Oe(t){if(!t)return"other";const e={image:"image",video:"video",audio:"audio",application:"document",font:"font",text:"document"};return e[t]?e[t]:t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":t.startsWith("application/pdf")||t.startsWith("text/")||t.startsWith("application/msword")||t.startsWith("application/vnd.")?"document":t.startsWith("application/zip")||t.startsWith("application/x-rar")||t.startsWith("application/x-7z")||t.startsWith("application/gzip")?"archive":t.startsWith("font/")?"font":"other"}function ys(t){const e=(t==null?void 0:t.toLowerCase().replace(".",""))||"";return Ka.has(e)}const xs="https://assets.filerobot.com/scaleflex/assets/file-types/v2/",Ya={png:"PNG",jpg:"JPG",jpeg:"JPG",gif:"GIF",bmp:"BMP",webp:"WEBP",svg:"SVG",tiff:"TIFF",tif:"TIFF",heic:"HEIC",avif:"AVIF",ico:"ICO",pdf:"PDF",doc:"DOC",docx:"DOCX",txt:"TXT",rtf:"RTF",xls:"XLS",xlsx:"XLSX",ppt:"PPT",pptx:"PPTX",csv:"CSV",odt:"ODT",ods:"ODS",odp:"ODP",mp4:"MP4",webm:"WEBM",mov:"MOV",avi:"AVI",mkv:"MKV",mpeg:"MPEG",mp3:"MP3",wav:"WAV",aac:"AAC",flac:"FLAC",ogg:"OGG",wma:"WMA",zip:"ZIP",rar:"RAR","7z":"7Z",tar:"TAR",gz:"GZ",ttf:"TTF",otf:"OTF",woff:"WOFF",woff2:"WOFF2",eot:"EOT",psd:"PSD",ai:"AI",dwg:"DWG",js:"JS",ts:"TS",css:"CSS",html:"HTML",json:"JSON",xml:"XML",php:"PHP",sh:"SH",exe:"EXE",iso:"ISO",bin:"BIN"};function et(t){const e=(t==null?void 0:t.toLowerCase().replace(".",""))||"",s=Ya[e];return`${xs}${s||"DEFAULT"}.png`}function De(){return`${xs}DEFAULT.png`}function yt(t){if(!t)return"";const e=t.split("/");return e.length>1?e[1]:e[0]}const Xa=new Set(["png","svg","webp","gif","avif"]);function Nt(t){const e=(t==null?void 0:t.toLowerCase().replace(".",""))||"";return Xa.has(e)}const Wa=new Set(["svg","svg+xml","png","pdf"]);function ws(t){return Wa.has(yt(t).toLowerCase())}function pt(t){var i;const e=t.info,s=(e==null?void 0:e.video_thumbnail)||(e==null?void 0:e.image_thumbnail)||(e==null?void 0:e.thumbnail)||(e==null?void 0:e.preview)||((i=t.url)==null?void 0:i.cdn)||"";return ze(s)}function $s(t){const e=t.info,s=(e==null?void 0:e.video_thumbnail)||(e==null?void 0:e.image_thumbnail)||(e==null?void 0:e.thumbnail)||"";return s?ze(s):""}function Bt(t){var s,i;let e=ze(((s=t.url)==null?void 0:s.cdn)||((i=t.url)==null?void 0:i.public)||"");return e?(e=e.replace(/([?&])func=proxy&?/,"$1").replace(/[?&]$/,""),Ke(e,{w:"200",force_format:"webp,jpeg",doc_page:"1",bypass_process_proxy:"1"})):""}function Ke(t,e){try{const s=new URL(t);for(const[i,a]of Object.entries(e))s.searchParams.set(i,a);return s.toString()}catch{return t}}const rs=/^(https:\/\/)([a-z0-9_-]+)\.filerobot\.com\//i;function ze(t,e){if(!t)return"";if(t.includes("assets.filerobot.com"))return t;const s=t.match(rs);if(s){const i=s[2];return t.replace(rs,`$1assets.filerobot.com/${i}/`)}if(e)try{const i=new URL(t);return`https://assets.filerobot.com/${e}${i.pathname}${i.search}`}catch{}return t}function ks(t,e){const s=t.file_uri_cdn;if(!s)return"";let i=ze(s);const a=Oe(t.file_type),r=String(window.devicePixelRatio||1);return a==="video"?Ke(i,{w:e,dpr:r,force_format:"webp,jpeg"}):t.file_type==="application/pdf"||yt(t.file_type).toLowerCase()==="pdf"?(i=i.replace(/([?&])func=proxy&?/,"$1").replace(/[?&]$/,""),Ke(i,{w:e,dpr:r,force_format:"webp,jpeg",doc_page:"1",bypass_process_proxy:"1"})):Ke(i,{w:e,dpr:r})}function Ut(t){if(t===0)return"0 B";const e=["B","KB","MB","GB","TB"],s=1024,i=Math.floor(Math.log(t)/Math.log(s));return`${(t/Math.pow(s,i)).toFixed(i===0?0:1)} ${e[i]}`}function ht(t){if(!t)return"—";const e=new Date(t);return isNaN(e.getTime())?"—":e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function Ss(t,e){return!t||!e?"":`${t} x ${e}`}var Qa=Object.defineProperty,Za=Object.getOwnPropertyDescriptor,tt=(t,e,s,i)=>{for(var a=i>1?void 0:i?Za(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&Qa(e,s,a),a};let ke=class extends o.LitElement{constructor(){super(...arguments),this.index=0,this.selected=!1,this.multiSelect=!0}_handleSelect(t){if(t.stopPropagation(),t.composedPath().some(i=>i instanceof HTMLElement&&(i.classList.contains("check")||i.classList.contains("check-box")))){this.dispatchEvent(new CustomEvent("asset-select",{detail:{asset:this.asset,index:this.index,event:new MouseEvent("click",{ctrlKey:!0,metaKey:!0,shiftKey:t.shiftKey})},bubbles:!0}));return}this.dispatchEvent(new CustomEvent("asset-select",{detail:{asset:this.asset,index:this.index,event:t},bubbles:!0}))}_handlePreview(t){t.stopPropagation(),this.dispatchEvent(new CustomEvent("asset-preview",{detail:{asset:this.asset},bubbles:!0}))}_formatDuration(t){const e=Math.floor(t/3600),s=Math.floor(t%3600/60),i=Math.floor(t%60),a=r=>String(r).padStart(2,"0");return e>0?`${e}:${a(s)}:${a(i)}`:`${a(s)}:${a(i)}`}_handleQuickSelect(t){t.stopPropagation(),this.dispatchEvent(new CustomEvent("asset-quick-select",{detail:{asset:this.asset},bubbles:!0}))}render(){var d,h,u,f,p;const t=this.asset;if(!t)return o.html``;const s=Oe(t.type)==="video",i=((d=t.extension)==null?void 0:d.toLowerCase())==="pdf",a=ys(t.extension||"");let r="";s?r=$s(t):i?r=Bt(t):a&&(r=pt(t));const n=et(t.extension||""),l=Nt(t.extension||"");return o.html`
|
|
4442
4442
|
<div class="card" @click=${this._handleSelect}>
|
|
4443
4443
|
<div class="thumbnail ${l&&r?"chess":""}">
|
|
4444
4444
|
${r?o.html`<img
|
|
@@ -4658,7 +4658,7 @@
|
|
|
4658
4658
|
:host { animation: none; }
|
|
4659
4659
|
.overlay { transition: none; }
|
|
4660
4660
|
}
|
|
4661
|
-
`;tt([c.property({type:Object})],ke.prototype,"asset",2);tt([c.property({type:Number})],ke.prototype,"index",2);tt([c.property({type:Boolean,reflect:!0})],ke.prototype,"selected",2);tt([c.property({type:Boolean})],ke.prototype,"multiSelect",2);ke=tt([c.customElement("ap-asset-card")],ke);var
|
|
4661
|
+
`;tt([c.property({type:Object})],ke.prototype,"asset",2);tt([c.property({type:Number})],ke.prototype,"index",2);tt([c.property({type:Boolean,reflect:!0})],ke.prototype,"selected",2);tt([c.property({type:Boolean})],ke.prototype,"multiSelect",2);ke=tt([c.customElement("ap-asset-card")],ke);var Ja=Object.defineProperty,er=Object.getOwnPropertyDescriptor,Ue=(t,e,s,i)=>{for(var a=i>1?void 0:i?er(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&Ja(e,s,a),a};let he=class extends o.LitElement{constructor(){super(...arguments),this.index=0,this.selected=!1,this.multiSelect=!0,this.compactLevel=0}_getGridColumns(){const t=[];return this.multiSelect&&t.push("32px"),t.push("48px"),t.push("minmax(120px, 1fr)"),t.push("72px"),this.compactLevel<2&&t.push("100px"),this.compactLevel<1&&t.push("120px"),t.push("64px"),t.join(" ")}_handleSelect(t){if(t.composedPath().some(i=>i instanceof HTMLElement&&(i.classList.contains("check")||i.classList.contains("check-box")))){this.dispatchEvent(new CustomEvent("asset-select",{detail:{asset:this.asset,index:this.index,event:new MouseEvent("click",{ctrlKey:!0,metaKey:!0,shiftKey:t.shiftKey})},bubbles:!0}));return}this.dispatchEvent(new CustomEvent("asset-select",{detail:{asset:this.asset,index:this.index,event:t},bubbles:!0}))}_handlePreview(t){t.stopPropagation(),this.dispatchEvent(new CustomEvent("asset-preview",{detail:{asset:this.asset},bubbles:!0}))}_handleQuickSelect(t){t.stopPropagation(),this.dispatchEvent(new CustomEvent("asset-quick-select",{detail:{asset:this.asset},bubbles:!0}))}render(){var d,h,u;const t=this.asset;if(!t)return o.html``;const s=Oe(t.type)==="video",i=((d=t.extension)==null?void 0:d.toLowerCase())==="pdf",a=ys(t.extension||"");let r="";s?r=$s(t):i?r=Bt(t):a&&(r=pt(t));const n=et(t.extension||""),l=Nt(t.extension||"");return o.html`
|
|
4662
4662
|
<div class="row" style="grid-template-columns: ${this._getGridColumns()}" @click=${this._handleSelect}>
|
|
4663
4663
|
${this.multiSelect?o.html`
|
|
4664
4664
|
<div class="check">
|
|
@@ -4826,7 +4826,7 @@
|
|
|
4826
4826
|
:host([selected]) .check-icon {
|
|
4827
4827
|
display: block;
|
|
4828
4828
|
}
|
|
4829
|
-
`;Ue([c.property({type:Object})],he.prototype,"asset",2);Ue([c.property({type:Number})],he.prototype,"index",2);Ue([c.property({type:Boolean,reflect:!0})],he.prototype,"selected",2);Ue([c.property({type:Boolean})],he.prototype,"multiSelect",2);Ue([c.property({type:Number})],he.prototype,"compactLevel",2);he=Ue([c.customElement("ap-asset-row")],he);var
|
|
4829
|
+
`;Ue([c.property({type:Object})],he.prototype,"asset",2);Ue([c.property({type:Number})],he.prototype,"index",2);Ue([c.property({type:Boolean,reflect:!0})],he.prototype,"selected",2);Ue([c.property({type:Boolean})],he.prototype,"multiSelect",2);Ue([c.property({type:Number})],he.prototype,"compactLevel",2);he=Ue([c.customElement("ap-asset-row")],he);var tr=Object.defineProperty,sr=Object.getOwnPropertyDescriptor,Ae=(t,e,s,i)=>{for(var a=i>1?void 0:i?sr(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&tr(e,s,a),a};let ne=class extends o.LitElement{constructor(){super(...arguments),this.previews=[],this.selected=!1,this.selectable=!1,this.multiSelect=!0,this.index=0}_handleClick(t){if(!this.selectable){this._handleOpen();return}if(t.composedPath().some(i=>i instanceof HTMLElement&&(i.classList.contains("check")||i.classList.contains("check-box")))){t.stopPropagation(),this.dispatchEvent(new CustomEvent("folder-select",{detail:{folder:this.folder,index:this.index,event:new MouseEvent("click",{ctrlKey:!0,metaKey:!0,shiftKey:t.shiftKey})},bubbles:!0,composed:!0}));return}this._handleOpen()}_handleOpen(){this.dispatchEvent(new CustomEvent("folder-open",{detail:{folder:this.folder},bubbles:!0,composed:!0}))}_getPreviewUrl(t){return ks(t,"200")}_renderPreviewImg(t){const e=ws(t.file_type),s=this._getPreviewUrl(t),i=et(yt(t.file_type)),a=De();return o.html`<div class="preview-slot ${e?"icon-bg":""}">
|
|
4830
4830
|
<img
|
|
4831
4831
|
class="preview-img ${e?"icon-mode":""}"
|
|
4832
4832
|
src="${s||i}"
|
|
@@ -5051,7 +5051,7 @@
|
|
|
5051
5051
|
:host([selected]) .check-icon {
|
|
5052
5052
|
display: block;
|
|
5053
5053
|
}
|
|
5054
|
-
`];Ae([c.property({type:Object})],ne.prototype,"folder",2);Ae([c.property({type:Array})],ne.prototype,"previews",2);Ae([c.property({type:Boolean,reflect:!0})],ne.prototype,"selected",2);Ae([c.property({type:Boolean})],ne.prototype,"selectable",2);Ae([c.property({type:Boolean})],ne.prototype,"multiSelect",2);Ae([c.property({type:Number})],ne.prototype,"index",2);ne=Ae([c.customElement("ap-folder-card")],ne);var
|
|
5054
|
+
`];Ae([c.property({type:Object})],ne.prototype,"folder",2);Ae([c.property({type:Array})],ne.prototype,"previews",2);Ae([c.property({type:Boolean,reflect:!0})],ne.prototype,"selected",2);Ae([c.property({type:Boolean})],ne.prototype,"selectable",2);Ae([c.property({type:Boolean})],ne.prototype,"multiSelect",2);Ae([c.property({type:Number})],ne.prototype,"index",2);ne=Ae([c.customElement("ap-folder-card")],ne);var ir=Object.defineProperty,ar=Object.getOwnPropertyDescriptor,ge=(t,e,s,i)=>{for(var a=i>1?void 0:i?ar(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&ir(e,s,a),a};let Z=class extends o.LitElement{constructor(){super(...arguments),this.previews=[],this.selected=!1,this.selectable=!1,this.multiSelect=!0,this.index=0,this.compactLevel=0}_getGridColumns(){const t=[];return this.multiSelect&&t.push("32px"),t.push("48px"),t.push("minmax(120px, 1fr)"),t.push("72px"),this.compactLevel<2&&t.push("100px"),this.compactLevel<1&&t.push("120px"),t.push("64px"),t.join(" ")}_renderPreviewImg(t){const e=ws(t.file_type),s=ks(t,"80"),i=et(yt(t.file_type)),a=De();return o.html`<div class="preview-slot ${e?"icon-bg":""}"><img
|
|
5055
5055
|
class="preview-img ${e?"icon-mode":""}"
|
|
5056
5056
|
src="${s||i}"
|
|
5057
5057
|
alt=""
|
|
@@ -5205,7 +5205,7 @@
|
|
|
5205
5205
|
:host([selected]) .check-icon {
|
|
5206
5206
|
display: block;
|
|
5207
5207
|
}
|
|
5208
|
-
`;ge([c.property({type:Object})],Z.prototype,"folder",2);ge([c.property({type:Array})],Z.prototype,"previews",2);ge([c.property({type:Boolean,reflect:!0})],Z.prototype,"selected",2);ge([c.property({type:Boolean})],Z.prototype,"selectable",2);ge([c.property({type:Boolean})],Z.prototype,"multiSelect",2);ge([c.property({type:Number})],Z.prototype,"index",2);ge([c.property({type:Number})],Z.prototype,"compactLevel",2);Z=ge([c.customElement("ap-folder-row")],Z);var
|
|
5208
|
+
`;ge([c.property({type:Object})],Z.prototype,"folder",2);ge([c.property({type:Array})],Z.prototype,"previews",2);ge([c.property({type:Boolean,reflect:!0})],Z.prototype,"selected",2);ge([c.property({type:Boolean})],Z.prototype,"selectable",2);ge([c.property({type:Boolean})],Z.prototype,"multiSelect",2);ge([c.property({type:Number})],Z.prototype,"index",2);ge([c.property({type:Number})],Z.prototype,"compactLevel",2);Z=ge([c.customElement("ap-folder-row")],Z);var rr=Object.defineProperty,or=Object.getOwnPropertyDescriptor,st=(t,e,s,i)=>{for(var a=i>1?void 0:i?or(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&rr(e,s,a),a};let Se=class extends o.LitElement{constructor(){super(...arguments),this.variant="grid",this.gridSize="normal",this.multiSelect=!0,this.folderCount=0}render(){if(this.variant==="grid"){const n=this.gridSize==="large"?"280px":"220px";return o.html`
|
|
5209
5209
|
<div class="grid-skeleton" style="--ap-grid-min-col: ${n}">
|
|
5210
5210
|
${Array.from({length:18},()=>o.html`<div class="card-skel">
|
|
5211
5211
|
<div class="skeleton card-skel-thumb"></div>
|
|
@@ -5376,7 +5376,7 @@
|
|
|
5376
5376
|
@media (prefers-reduced-motion: reduce) {
|
|
5377
5377
|
.skeleton { animation: none; }
|
|
5378
5378
|
}
|
|
5379
|
-
`;st([c.property({reflect:!0})],Se.prototype,"variant",2);st([c.property({type:String})],Se.prototype,"gridSize",2);st([c.property({type:Boolean})],Se.prototype,"multiSelect",2);st([c.property({type:Number})],Se.prototype,"folderCount",2);Se=st([c.customElement("ap-skeleton")],Se);function
|
|
5379
|
+
`;st([c.property({reflect:!0})],Se.prototype,"variant",2);st([c.property({type:String})],Se.prototype,"gridSize",2);st([c.property({type:Boolean})],Se.prototype,"multiSelect",2);st([c.property({type:Number})],Se.prototype,"folderCount",2);Se=st([c.customElement("ap-skeleton")],Se);function Cs(t){var a,r;const e=(a=t.info)==null?void 0:a.playlists;if(!(e!=null&&e.length))return null;const s=(r=e[0])==null?void 0:r.playlists;return s!=null&&s.length&&s[0]||null}var nr=Object.defineProperty,lr=Object.getOwnPropertyDescriptor,I=(t,e,s,i)=>{for(var a=i>1?void 0:i?lr(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&nr(e,s,a),a};let P=class extends o.LitElement{constructor(){super(...arguments),this.asset=null,this.assets=[],this.selectedIds=[],this.containerToken="",this.showMetadata=!0,this.metadataFields=[],this.labels=[],this.regionalFilters={},this.multiSelect=!0,this._isFullscreen=!1,this._fsImageLoaded=!1,this._previewLoading=!1,this._openSections=new Set(["file-info","metadata"]),this._hls=null}connectedCallback(){super.connectedCallback(),this._onFullscreenChange=this._onFullscreenChange.bind(this),this._onKeyDown=this._onKeyDown.bind(this),document.addEventListener("fullscreenchange",this._onFullscreenChange),document.addEventListener("keydown",this._onKeyDown)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("fullscreenchange",this._onFullscreenChange),document.removeEventListener("keydown",this._onKeyDown),this._destroyHls()}_onKeyDown(t){if(t.key!=="ArrowLeft"&&t.key!=="ArrowRight")return;const e=t.composedPath()[0];if(!e)return;const s=e.tagName;s==="INPUT"||s==="TEXTAREA"||s==="SELECT"||e.getAttribute("role")==="radio"||e.getAttribute("role")==="listbox"||e.isContentEditable||(t.preventDefault(),t.key==="ArrowLeft"?this._prev():this._next())}_destroyHls(){this._hls&&(this._hls.destroy(),this._hls=null)}updated(t){if(super.updated(t),t.has("asset")&&(this._destroyHls(),this._previewLoading=!0,this.asset)){const e=Oe(this.asset.type);e==="video"&&this._setupHls(this.asset),e!=="image"&&e!=="video"&&(this._previewLoading=!1)}}async _setupHls(t){var i,a;const e=Cs(t);if(!e||(await this.updateComplete,((i=this.asset)==null?void 0:i.uuid)!==t.uuid))return;const s=this._videoEl;if(s){if(s.canPlayType("application/vnd.apple.mpegurl")){s.src=e;return}try{const{default:r}=await Promise.resolve().then(()=>require("./hls.light-C3NKRmfw.cjs"));if(!r.isSupported()||((a=this.asset)==null?void 0:a.uuid)!==t.uuid||!this.isConnected)return;const n=new r;this._hls=n,n.loadSource(e),n.attachMedia(s),n.on(r.Events.ERROR,(l,d)=>{var h;d.fatal&&(this._destroyHls(),s.src=((h=t.url)==null?void 0:h.cdn)||"")})}catch{}}}_onFullscreenChange(){this._isFullscreen=!!document.fullscreenElement,this._isFullscreen&&(this._fsImageLoaded=!1)}_close(){this.dispatchEvent(new CustomEvent("preview-close",{bubbles:!0,composed:!0}))}_exitFullscreen(){var t;(t=document.exitFullscreen)==null||t.call(document)}_fullscreen(){var e,s,i,a,r,n;if(((s=(e=this.asset)==null?void 0:e.extension)==null?void 0:s.toLowerCase())==="pdf"&&((a=(i=this.asset)==null?void 0:i.url)!=null&&a.cdn)){window.open(this.asset.url.cdn,"_blank","noopener");return}this._fsImageLoaded=!1,(n=(r=this.previewArea)==null?void 0:r.requestFullscreen)==null||n.call(r)}_select(){if(!this.asset)return;if(!this.multiSelect){this.dispatchEvent(new CustomEvent("asset-quick-select",{detail:{asset:this.asset},bubbles:!0,composed:!0}));return}const t=this._getCurrentIndex();this.dispatchEvent(new CustomEvent("asset-select",{detail:{asset:this.asset,index:t,event:new MouseEvent("click",{ctrlKey:!0,metaKey:!0})},bubbles:!0,composed:!0}))}_getCurrentIndex(){return!this.asset||this.assets.length===0?-1:this.assets.findIndex(t=>t.uuid===this.asset.uuid)}_navigateTo(t){this._fsImageLoaded=!1,this.dispatchEvent(new CustomEvent("preview-navigate",{detail:{asset:t},bubbles:!0,composed:!0}))}_supportsFullscreen(t){const e=Oe(t.type);return e==="image"||e==="video"||e==="audio"}_findNavTarget(t,e){const s=e===1?this.assets.length:-1;for(let i=t+e;i!==s;i+=e)if(!this._isFullscreen||this._supportsFullscreen(this.assets[i]))return i;return-1}_prev(){const t=this._getCurrentIndex();if(t<=0)return;const e=this._findNavTarget(t,-1);e>=0&&this._navigateTo(this.assets[e])}_next(){const t=this._getCurrentIndex();if(t<0||t>=this.assets.length-1)return;const e=this._findNavTarget(t,1);e>=0&&this._navigateTo(this.assets[e])}_getFullscreenImageUrl(t){var i,a;const e=(i=t.url)==null?void 0:i.cdn;if(!e)return pt(t)||"";if(((a=t.extension)==null?void 0:a.toLowerCase())==="svg")return e;const s=ze(e,this.containerToken);return Ke(s,{w:String(window.screen.width),dpr:String(window.devicePixelRatio||1),org_if_sml:"1"})}_getBlurDimensions(t){var n,l;const e=(n=t.info)==null?void 0:n.img_w,s=(l=t.info)==null?void 0:l.img_h;if(!e||!s)return{width:"100vw",height:"100vh"};const i=window.innerWidth,a=window.innerHeight,r=Math.min(i/e,a/s,1);return{width:`${Math.round(e*r)}px`,height:`${Math.round(s*r)}px`}}_onFsImageLoad(){this._fsImageLoaded=!0}_getTagEntries(t){if(!t)return[];if(Array.isArray(t))return this._parseTagArray(t);const e=Object.values(t);if(e.length>0&&Array.isArray(e[0])){const s=e.flat(),i=new Set;return s.filter(a=>!a.label||i.has(a.sid)?!1:(i.add(a.sid),!0))}return e.map(s=>({label:s.label,sid:s.sid})).filter(s=>s.label)}_parseTagArray(t){return t.map(e=>{if(typeof e=="string")return{label:e,sid:e};const s=e;return{label:s.label||Object.values(s.names||{})[0]||"",sid:s.sid||""}}).filter(e=>e.label)}_applyTagFilter(t){this.dispatchEvent(new CustomEvent("filter-update",{detail:{key:v.TAGS,values:[t],operator:x.IS},bubbles:!0,composed:!0}))}_applyLabelFilter(t){this.dispatchEvent(new CustomEvent("filter-update",{detail:{key:v.LABELS,values:[t],operator:x.IS},bubbles:!0,composed:!0}))}_toggleSection(t){const e=new Set(this._openSections);e.has(t)?e.delete(t):e.add(t),this._openSections=e}_renderFileInfoSection(t){const e=this._getFileInfoRows(t);if(e.length===0)return o.nothing;const s=this._openSections.has("file-info");return o.html`
|
|
5380
5380
|
<div class="accordion">
|
|
5381
5381
|
<button
|
|
5382
5382
|
class="accordion-trigger"
|
|
@@ -6053,7 +6053,7 @@
|
|
|
6053
6053
|
font-family: inherit;
|
|
6054
6054
|
user-select: none;
|
|
6055
6055
|
}
|
|
6056
|
-
`];Ve([c.property()],ue.prototype,"value",2);Ve([c.property({type:Array})],ue.prototype,"options",2);Ve([c.property({type:Boolean})],ue.prototype,"disabled",2);Ve([c.property({reflect:!0})],ue.prototype,"direction",2);Ve([c.property({reflect:!0})],ue.prototype,"columns",2);ue=Ve([c.customElement("ap-radio-group")],ue);var br=Object.defineProperty,_r=Object.getOwnPropertyDescriptor,
|
|
6056
|
+
`];Ve([c.property()],ue.prototype,"value",2);Ve([c.property({type:Array})],ue.prototype,"options",2);Ve([c.property({type:Boolean})],ue.prototype,"disabled",2);Ve([c.property({reflect:!0})],ue.prototype,"direction",2);Ve([c.property({reflect:!0})],ue.prototype,"columns",2);ue=Ve([c.customElement("ap-radio-group")],ue);var br=Object.defineProperty,_r=Object.getOwnPropertyDescriptor,Es=(t,e,s,i)=>{for(var a=i>1?void 0:i?_r(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&br(e,s,a),a};let ut=class extends o.LitElement{constructor(){super(...arguments),this.size=24}render(){return o.html`<div class="spinner" style="width:${this.size}px;height:${this.size}px"></div>`}};ut.styles=[o.css`
|
|
6057
6057
|
:host {
|
|
6058
6058
|
display: inline-flex;
|
|
6059
6059
|
}
|
|
@@ -6066,7 +6066,7 @@
|
|
|
6066
6066
|
@keyframes spin {
|
|
6067
6067
|
to { transform: rotate(360deg); }
|
|
6068
6068
|
}
|
|
6069
|
-
`];
|
|
6069
|
+
`];Es([c.property({type:Number})],ut.prototype,"size",2);ut=Es([c.customElement("ap-spinner")],ut);var yr=Object.defineProperty,xr=Object.getOwnPropertyDescriptor,xt=(t,e,s,i)=>{for(var a=i>1?void 0:i?xr(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&yr(e,s,a),a};let Re=class extends o.LitElement{constructor(){super(...arguments),this.folders=[],this.loading=!1,this._mode="recursive"}_handleConfirm(){this.dispatchEvent(new CustomEvent("folder-resolve-confirm",{detail:{mode:this._mode},bubbles:!0,composed:!0}))}_handleCancel(){this.dispatchEvent(new CustomEvent("folder-resolve-cancel",{bubbles:!0,composed:!0}))}_handleModeChange(t){this._mode=t.detail.value}render(){const t=this.folders.length;return o.html`
|
|
6070
6070
|
<div class="backdrop" @click=${e=>{e.target===e.currentTarget&&this._handleCancel()}}>
|
|
6071
6071
|
<div class="dialog">
|
|
6072
6072
|
<div class="title">Add folder contents</div>
|
|
@@ -6230,7 +6230,7 @@
|
|
|
6230
6230
|
.label[hidden] {
|
|
6231
6231
|
display: none;
|
|
6232
6232
|
}
|
|
6233
|
-
`];wt([c.property({type:Boolean,reflect:!0})],je.prototype,"checked",2);wt([c.property({type:Boolean,reflect:!0})],je.prototype,"indeterminate",2);wt([c.property({type:Boolean,reflect:!0})],je.prototype,"disabled",2);je=wt([c.customElement("ap-checkbox")],je);var kr=Object.defineProperty,Sr=Object.getOwnPropertyDescriptor,
|
|
6233
|
+
`];wt([c.property({type:Boolean,reflect:!0})],je.prototype,"checked",2);wt([c.property({type:Boolean,reflect:!0})],je.prototype,"indeterminate",2);wt([c.property({type:Boolean,reflect:!0})],je.prototype,"disabled",2);je=wt([c.customElement("ap-checkbox")],je);var kr=Object.defineProperty,Sr=Object.getOwnPropertyDescriptor,Fs=(t,e,s,i)=>{for(var a=i>1?void 0:i?Sr(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&kr(e,s,a),a};let gt=class extends o.LitElement{constructor(){super(...arguments),this.open=!1,this._handleOutsideClick=t=>{this.open&&!t.composedPath().includes(this)&&(this.open=!1)}}render(){return o.html`
|
|
6234
6234
|
<slot name="trigger" @click=${()=>this.open=!this.open}></slot>
|
|
6235
6235
|
<div class="content ${this.open?"open":""}">
|
|
6236
6236
|
<slot></slot>
|
|
@@ -6256,7 +6256,7 @@
|
|
|
6256
6256
|
.content.open {
|
|
6257
6257
|
display: block;
|
|
6258
6258
|
}
|
|
6259
|
-
`];
|
|
6259
|
+
`];Fs([c.state()],gt.prototype,"open",2);gt=Fs([c.customElement("ap-popover")],gt);var Cr=Object.defineProperty,Er=Object.getOwnPropertyDescriptor,U=(t,e,s,i)=>{for(var a=i>1?void 0:i?Er(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&Cr(e,s,a),a};let z=class extends o.LitElement{constructor(){super(...arguments),this.value="",this.label="",this.variant="default",this.options=[],this._open=!1,this._focusedIndex=-1,this._menuPosition="below",this._menuAlign="align-left",this._menuTop=0,this._menuBottom=0,this._menuLeft=0,this._menuRight=0,this._handleOutsideClick=t=>{t.composedPath().includes(this)||(this._open=!1,document.removeEventListener("click",this._handleOutsideClick))}}close(){this._open=!1}render(){const t=this.options.find(s=>s.value===this.value),e="ap-dropdown-menu";return o.html`
|
|
6260
6260
|
<button
|
|
6261
6261
|
class="trigger"
|
|
6262
6262
|
role="combobox"
|
|
@@ -6375,7 +6375,7 @@
|
|
|
6375
6375
|
.option[aria-selected="true"] ap-icon {
|
|
6376
6376
|
color: var(--ap-primary, oklch(0.578 0.198 268.129));
|
|
6377
6377
|
}
|
|
6378
|
-
`];U([c.property()],z.prototype,"value",2);U([c.property()],z.prototype,"label",2);U([c.property({reflect:!0})],z.prototype,"variant",2);U([c.property({type:Array})],z.prototype,"options",2);U([c.state()],z.prototype,"_open",2);U([c.state()],z.prototype,"_focusedIndex",2);U([c.state()],z.prototype,"_menuPosition",2);U([c.state()],z.prototype,"_menuAlign",2);U([c.state()],z.prototype,"_menuTop",2);U([c.state()],z.prototype,"_menuBottom",2);U([c.state()],z.prototype,"_menuLeft",2);U([c.state()],z.prototype,"_menuRight",2);z=U([c.customElement("ap-dropdown")],z);var Fr=Object.defineProperty,Ar=Object.getOwnPropertyDescriptor,
|
|
6378
|
+
`];U([c.property()],z.prototype,"value",2);U([c.property()],z.prototype,"label",2);U([c.property({reflect:!0})],z.prototype,"variant",2);U([c.property({type:Array})],z.prototype,"options",2);U([c.state()],z.prototype,"_open",2);U([c.state()],z.prototype,"_focusedIndex",2);U([c.state()],z.prototype,"_menuPosition",2);U([c.state()],z.prototype,"_menuAlign",2);U([c.state()],z.prototype,"_menuTop",2);U([c.state()],z.prototype,"_menuBottom",2);U([c.state()],z.prototype,"_menuLeft",2);U([c.state()],z.prototype,"_menuRight",2);z=U([c.customElement("ap-dropdown")],z);var Fr=Object.defineProperty,Ar=Object.getOwnPropertyDescriptor,As=(t,e,s,i)=>{for(var a=i>1?void 0:i?Ar(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&Fr(e,s,a),a};let ft=class extends o.LitElement{constructor(){super(...arguments),this.variant="default"}render(){return o.html`<span class="badge"><slot></slot></span>`}};ft.styles=[o.css`
|
|
6379
6379
|
:host {
|
|
6380
6380
|
display: inline-flex;
|
|
6381
6381
|
}
|
|
@@ -6394,7 +6394,7 @@
|
|
|
6394
6394
|
background: var(--ap-primary-10, oklch(0.578 0.198 268.129 / 0.1));
|
|
6395
6395
|
color: var(--ap-primary, oklch(0.578 0.198 268.129));
|
|
6396
6396
|
}
|
|
6397
|
-
`];
|
|
6397
|
+
`];As([c.property({reflect:!0})],ft.prototype,"variant",2);ft=As([c.customElement("ap-badge")],ft);var Tr=Object.defineProperty,Mr=Object.getOwnPropertyDescriptor,Ts=(t,e,s,i)=>{for(var a=i>1?void 0:i?Mr(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&Tr(e,s,a),a};let mt=class extends o.LitElement{constructor(){super(...arguments),this.text=""}render(){return o.html`
|
|
6398
6398
|
<slot></slot>
|
|
6399
6399
|
<div class="tip">${this.text}</div>
|
|
6400
6400
|
`}};mt.styles=[o.css`
|
|
@@ -6420,7 +6420,7 @@
|
|
|
6420
6420
|
:host(:hover) .tip {
|
|
6421
6421
|
display: block;
|
|
6422
6422
|
}
|
|
6423
|
-
`];As([c.property()],mt.prototype,"text",2);mt=As([c.customElement("ap-tooltip")],mt);var Lr=Object.defineProperty,$t=(t,e,s,i)=>{for(var a=void 0,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=n(e,s,a)||a);return a&&Lr(e,s,a),a};const Ht=class Ht extends o.LitElement{constructor(){super(),this._initFailed=!1,this._loadId=0,this._loadMoreId=0,this._loadDataTimer=null,this._pendingFilter=null,this._pendingMetadataField=null,this._uploaderEl=null,this._uploaderImportPromise=null,this._dragCounter=0,this._isDragOver=!1,this._isUploaderOpen=!1,this._folderResolveOpen=!1,this._onDragEnter=e=>{var s;!((s=this.config)!=null&&s.uploader)||!this._hasFileTransfer(e)||(e.preventDefault(),this._dragCounter++,this._dragCounter===1&&(this._isDragOver=!0))},this._onDragOver=e=>{var s;!((s=this.config)!=null&&s.uploader)||!this._hasFileTransfer(e)||(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"))},this._onDragLeave=e=>{var s;!((s=this.config)!=null&&s.uploader)||!this._hasFileTransfer(e)||(e.preventDefault(),this._dragCounter--,this._dragCounter<=0&&(this._dragCounter=0,this._isDragOver=!1))},this._onDrop=e=>{var i,a;if(!((i=this.config)!=null&&i.uploader)||!this._hasFileTransfer(e))return;e.preventDefault(),this._dragCounter=0,this._isDragOver=!1;const s=Array.from(((a=e.dataTransfer)==null?void 0:a.files)??[]);s.length>0&&this._openUploader(s)},this.store=Rs(),this.storeCtrl=new js(this,this.store),this.selectionCtrl=new Bs(this,this.store),this.infiniteScrollCtrl=new Us(this,()=>this._loadMore()),this.marqueeCtrl=new Vs(this,this.store)}get _isInline(){var e;return((e=this.config)==null?void 0:e.displayMode)==="inline"}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback(),this._uploaderEl&&(this._uploaderEl.remove(),this._uploaderEl=null),this._uploaderImportPromise=null,this._dragCounter=0,this._isDragOver=!1,this._isUploaderOpen=!1}updated(e){super.updated(e),e.has("config")&&this.config&&this._initConfig(this.config);const s=this.renderRoot.querySelector("#sentinel");if(s&&s!==this._lastSentinel){this._lastSentinel=s;const a=this.renderRoot.querySelector(".main-content");this.infiniteScrollCtrl.observe(s,a)}const i=this.renderRoot.querySelector(".main-content");i&&i!==this._lastMarqueeContainer&&(this._lastMarqueeContainer=i,this.marqueeCtrl.attach(i))}_initConfig(e){const s={folderSelection:!0,...e};this._initFailed=!1,this._initPromise=this._doInit(s).catch(()=>{this._initFailed=!0}),this.toggleAttribute("inline",s.displayMode==="inline"),s.displayMode==="inline"&&!this.store.getState().isOpen&&this.open()}async _doInit(e){const s=Di(),i=s.sortBy??e.defaultSortBy??"created_at",a=s.sortDirection??e.defaultSortDirection??"desc";this.store.setState({config:e,projectToken:e.auth.projectToken,viewMode:e.rememberLastView&&Ri()||e.defaultViewMode||"grid",sortBy:i,sortDirection:a}),this.apiClient=new qs(e.auth,e.apiBase);try{if(e.auth.mode==="securityTemplate"){const g=await Ws(this.apiClient);this.apiClient.setSassKey(g),this.store.setState({sassKey:g})}const[r,n,l,d]=await Promise.allSettled([fi(this.apiClient),Ys(this.apiClient),Xs(this.apiClient),ui(this.apiClient)]);if(r.status==="fulfilled"){const{fields:g,regionalVariantGroups:m,regionalFilters:_,brandColor:y}=r.value;this.store.setState({metadataFields:g,regionalVariantGroups:m,regionalFilters:_,...y?{brandColor:y}:{}})}n.status==="fulfilled"&&this.store.setState({labels:n.value.labels||[]}),l.status==="fulfilled"&&this.store.setState({tags:l.value}),d.status==="fulfilled"&&this.store.setState({fileTypes:d.value});const{pinnedFilters:h,pinnedMetadata:u}=Oi(e.auth.projectToken??null),f=this.store.getState().filters;this.store.setState({filters:{...f,pinned:h,visible:[...h],metadata:{...f.metadata,pinned:u,visible:[...u]}}});const p=e.brandColor||this.store.getState().brandColor;p&&(this.store.setState({brandColor:p}),qi(this,p))}catch(r){throw this.dispatchEvent(new CustomEvent("ap-error",{detail:{error:r,context:"init"},bubbles:!0,composed:!0})),r}}_ensureUploaderImport(){return this._uploaderImportPromise?this._uploaderImportPromise:(this._uploaderImportPromise=import("@scaleflex/uploader/define").then(()=>{},e=>{throw this._uploaderImportPromise=null,e}),this._uploaderImportPromise)}_buildUploaderConfig(){const e=this.config,s=e.uploader,i=this.store.getState();let a;return e.auth.mode==="securityTemplate"?a={mode:"security-template",container:e.auth.projectToken,securityTemplateId:e.auth.securityTemplateKey}:a={mode:"sass-key",container:e.auth.projectToken,sassKey:e.auth.sassKey},{auth:a,targetFolder:i.currentFolderPath||"/",mode:"inline",restrictions:s.restrictions,concurrency:s.concurrency,autoProceed:s.autoProceed,showFillMetadata:s.showFillMetadata,connectors:s.connectors,sourcesLayout:s.sourcesLayout,headerButton:s.headerButton??"back",clearOnClose:s.clearOnClose,clearOnComplete:s.clearOnComplete,rejectedFileAutoRemoveDelay:s.rejectedFileAutoRemoveDelay}}async _openUploader(e){var i;if(!((i=this.config)!=null&&i.uploader)||this._isUploaderOpen)return;try{await this._ensureUploaderImport()}catch(a){this.dispatchEvent(new CustomEvent("ap-error",{detail:{error:a instanceof Error?a:new Error(String(a)),context:"uploader-load"},bubbles:!0,composed:!0}));return}this._uploaderEl=document.createElement("sfx-uploader");const s=this._uploaderEl;s.addEventListener("sfx-all-complete",()=>{this.store.getState().isOpen&&this._loadData()}),s.addEventListener("sfx-complete-action",()=>{this._closeUploader()}),s.addEventListener("sfx-cancel",()=>{this._closeUploader()}),this._isUploaderOpen=!0,await this.updateComplete,s.config=this._buildUploaderConfig(),await s.updateComplete,e!=null&&e.length&&s.addFiles(e)}_closeUploader(){this._isUploaderOpen=!1,this._uploaderEl=null}_handleUploadClick(){this._openUploader()}_hasFileTransfer(e){var s,i;return!!((i=(s=e.dataTransfer)==null?void 0:s.types)!=null&&i.includes("Files"))}async open(){var u,f,p,g,m,_,y,S,w,E;const e=this.store.getState(),s=Ge((u=this.config)==null?void 0:u.forcedFilters),i=new Set(Object.keys(s)),a={},r=Ge((f=this.config)==null?void 0:f.defaultFilters);for(const[M,$]of Object.entries(r))i.has(M)||(a[M]=$);const n=Object.keys(a),l=((p=this.config)==null?void 0:p.tabs)??["assets","folders"],d=(g=this.config)!=null&&g.rememberLastTab?Ni():null,h=(d&&l.includes(d)?d:null)??((m=this.config)!=null&&m.defaultTab&&l.includes(this.config.defaultTab)?this.config.defaultTab:null)??l[0]??"assets";this.store.setState({isOpen:!0,activeTab:h,searchQuery:"",filters:{metadata:{pinned:e.filters.metadata.pinned,visible:[...e.filters.metadata.pinned],applied:{}},pinned:e.filters.pinned,visible:[...new Set([...e.filters.pinned,...n])],applied:a},offset:0,assets:[],folders:[],currentFolder:null,currentFolderPath:h==="folders"&&((_=this.config)==null?void 0:_.rememberLastFolder)&&is()||((y=this.config)==null?void 0:y.rootFolderPath)||"/",breadcrumb:this._buildBreadcrumbFromPath(h==="folders"&&((S=this.config)==null?void 0:S.rememberLastFolder)&&is()||((w=this.config)==null?void 0:w.rootFolderPath)||"/",((E=this.config)==null?void 0:E.rootFolderPath)||"/"),selectedAssets:new Map,selectedFolders:new Map,isResolvingFolders:!1,folderPreviews:{},isPreviewOpen:!1,previewAsset:null,isLoading:!0,isSelectingAll:!1}),this._dragCounter=0,this._isDragOver=!1,this.dispatchEvent(new CustomEvent("ap-open",{detail:{timestamp:Date.now()},bubbles:!0,composed:!0})),await this.updateComplete,!this._initPromise&&this.config&&this._initConfig(this.config),!(this._initPromise&&(await this._initPromise,this._initFailed))&&this._loadData()}close(){this.store.setState({isOpen:!1}),this._dragCounter=0,this._isDragOver=!1,this._isUploaderOpen=!1,this._folderResolveOpen=!1}_scrollToTop(){var e;(e=this.renderRoot.querySelector(".main-content"))==null||e.scrollTo({top:0})}async _loadData(){var i,a,r,n,l,d,h,u,f,p,g,m,_,y;if(!this.apiClient)return;const e=++this._loadId,s=this.store.getState();this._scrollToTop(),this.store.setState({isLoading:!0});try{const S=s.activeTab;if(S==="assets"){const w=this._buildSearchNotation(),E=s.currentFolderPath||"/",M=qe(this.apiClient,{folder:E,offset:0,limit:s.limit,sort_by:s.sortBy,sort_direction:s.sortDirection,search:s.searchQuery||void 0,q:w||void 0,recursive:1}),$=Xt(this.apiClient,{folder:E,q:w||void 0,search:s.searchQuery||void 0,recursive:1}).catch(()=>null),[C,O]=await Promise.all([M,$]);if(e!==this._loadId)return;const V=((i=C.files)==null?void 0:i.length)??0,q=V>=s.limit,Te=((a=O==null?void 0:O.stats)==null?void 0:a.approx_files_count)??((r=O==null?void 0:O.info)==null?void 0:r.total_files_count)??((n=C.info)==null?void 0:n.total_files_count)??((d=(l=C.base)==null?void 0:l.count)==null?void 0:d.files_recursive)??((u=(h=C.base)==null?void 0:h.count)==null?void 0:u.files_direct)??V;this.store.setState({assets:C.files||[],folders:[],totalCount:Te,totalFolderCount:0,offset:0,hasMore:q,isLoading:!1})}else if(S==="folders"){const w=this._buildSearchNotation(),E=s.currentFolderPath||"/",[M,$,C]=await Promise.all([Gs(this.apiClient,{folderPath:s.currentFolderPath,q:s.searchQuery||void 0,recursive:s.searchQuery?1:0,sort_by:s.sortBy,sort_direction:s.sortDirection}),qe(this.apiClient,{folder:E,offset:0,limit:s.limit,sort_by:s.sortBy,sort_direction:s.sortDirection,search:s.searchQuery||void 0,q:w||void 0,recursive:0}),Xt(this.apiClient,{folder:E,q:w||void 0,search:s.searchQuery||void 0,recursive:0}).catch(()=>null)]);if(e!==this._loadId)return;const O=M.folders||[];let V={};if(O.length>0)try{V=await Ks(this.apiClient,O.map(me=>me.uuid))}catch{}if(e!==this._loadId)return;const q=((f=$.files)==null?void 0:f.length)??0,Te=q>=s.limit,it=((p=C==null?void 0:C.stats)==null?void 0:p.approx_files_count)??((g=C==null?void 0:C.info)==null?void 0:g.total_files_count)??((m=$.info)==null?void 0:m.total_files_count)??((y=(_=$.base)==null?void 0:_.count)==null?void 0:y.files_direct)??q;this.store.setState({assets:$.files||[],folders:O,folderPreviews:V,totalCount:it,totalFolderCount:M.total??O.length,offset:0,hasMore:Te,isLoading:!1})}}catch(S){if(e!==this._loadId)return;this.store.setState({isLoading:!1}),this.dispatchEvent(new CustomEvent("ap-error",{detail:{error:S,context:"loadData"},bubbles:!0,composed:!0}))}}async _loadMore(){const e=this.store.getState();if(e.isLoading||!e.hasMore||!this.apiClient)return;const s=++this._loadMoreId,i=e.offset+e.limit;this.store.setState({isLoading:!0});try{const a=this._buildSearchNotation(),r=await qe(this.apiClient,{folder:e.currentFolderPath||"/",offset:i,limit:e.limit,sort_by:e.sortBy,sort_direction:e.sortDirection,search:e.searchQuery||void 0,q:a||void 0,recursive:e.activeTab==="folders"?0:1});if(s!==this._loadMoreId)return;const n=this.store.getState().assets,l=r.files||[],d=l.length>=e.limit,h=[...n,...l];this.store.setState({assets:h,offset:i,hasMore:d,isLoading:!1})}catch{if(s!==this._loadMoreId)return;this.store.setState({isLoading:!1})}}_debouncedLoadData(e=120){this._loadDataTimer&&clearTimeout(this._loadDataTimer),this._loadDataTimer=setTimeout(()=>{this._loadDataTimer=null,this._loadData()},e)}_handleCancel(e){var s,i;this.close(),(i=(s=this.config)==null?void 0:s.onCancel)==null||i.call(s),this.dispatchEvent(new CustomEvent("ap-cancel",{detail:{reason:e},bubbles:!0,composed:!0}))}_handleSearchChange(e){this.store.setState({searchQuery:e.detail.value,offset:0,assets:[],folders:[]}),this.selectionCtrl.resetRange(),this._loadData()}_handleViewChange(e){var i;const s=e.detail.mode;this.store.setState({viewMode:s}),(i=this.config)!=null&&i.rememberLastView&&zi(s),this._scrollToTop()}_handleRegionalChange(e){const{groupUuid:s,value:i}=e.detail,a=this.store.getState().regionalFilters;this.store.setState({regionalFilters:{...a,[s]:i}})}_handleSortChange(e){const s=e.detail.value,i=this.store.getState();this.store.setState({sortBy:s,offset:0,assets:[],folders:[]}),ts(s,i.sortDirection),this.selectionCtrl.resetRange(),this._loadData()}_handleSortDirectionChange(e){const s=e.detail.value,i=this.store.getState();this.store.setState({sortDirection:s,offset:0,assets:[],folders:[]}),ts(i.sortBy,s),this.selectionCtrl.resetRange(),this._loadData()}_handleTabChange(e){var i,a;const s=e.detail.tab;(i=this.config)!=null&&i.rememberLastTab&&ji(s),this.store.setState({activeTab:s,currentFolder:null,currentFolderPath:((a=this.config)==null?void 0:a.rootFolderPath)??"/",breadcrumb:[],offset:0,assets:[],folders:[]}),this.selectionCtrl.resetRange(),this._loadData()}_handleAssetSelect(e){this.selectionCtrl.handleSelect(e.detail.asset,e.detail.index,e.detail.event)}_handleFolderSelect(e){this.selectionCtrl.handleFolderSelect(e.detail.folder,e.detail.index,e.detail.event)}_handleAssetPreview(e){this.store.setState({previewAsset:e.detail.asset,isPreviewOpen:!0})}_handleQuickSelect(e){var i,a;const s=e.detail.asset;(a=(i=this.config)==null?void 0:i.onSelect)==null||a.call(i,[s]),this.dispatchEvent(new CustomEvent("ap-select",{detail:{assets:[s]},bubbles:!0,composed:!0})),this._isInline||this.close()}_handleFolderOpen(e){var r;const s=e.detail.folder,i=this.store.getState(),a=s.path||`${i.currentFolderPath}${s.name}/`;(r=this.config)!=null&&r.rememberLastFolder&&ss(a),this.store.setState({currentFolder:s.uuid,currentFolderPath:a,breadcrumb:[...i.breadcrumb,{uuid:s.uuid,name:s.name,path:a}],searchQuery:"",offset:0,assets:[],folders:[]}),this.selectionCtrl.resetRange(),this._loadData()}_handleBreadcrumbNavigate(e){var l,d;const s=e.detail.uuid,i=this.store.getState(),a=s?i.breadcrumb.findIndex(h=>h.uuid===s):-1,r=s?i.breadcrumb.slice(0,a+1):[],n=r.length>0?r[r.length-1].path:((l=this.config)==null?void 0:l.rootFolderPath)||"/";(d=this.config)!=null&&d.rememberLastFolder&&ss(n),this.store.setState({currentFolder:s||null,currentFolderPath:n,breadcrumb:r,offset:0,assets:[],folders:[]}),this.selectionCtrl.resetRange(),this._loadData()}_buildBreadcrumbFromPath(e,s){if(!e||e===s||e==="/")return[];const a=(e.startsWith(s)?e.slice(s.length):e.replace(/^\//,"")).split("/").filter(Boolean),r=[];let n=s.endsWith("/")?s:s+"/";for(const l of a)n+=l+"/",r.push({uuid:n,name:l,path:n});return r}_handlePreviewClose(){this.store.setState({isPreviewOpen:!1,previewAsset:null})}_handlePreviewNavigate(e){this.store.setState({previewAsset:e.detail.asset})}_handleSelectionConfirm(e){var a,r,n,l,d,h;const s=e.detail.assets,i=e.detail.folders||[];if(i.length>0&&((a=this.config)==null?void 0:a.folderSelection)!==!1){if(((r=this.config)==null?void 0:r.folderSelectionMode)==="assets"){this._folderResolveOpen=!0;return}(l=(n=this.config)==null?void 0:n.onSelect)==null||l.call(n,s,i),this.dispatchEvent(new CustomEvent("ap-select",{detail:{assets:s,folders:i},bubbles:!0,composed:!0})),this._isInline||this.close();return}(h=(d=this.config)==null?void 0:d.onSelect)==null||h.call(d,s),this.dispatchEvent(new CustomEvent("ap-select",{detail:{assets:s},bubbles:!0,composed:!0})),this._isInline||this.close()}async _handleFolderResolveConfirm(e){var r,n,l;const s=e.detail.mode,i=this.selectionCtrl.getSelectedFolders(),a=this.selectionCtrl.getSelectedAssets();this.store.setState({isResolvingFolders:!0});try{const d=await Promise.all(i.map(m=>qe(this.apiClient,{folder:m.path,recursive:s==="recursive"?1:0,limit:1e4}))),h=[];for(const m of d)h.push(...m.files);const u=[...a],f=new Set(u.map(m=>m.uuid));for(const m of h)f.has(m.uuid)||(u.push(m),f.add(m.uuid));const p=(r=this.config)==null?void 0:r.maxSelections,g=p?u.slice(0,p):u;(l=(n=this.config)==null?void 0:n.onSelect)==null||l.call(n,g),this.dispatchEvent(new CustomEvent("ap-select",{detail:{assets:g},bubbles:!0,composed:!0})),this._folderResolveOpen=!1,this.store.setState({isResolvingFolders:!1}),this._isInline||this.close()}catch(d){this.store.setState({isResolvingFolders:!1}),this.dispatchEvent(new CustomEvent("ap-error",{detail:{error:d,context:"folderResolve"},bubbles:!0,composed:!0}))}}_handleFolderResolveCancel(){this._folderResolveOpen=!1}async _handleSelectAll(e){var l,d,h;const s=this.store.getState();if(s.isSelectingAll||!this.apiClient||!(((l=s.config)==null?void 0:l.multiSelect)??!0))return;const a=((d=e==null?void 0:e.detail)==null?void 0:d.scope)??"all",r=a!=="assets"&&((h=this.config)==null?void 0:h.folderSelection)!==!1&&s.folders.length>0;if(!(a!=="folders")){r&&this.selectionCtrl.selectAllFolders(s.folders);return}if(s.assets.length>=s.totalCount){r&&this.selectionCtrl.selectAllFolders(s.folders),this.selectionCtrl.selectAll(s.assets);return}this.store.setState({isSelectingAll:!0});try{const u=this._buildSearchNotation(),f=s.currentFolderPath||"/",p=s.limit,g=s.assets,m=s.totalCount,_=s.activeTab==="folders"?0:1,y=[];for(let C=g.length;C<m;C+=p)y.push(C);const S=4,w=[];for(let C=0;C<y.length;C+=S){const O=y.slice(C,C+S),V=await Promise.all(O.map(q=>qe(this.apiClient,{folder:f,offset:q,limit:p,sort_by:s.sortBy,sort_direction:s.sortDirection,search:s.searchQuery||void 0,q:u||void 0,recursive:_})));for(const q of V)q.files&&w.push(...q.files)}const E=new Set(g.map(C=>C.uuid)),M=w.filter(C=>E.has(C.uuid)?!1:(E.add(C.uuid),!0)),$=[...g,...M];this.store.setState({assets:$,offset:Math.max(0,$.length-p),hasMore:!1,isSelectingAll:!1}),r&&this.selectionCtrl.selectAllFolders(s.folders),this.selectionCtrl.selectAll($)}catch(u){this.store.setState({isSelectingAll:!1}),this.dispatchEvent(new CustomEvent("ap-error",{detail:{error:u,context:"selectAll"},bubbles:!0,composed:!0}))}}_handleSelectionClear(){this.selectionCtrl.clearSelection()}_handleSelectionDeselect(e){const s=new Map(this.store.getState().selectedAssets);s.delete(e.detail.uuid),this.store.setState({selectedAssets:s})}_isDateFilterKey(e){return e===v.DATE||e===v.LICENSE_EXPIRY||e===R.DUE_DATE}_handleFilterUpdate(e){const{key:s,values:i,operator:a}=e.detail,n={...this.store.getState().filters};let l=i===""||i===null||i===void 0||Array.isArray(i)&&i.length===0||typeof i=="object"&&!Array.isArray(i)&&Object.values(i).every(d=>d==null||d===""||Array.isArray(d)&&d.length===0);if(!l&&this._isDateFilterKey(s)&&typeof i=="object"&&!Array.isArray(i)){const{kind:d,preset:h,from:u,to:f}=i;l=!d&&!h&&!u&&!f}if(l){const d={...n.applied};delete d[s],n.applied=d,n.pinned.includes(s)||(n.visible=n.visible.filter(h=>h!==s))}else{const d={...n.applied};this._isDateFilterKey(s)&&typeof i=="object"&&!Array.isArray(i)?d[s]={type:"date",field:i.field||"created",kind:i.kind||null,preset:i.preset||null,from:i.from||null,to:i.to||null}:s===v.IMAGE&&typeof i=="object"&&!Array.isArray(i)?d[s]=i:d[s]={type:"string",values:Array.isArray(i)?i:[i],operator:a||":"},n.applied=d,n.visible.includes(s)||(n.visible=[...n.visible,s])}if(this.store.setState({filters:n,offset:0,assets:[],folders:[],isLoading:!0}),this.selectionCtrl.resetRange(),this._debouncedLoadData(),this._pendingFilter===s){this._pendingFilter=null;const d=this.renderRoot.querySelector("ap-filters-bar");d&&(d.pendingFilter=null)}}_handleFilterOpen(e){const s=e.detail.key,i=e.detail.chipRect,a=this.renderRoot.querySelector("ap-content-toolbar");let r,n;if(i){const l=this.renderRoot.querySelector(".toolbar-filters-wrapper");if(l){const d=l.getBoundingClientRect();r=i.left-d.left,n=i.bottom-d.top}}a==null||a.openFilterPanel(s,!0,r,n)}_handleMetadataFilterOpen(e){const{fieldKey:s,chipRect:i}=e.detail,a=this.renderRoot.querySelector("ap-content-toolbar");let r,n;if(i){const l=this.renderRoot.querySelector(".toolbar-filters-wrapper");if(l){const d=l.getBoundingClientRect();r=i.left-d.left,n=i.bottom-d.top}}a==null||a.openMetadataFieldPanel(s,!0,r,n)}_handleFilterPanelChange(e){const s=this.renderRoot.querySelector("ap-filters-bar");s&&(s.activeFilter=e.detail.key,s.activeMetadataField=e.detail.metadataFieldKey||null),!e.detail.key&&!e.detail.metadataFieldKey&&(this._pendingFilter||this._pendingMetadataField)&&(this._pendingFilter=null,this._pendingMetadataField=null,s&&(s.pendingFilter=null,s.pendingMetadataField=null))}async _handleFilterPending(e){var p,g,m;const{key:s,metadataFieldKey:i}=e.detail,a=this.renderRoot.querySelector("ap-filters-bar"),r=this.renderRoot.querySelector("ap-content-toolbar");if(!a||!r)return;i?(this._pendingMetadataField=i,a.pendingMetadataField=i):s&&(this._pendingFilter=s,a.pendingFilter=s),await a.updateComplete;let n=a.renderRoot.querySelector(".chip.pending");if(!n){const _=a.renderRoot.querySelectorAll(".chip.pinned-empty"),y=i?(p=a._getMetadataLabel)==null?void 0:p.call(a,i):void 0;for(const S of _){const w=(m=(g=S.querySelector(".chip-label"))==null?void 0:g.textContent)==null?void 0:m.trim();if(i&&w===y){n=S;break}if(s&&w===(Le[s]||s)){n=S;break}}}if(!n)return;const l=n.getBoundingClientRect(),d=this.renderRoot.querySelector(".toolbar-filters-wrapper"),h=d==null?void 0:d.getBoundingClientRect(),u=h?l.left-h.left:l.left,f=h?l.bottom-h.top:void 0;i?r.openMetadataFieldPanel(i,!0,u,f):s&&r.openFilterPanel(s,!0,u,f)}_handleFilterRemove(e){var n;const s=e.detail.key;if(s in(((n=this.config)==null?void 0:n.forcedFilters)??{}))return;const a={...this.store.getState().filters},r={...a.applied};delete r[s],a.applied=r,a.pinned.includes(s)||(a.visible=a.visible.filter(l=>l!==s)),this.store.setState({filters:a,offset:0,assets:[],folders:[],isLoading:!0}),this.selectionCtrl.resetRange(),this._debouncedLoadData()}_handleMetadataFilterChange(e){const{fieldKey:s,operator:i,values:a,metadataType:r}=e.detail,l={...this.store.getState().filters},d={...l.metadata},h={...d.applied};if(!a||Array.isArray(a)&&a.length===0?(delete h[s],d.applied=h,d.pinned.includes(s)||(d.visible=d.visible.filter(f=>f!==s))):(h[s]={type:"string",values:Array.isArray(a)?a:[a],operator:i||":",metadataType:r},d.applied=h,d.visible.includes(s)||(d.visible=[...d.visible,s])),l.metadata=d,this.store.setState({filters:l,offset:0,assets:[],folders:[],isLoading:!0}),this.selectionCtrl.resetRange(),this._debouncedLoadData(),this._pendingMetadataField===s){this._pendingMetadataField=null;const f=this.renderRoot.querySelector("ap-filters-bar");f&&(f.pendingMetadataField=null)}}_handleMetadataFieldToggle(e){const{fieldKey:s,visible:i}=e.detail,r={...this.store.getState().filters},n={...r.metadata};i?n.visible.includes(s)||(n.visible=[...n.visible,s]):n.visible=n.visible.filter(l=>l!==s),r.metadata=n,this.store.setState({filters:r})}_handleMetadataFilterRemove(e){const{fieldKey:s}=e.detail,a={...this.store.getState().filters},r={...a.metadata},n={...r.applied};delete n[s],r.applied=n,r.pinned.includes(s)||(r.visible=r.visible.filter(l=>l!==s)),a.metadata=r,this.store.setState({filters:a,offset:0,assets:[],folders:[],isLoading:!0}),this.selectionCtrl.resetRange(),this._debouncedLoadData()}_handleFilterPin(e){var l,d;const{key:s,pinned:i}=e.detail,r={...this.store.getState().filters};i?r.pinned.includes(s)||(r.pinned=[...r.pinned,s]):(r.pinned=r.pinned.filter(h=>h!==s),s in r.applied||(r.visible=r.visible.filter(h=>h!==s))),this.store.setState({filters:r});const n=((d=(l=this.store.getState().config)==null?void 0:l.auth)==null?void 0:d.projectToken)??null;Pi(n,r.pinned)}_handleMetadataPin(e){var d,h;const{fieldKey:s,pinned:i}=e.detail,r={...this.store.getState().filters},n={...r.metadata};i?n.pinned.includes(s)||(n.pinned=[...n.pinned,s]):(n.pinned=n.pinned.filter(u=>u!==s),s in n.applied||(n.visible=n.visible.filter(u=>u!==s))),r.metadata=n,this.store.setState({filters:r});const l=((h=(d=this.store.getState().config)==null?void 0:d.auth)==null?void 0:h.projectToken)??null;Ii(l,n.pinned)}_handleFiltersClearAll(){const e=this.store.getState();this.store.setState({filters:{...e.filters,applied:{},visible:[...e.filters.pinned],metadata:{...e.filters.metadata,applied:{},visible:[...e.filters.metadata.pinned]}},offset:0,assets:[],folders:[],isLoading:!0});const s=this.renderRoot.querySelector("ap-filters-bar");s&&(s.activeFilter=null),this.selectionCtrl.resetRange(),this._debouncedLoadData()}_handleFilterDeactivate(e){const s=e.detail.key,a={...this.store.getState().filters};a.visible=a.visible.filter(r=>r!==s),this.store.setState({filters:a})}_handleMetadataFieldDeactivate(e){const{fieldKey:s}=e.detail,a={...this.store.getState().filters},r={...a.metadata};r.visible=r.visible.filter(n=>n!==s),a.metadata=r,this.store.setState({filters:a})}_handleFiltersSet(e){var h;const{applied:s,metadata:i}=e.detail,r={...this.store.getState().filters},n=new Set(Object.keys(((h=this.config)==null?void 0:h.forcedFilters)??{})),l={...s};for(const u of n)delete l[u];r.applied=l;const d=Object.keys(s);if(r.visible=[...new Set([...r.pinned,...d])],i){const u={...r.metadata};u.applied=i.applied;const f=Object.keys(i.applied);u.visible=[...new Set([...u.pinned,...f])],r.metadata=u}this.store.setState({filters:r,offset:0,assets:[],folders:[],isLoading:!0}),this.selectionCtrl.resetRange(),this._debouncedLoadData()}_getSortOptions(){const e=this.storeCtrl.state;return e.searchQuery?Hi:e.activeTab==="folders"?Gi:zt}_buildSearchNotation(){var a;const e=this.store.getState(),s={...Ge((a=this.config)==null?void 0:a.forcedFilters),...e.filters.applied};return bi(s,e.filters.metadata.applied).join(" ")}render(){var p,g,m,_,y,S,w,E,M,$,C,O;const e=this.storeCtrl.state,s=Array.from(e.selectedAssets.keys()),i=Array.from(e.selectedFolders.keys()),a=this.selectionCtrl.getSelectedAssets(),r=this.selectionCtrl.getSelectedFolders(),n=((p=this.config)==null?void 0:p.folderSelection)!==!1,l=o.html`
|
|
6423
|
+
`];Ts([c.property()],mt.prototype,"text",2);mt=Ts([c.customElement("ap-tooltip")],mt);var Lr=Object.defineProperty,$t=(t,e,s,i)=>{for(var a=void 0,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=n(e,s,a)||a);return a&&Lr(e,s,a),a};const Ht=class Ht extends o.LitElement{constructor(){super(),this._initFailed=!1,this._loadId=0,this._loadMoreId=0,this._loadDataTimer=null,this._pendingFilter=null,this._pendingMetadataField=null,this._uploaderEl=null,this._uploaderImportPromise=null,this._dragCounter=0,this._isDragOver=!1,this._isUploaderOpen=!1,this._folderResolveOpen=!1,this._onDragEnter=e=>{var s;!((s=this.config)!=null&&s.uploader)||!this._hasFileTransfer(e)||(e.preventDefault(),this._dragCounter++,this._dragCounter===1&&(this._isDragOver=!0))},this._onDragOver=e=>{var s;!((s=this.config)!=null&&s.uploader)||!this._hasFileTransfer(e)||(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"))},this._onDragLeave=e=>{var s;!((s=this.config)!=null&&s.uploader)||!this._hasFileTransfer(e)||(e.preventDefault(),this._dragCounter--,this._dragCounter<=0&&(this._dragCounter=0,this._isDragOver=!1))},this._onDrop=e=>{var i,a;if(!((i=this.config)!=null&&i.uploader)||!this._hasFileTransfer(e))return;e.preventDefault(),this._dragCounter=0,this._isDragOver=!1;const s=Array.from(((a=e.dataTransfer)==null?void 0:a.files)??[]);s.length>0&&this._openUploader(s)},this.store=js(),this.storeCtrl=new Ns(this,this.store),this.selectionCtrl=new Us(this,this.store),this.infiniteScrollCtrl=new Vs(this,()=>this._loadMore()),this.marqueeCtrl=new qs(this,this.store)}get _isInline(){var e;return((e=this.config)==null?void 0:e.displayMode)==="inline"}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback(),this._uploaderEl&&(this._uploaderEl.remove(),this._uploaderEl=null),this._uploaderImportPromise=null,this._dragCounter=0,this._isDragOver=!1,this._isUploaderOpen=!1}updated(e){super.updated(e),e.has("config")&&this.config&&this._initConfig(this.config);const s=this.renderRoot.querySelector("#sentinel");if(s&&s!==this._lastSentinel){this._lastSentinel=s;const a=this.renderRoot.querySelector(".main-content");this.infiniteScrollCtrl.observe(s,a)}const i=this.renderRoot.querySelector(".main-content");i&&i!==this._lastMarqueeContainer&&(this._lastMarqueeContainer=i,this.marqueeCtrl.attach(i))}_initConfig(e){const s={folderSelection:!0,...e};this._initFailed=!1,this._initPromise=this._doInit(s).catch(()=>{this._initFailed=!0}),this.toggleAttribute("inline",s.displayMode==="inline"),s.displayMode==="inline"&&!this.store.getState().isOpen&&this.open()}async _doInit(e){const s=zi(),i=s.sortBy??e.defaultSortBy??"created_at",a=s.sortDirection??e.defaultSortDirection??"desc";this.store.setState({config:e,projectToken:e.auth.projectToken,viewMode:e.rememberLastView&&ji()||e.defaultViewMode||"grid",sortBy:i,sortDirection:a}),this.apiClient=new Hs(e.auth,e.apiBase);try{if(e.auth.mode==="securityTemplate"){const g=await Qs(this.apiClient);this.apiClient.setSassKey(g),this.store.setState({sassKey:g})}const[r,n,l,d]=await Promise.allSettled([mi(this.apiClient),Xs(this.apiClient),Ws(this.apiClient),gi(this.apiClient)]);if(r.status==="fulfilled"){const{fields:g,regionalVariantGroups:m,regionalFilters:_,brandColor:y}=r.value;this.store.setState({metadataFields:g,regionalVariantGroups:m,regionalFilters:_,...y?{brandColor:y}:{}})}n.status==="fulfilled"&&this.store.setState({labels:n.value.labels||[]}),l.status==="fulfilled"&&this.store.setState({tags:l.value}),d.status==="fulfilled"&&this.store.setState({fileTypes:d.value});const{pinnedFilters:h,pinnedMetadata:u}=Pi(e.auth.projectToken??null),f=this.store.getState().filters;this.store.setState({filters:{...f,pinned:h,visible:[...h],metadata:{...f.metadata,pinned:u,visible:[...u]}}});const p=e.brandColor||this.store.getState().brandColor;p&&(this.store.setState({brandColor:p}),Hi(this,p))}catch(r){throw this.dispatchEvent(new CustomEvent("ap-error",{detail:{error:r,context:"init"},bubbles:!0,composed:!0})),r}}_ensureUploaderImport(){return this._uploaderImportPromise?this._uploaderImportPromise:(this._uploaderImportPromise=import("@scaleflex/uploader/define").then(()=>{},e=>{throw this._uploaderImportPromise=null,e}),this._uploaderImportPromise)}_buildUploaderConfig(){const e=this.config,s=e.uploader,i=this.store.getState();let a;return e.auth.mode==="securityTemplate"?a={mode:"security-template",container:e.auth.projectToken,securityTemplateId:e.auth.securityTemplateKey}:a={mode:"sass-key",container:e.auth.projectToken,sassKey:e.auth.sassKey},{auth:a,targetFolder:i.currentFolderPath||"/",mode:"inline",restrictions:s.restrictions,concurrency:s.concurrency,autoProceed:s.autoProceed,showFillMetadata:s.showFillMetadata,connectors:s.connectors,sourcesLayout:s.sourcesLayout,headerButton:s.headerButton??"back",clearOnClose:s.clearOnClose,clearOnComplete:s.clearOnComplete,rejectedFileAutoRemoveDelay:s.rejectedFileAutoRemoveDelay}}async _openUploader(e){var i;if(!((i=this.config)!=null&&i.uploader)||this._isUploaderOpen)return;try{await this._ensureUploaderImport()}catch(a){this.dispatchEvent(new CustomEvent("ap-error",{detail:{error:a instanceof Error?a:new Error(String(a)),context:"uploader-load"},bubbles:!0,composed:!0}));return}this._uploaderEl=document.createElement("sfx-uploader");const s=this._uploaderEl;s.addEventListener("sfx-all-complete",()=>{this.store.getState().isOpen&&this._loadData()}),s.addEventListener("sfx-complete-action",()=>{this._closeUploader()}),s.addEventListener("sfx-cancel",()=>{this._closeUploader()}),this._isUploaderOpen=!0,await this.updateComplete,s.config=this._buildUploaderConfig(),await s.updateComplete,e!=null&&e.length&&s.addFiles(e)}_closeUploader(){this._isUploaderOpen=!1,this._uploaderEl=null}_handleUploadClick(){this._openUploader()}_hasFileTransfer(e){var s,i;return!!((i=(s=e.dataTransfer)==null?void 0:s.types)!=null&&i.includes("Files"))}async open(){var u,f,p,g,m,_,y,S,w,E;const e=this.store.getState(),s=Ge((u=this.config)==null?void 0:u.forcedFilters),i=new Set(Object.keys(s)),a={},r=Ge((f=this.config)==null?void 0:f.defaultFilters);for(const[M,$]of Object.entries(r))i.has(M)||(a[M]=$);const n=Object.keys(a),l=((p=this.config)==null?void 0:p.tabs)??["assets","folders"],d=(g=this.config)!=null&&g.rememberLastTab?Bi():null,h=(d&&l.includes(d)?d:null)??((m=this.config)!=null&&m.defaultTab&&l.includes(this.config.defaultTab)?this.config.defaultTab:null)??l[0]??"assets";this.store.setState({isOpen:!0,activeTab:h,searchQuery:"",filters:{metadata:{pinned:e.filters.metadata.pinned,visible:[...e.filters.metadata.pinned],applied:{}},pinned:e.filters.pinned,visible:[...new Set([...e.filters.pinned,...n])],applied:a},offset:0,assets:[],folders:[],currentFolder:null,currentFolderPath:h==="folders"&&((_=this.config)==null?void 0:_.rememberLastFolder)&&is()||((y=this.config)==null?void 0:y.rootFolderPath)||"/",breadcrumb:this._buildBreadcrumbFromPath(h==="folders"&&((S=this.config)==null?void 0:S.rememberLastFolder)&&is()||((w=this.config)==null?void 0:w.rootFolderPath)||"/",((E=this.config)==null?void 0:E.rootFolderPath)||"/"),selectedAssets:new Map,selectedFolders:new Map,isResolvingFolders:!1,folderPreviews:{},isPreviewOpen:!1,previewAsset:null,isLoading:!0,isSelectingAll:!1}),this._dragCounter=0,this._isDragOver=!1,this.dispatchEvent(new CustomEvent("ap-open",{detail:{timestamp:Date.now()},bubbles:!0,composed:!0})),await this.updateComplete,!this._initPromise&&this.config&&this._initConfig(this.config),!(this._initPromise&&(await this._initPromise,this._initFailed))&&this._loadData()}close(){this.store.setState({isOpen:!1}),this._dragCounter=0,this._isDragOver=!1,this._isUploaderOpen=!1,this._folderResolveOpen=!1}_scrollToTop(){var e;(e=this.renderRoot.querySelector(".main-content"))==null||e.scrollTo({top:0})}async _loadData(){var i,a,r,n,l,d,h,u,f,p,g,m,_,y;if(!this.apiClient)return;const e=++this._loadId,s=this.store.getState();this._scrollToTop(),this.store.setState({isLoading:!0});try{const S=s.activeTab;if(S==="assets"){const w=this._buildSearchNotation(),E=s.currentFolderPath||"/",M=qe(this.apiClient,{folder:E,offset:0,limit:s.limit,sort_by:s.sortBy,sort_direction:s.sortDirection,search:s.searchQuery||void 0,q:w||void 0,recursive:1}),$=Xt(this.apiClient,{folder:E,q:w||void 0,search:s.searchQuery||void 0,recursive:1}).catch(()=>null),[C,O]=await Promise.all([M,$]);if(e!==this._loadId)return;const V=((i=C.files)==null?void 0:i.length)??0,q=V>=s.limit,Te=((a=O==null?void 0:O.stats)==null?void 0:a.approx_files_count)??((r=O==null?void 0:O.info)==null?void 0:r.total_files_count)??((n=C.info)==null?void 0:n.total_files_count)??((d=(l=C.base)==null?void 0:l.count)==null?void 0:d.files_recursive)??((u=(h=C.base)==null?void 0:h.count)==null?void 0:u.files_direct)??V;this.store.setState({assets:C.files||[],folders:[],totalCount:Te,totalFolderCount:0,offset:0,hasMore:q,isLoading:!1})}else if(S==="folders"){const w=this._buildSearchNotation(),E=s.currentFolderPath||"/",[M,$,C]=await Promise.all([Ks(this.apiClient,{folderPath:s.currentFolderPath,q:s.searchQuery||void 0,recursive:s.searchQuery?1:0,sort_by:s.sortBy,sort_direction:s.sortDirection}),qe(this.apiClient,{folder:E,offset:0,limit:s.limit,sort_by:s.sortBy,sort_direction:s.sortDirection,search:s.searchQuery||void 0,q:w||void 0,recursive:0}),Xt(this.apiClient,{folder:E,q:w||void 0,search:s.searchQuery||void 0,recursive:0}).catch(()=>null)]);if(e!==this._loadId)return;const O=M.folders||[];let V={};if(O.length>0)try{V=await Ys(this.apiClient,O.map(me=>me.uuid))}catch{}if(e!==this._loadId)return;const q=((f=$.files)==null?void 0:f.length)??0,Te=q>=s.limit,it=((p=C==null?void 0:C.stats)==null?void 0:p.approx_files_count)??((g=C==null?void 0:C.info)==null?void 0:g.total_files_count)??((m=$.info)==null?void 0:m.total_files_count)??((y=(_=$.base)==null?void 0:_.count)==null?void 0:y.files_direct)??q;this.store.setState({assets:$.files||[],folders:O,folderPreviews:V,totalCount:it,totalFolderCount:M.total??O.length,offset:0,hasMore:Te,isLoading:!1})}}catch(S){if(e!==this._loadId)return;this.store.setState({isLoading:!1}),this.dispatchEvent(new CustomEvent("ap-error",{detail:{error:S,context:"loadData"},bubbles:!0,composed:!0}))}}async _loadMore(){const e=this.store.getState();if(e.isLoading||!e.hasMore||!this.apiClient)return;const s=++this._loadMoreId,i=e.offset+e.limit;this.store.setState({isLoading:!0});try{const a=this._buildSearchNotation(),r=await qe(this.apiClient,{folder:e.currentFolderPath||"/",offset:i,limit:e.limit,sort_by:e.sortBy,sort_direction:e.sortDirection,search:e.searchQuery||void 0,q:a||void 0,recursive:e.activeTab==="folders"?0:1});if(s!==this._loadMoreId)return;const n=this.store.getState().assets,l=r.files||[],d=l.length>=e.limit,h=[...n,...l];this.store.setState({assets:h,offset:i,hasMore:d,isLoading:!1})}catch{if(s!==this._loadMoreId)return;this.store.setState({isLoading:!1})}}_debouncedLoadData(e=120){this._loadDataTimer&&clearTimeout(this._loadDataTimer),this._loadDataTimer=setTimeout(()=>{this._loadDataTimer=null,this._loadData()},e)}_handleCancel(e){var s,i;this.close(),(i=(s=this.config)==null?void 0:s.onCancel)==null||i.call(s),this.dispatchEvent(new CustomEvent("ap-cancel",{detail:{reason:e},bubbles:!0,composed:!0}))}_handleSearchChange(e){this.store.setState({searchQuery:e.detail.value,offset:0,assets:[],folders:[]}),this.selectionCtrl.resetRange(),this._loadData()}_handleViewChange(e){var i;const s=e.detail.mode;this.store.setState({viewMode:s}),(i=this.config)!=null&&i.rememberLastView&&Ri(s),this._scrollToTop()}_handleRegionalChange(e){const{groupUuid:s,value:i}=e.detail,a=this.store.getState().regionalFilters;this.store.setState({regionalFilters:{...a,[s]:i}})}_handleSortChange(e){const s=e.detail.value,i=this.store.getState();this.store.setState({sortBy:s,offset:0,assets:[],folders:[]}),ts(s,i.sortDirection),this.selectionCtrl.resetRange(),this._loadData()}_handleSortDirectionChange(e){const s=e.detail.value,i=this.store.getState();this.store.setState({sortDirection:s,offset:0,assets:[],folders:[]}),ts(i.sortBy,s),this.selectionCtrl.resetRange(),this._loadData()}_handleTabChange(e){var i,a;const s=e.detail.tab;(i=this.config)!=null&&i.rememberLastTab&&Ni(s),this.store.setState({activeTab:s,currentFolder:null,currentFolderPath:((a=this.config)==null?void 0:a.rootFolderPath)??"/",breadcrumb:[],offset:0,assets:[],folders:[]}),this.selectionCtrl.resetRange(),this._loadData()}_handleAssetSelect(e){this.selectionCtrl.handleSelect(e.detail.asset,e.detail.index,e.detail.event)}_handleFolderSelect(e){this.selectionCtrl.handleFolderSelect(e.detail.folder,e.detail.index,e.detail.event)}_handleAssetPreview(e){this.store.setState({previewAsset:e.detail.asset,isPreviewOpen:!0})}_handleQuickSelect(e){var i,a;const s=e.detail.asset;(a=(i=this.config)==null?void 0:i.onSelect)==null||a.call(i,[s]),this.dispatchEvent(new CustomEvent("ap-select",{detail:{assets:[s]},bubbles:!0,composed:!0})),this._isInline||this.close()}_handleFolderOpen(e){var r;const s=e.detail.folder,i=this.store.getState(),a=s.path||`${i.currentFolderPath}${s.name}/`;(r=this.config)!=null&&r.rememberLastFolder&&ss(a),this.store.setState({currentFolder:s.uuid,currentFolderPath:a,breadcrumb:[...i.breadcrumb,{uuid:s.uuid,name:s.name,path:a}],searchQuery:"",offset:0,assets:[],folders:[]}),this.selectionCtrl.resetRange(),this._loadData()}_handleBreadcrumbNavigate(e){var l,d;const s=e.detail.uuid,i=this.store.getState(),a=s?i.breadcrumb.findIndex(h=>h.uuid===s):-1,r=s?i.breadcrumb.slice(0,a+1):[],n=r.length>0?r[r.length-1].path:((l=this.config)==null?void 0:l.rootFolderPath)||"/";(d=this.config)!=null&&d.rememberLastFolder&&ss(n),this.store.setState({currentFolder:s||null,currentFolderPath:n,breadcrumb:r,offset:0,assets:[],folders:[]}),this.selectionCtrl.resetRange(),this._loadData()}_buildBreadcrumbFromPath(e,s){if(!e||e===s||e==="/")return[];const a=(e.startsWith(s)?e.slice(s.length):e.replace(/^\//,"")).split("/").filter(Boolean),r=[];let n=s.endsWith("/")?s:s+"/";for(const l of a)n+=l+"/",r.push({uuid:n,name:l,path:n});return r}_handlePreviewClose(){this.store.setState({isPreviewOpen:!1,previewAsset:null})}_handlePreviewNavigate(e){this.store.setState({previewAsset:e.detail.asset})}_handleSelectionConfirm(e){var a,r,n,l,d,h;const s=e.detail.assets,i=e.detail.folders||[];if(i.length>0&&((a=this.config)==null?void 0:a.folderSelection)!==!1){if(((r=this.config)==null?void 0:r.folderSelectionMode)==="assets"){this._folderResolveOpen=!0;return}(l=(n=this.config)==null?void 0:n.onSelect)==null||l.call(n,s,i),this.dispatchEvent(new CustomEvent("ap-select",{detail:{assets:s,folders:i},bubbles:!0,composed:!0})),this._isInline||this.close();return}(h=(d=this.config)==null?void 0:d.onSelect)==null||h.call(d,s),this.dispatchEvent(new CustomEvent("ap-select",{detail:{assets:s},bubbles:!0,composed:!0})),this._isInline||this.close()}async _handleFolderResolveConfirm(e){var r,n,l;const s=e.detail.mode,i=this.selectionCtrl.getSelectedFolders(),a=this.selectionCtrl.getSelectedAssets();this.store.setState({isResolvingFolders:!0});try{const d=await Promise.all(i.map(m=>qe(this.apiClient,{folder:m.path,recursive:s==="recursive"?1:0,limit:1e4}))),h=[];for(const m of d)h.push(...m.files);const u=[...a],f=new Set(u.map(m=>m.uuid));for(const m of h)f.has(m.uuid)||(u.push(m),f.add(m.uuid));const p=(r=this.config)==null?void 0:r.maxSelections,g=p?u.slice(0,p):u;(l=(n=this.config)==null?void 0:n.onSelect)==null||l.call(n,g),this.dispatchEvent(new CustomEvent("ap-select",{detail:{assets:g},bubbles:!0,composed:!0})),this._folderResolveOpen=!1,this.store.setState({isResolvingFolders:!1}),this._isInline||this.close()}catch(d){this.store.setState({isResolvingFolders:!1}),this.dispatchEvent(new CustomEvent("ap-error",{detail:{error:d,context:"folderResolve"},bubbles:!0,composed:!0}))}}_handleFolderResolveCancel(){this._folderResolveOpen=!1}async _handleSelectAll(e){var l,d,h;const s=this.store.getState();if(s.isSelectingAll||!this.apiClient||!(((l=s.config)==null?void 0:l.multiSelect)??!0))return;const a=((d=e==null?void 0:e.detail)==null?void 0:d.scope)??"all",r=a!=="assets"&&((h=this.config)==null?void 0:h.folderSelection)!==!1&&s.folders.length>0;if(!(a!=="folders")){r&&this.selectionCtrl.selectAllFolders(s.folders);return}if(s.assets.length>=s.totalCount){r&&this.selectionCtrl.selectAllFolders(s.folders),this.selectionCtrl.selectAll(s.assets);return}this.store.setState({isSelectingAll:!0});try{const u=this._buildSearchNotation(),f=s.currentFolderPath||"/",p=s.limit,g=s.assets,m=s.totalCount,_=s.activeTab==="folders"?0:1,y=[];for(let C=g.length;C<m;C+=p)y.push(C);const S=4,w=[];for(let C=0;C<y.length;C+=S){const O=y.slice(C,C+S),V=await Promise.all(O.map(q=>qe(this.apiClient,{folder:f,offset:q,limit:p,sort_by:s.sortBy,sort_direction:s.sortDirection,search:s.searchQuery||void 0,q:u||void 0,recursive:_})));for(const q of V)q.files&&w.push(...q.files)}const E=new Set(g.map(C=>C.uuid)),M=w.filter(C=>E.has(C.uuid)?!1:(E.add(C.uuid),!0)),$=[...g,...M];this.store.setState({assets:$,offset:Math.max(0,$.length-p),hasMore:!1,isSelectingAll:!1}),r&&this.selectionCtrl.selectAllFolders(s.folders),this.selectionCtrl.selectAll($)}catch(u){this.store.setState({isSelectingAll:!1}),this.dispatchEvent(new CustomEvent("ap-error",{detail:{error:u,context:"selectAll"},bubbles:!0,composed:!0}))}}_handleSelectionClear(){this.selectionCtrl.clearSelection()}_handleSelectionDeselect(e){const s=new Map(this.store.getState().selectedAssets);s.delete(e.detail.uuid),this.store.setState({selectedAssets:s})}_isDateFilterKey(e){return e===v.DATE||e===v.LICENSE_EXPIRY||e===R.DUE_DATE}_handleFilterUpdate(e){const{key:s,values:i,operator:a}=e.detail,n={...this.store.getState().filters};let l=i===""||i===null||i===void 0||Array.isArray(i)&&i.length===0||typeof i=="object"&&!Array.isArray(i)&&Object.values(i).every(d=>d==null||d===""||Array.isArray(d)&&d.length===0);if(!l&&this._isDateFilterKey(s)&&typeof i=="object"&&!Array.isArray(i)){const{kind:d,preset:h,from:u,to:f}=i;l=!d&&!h&&!u&&!f}if(l){const d={...n.applied};delete d[s],n.applied=d,n.pinned.includes(s)||(n.visible=n.visible.filter(h=>h!==s))}else{const d={...n.applied};this._isDateFilterKey(s)&&typeof i=="object"&&!Array.isArray(i)?d[s]={type:"date",field:i.field||"created",kind:i.kind||null,preset:i.preset||null,from:i.from||null,to:i.to||null}:s===v.IMAGE&&typeof i=="object"&&!Array.isArray(i)?d[s]=i:d[s]={type:"string",values:Array.isArray(i)?i:[i],operator:a||":"},n.applied=d,n.visible.includes(s)||(n.visible=[...n.visible,s])}if(this.store.setState({filters:n,offset:0,assets:[],folders:[],isLoading:!0}),this.selectionCtrl.resetRange(),this._debouncedLoadData(),this._pendingFilter===s){this._pendingFilter=null;const d=this.renderRoot.querySelector("ap-filters-bar");d&&(d.pendingFilter=null)}}_handleFilterOpen(e){const s=e.detail.key,i=e.detail.chipRect,a=this.renderRoot.querySelector("ap-content-toolbar");let r,n;if(i){const l=this.renderRoot.querySelector(".toolbar-filters-wrapper");if(l){const d=l.getBoundingClientRect();r=i.left-d.left,n=i.bottom-d.top}}a==null||a.openFilterPanel(s,!0,r,n)}_handleMetadataFilterOpen(e){const{fieldKey:s,chipRect:i}=e.detail,a=this.renderRoot.querySelector("ap-content-toolbar");let r,n;if(i){const l=this.renderRoot.querySelector(".toolbar-filters-wrapper");if(l){const d=l.getBoundingClientRect();r=i.left-d.left,n=i.bottom-d.top}}a==null||a.openMetadataFieldPanel(s,!0,r,n)}_handleFilterPanelChange(e){const s=this.renderRoot.querySelector("ap-filters-bar");s&&(s.activeFilter=e.detail.key,s.activeMetadataField=e.detail.metadataFieldKey||null),!e.detail.key&&!e.detail.metadataFieldKey&&(this._pendingFilter||this._pendingMetadataField)&&(this._pendingFilter=null,this._pendingMetadataField=null,s&&(s.pendingFilter=null,s.pendingMetadataField=null))}async _handleFilterPending(e){var p,g,m;const{key:s,metadataFieldKey:i}=e.detail,a=this.renderRoot.querySelector("ap-filters-bar"),r=this.renderRoot.querySelector("ap-content-toolbar");if(!a||!r)return;i?(this._pendingMetadataField=i,a.pendingMetadataField=i):s&&(this._pendingFilter=s,a.pendingFilter=s),await a.updateComplete;let n=a.renderRoot.querySelector(".chip.pending");if(!n){const _=a.renderRoot.querySelectorAll(".chip.pinned-empty"),y=i?(p=a._getMetadataLabel)==null?void 0:p.call(a,i):void 0;for(const S of _){const w=(m=(g=S.querySelector(".chip-label"))==null?void 0:g.textContent)==null?void 0:m.trim();if(i&&w===y){n=S;break}if(s&&w===(Le[s]||s)){n=S;break}}}if(!n)return;const l=n.getBoundingClientRect(),d=this.renderRoot.querySelector(".toolbar-filters-wrapper"),h=d==null?void 0:d.getBoundingClientRect(),u=h?l.left-h.left:l.left,f=h?l.bottom-h.top:void 0;i?r.openMetadataFieldPanel(i,!0,u,f):s&&r.openFilterPanel(s,!0,u,f)}_handleFilterRemove(e){var n;const s=e.detail.key;if(s in(((n=this.config)==null?void 0:n.forcedFilters)??{}))return;const a={...this.store.getState().filters},r={...a.applied};delete r[s],a.applied=r,a.pinned.includes(s)||(a.visible=a.visible.filter(l=>l!==s)),this.store.setState({filters:a,offset:0,assets:[],folders:[],isLoading:!0}),this.selectionCtrl.resetRange(),this._debouncedLoadData()}_handleMetadataFilterChange(e){const{fieldKey:s,operator:i,values:a,metadataType:r}=e.detail,l={...this.store.getState().filters},d={...l.metadata},h={...d.applied};if(!a||Array.isArray(a)&&a.length===0?(delete h[s],d.applied=h,d.pinned.includes(s)||(d.visible=d.visible.filter(f=>f!==s))):(h[s]={type:"string",values:Array.isArray(a)?a:[a],operator:i||":",metadataType:r},d.applied=h,d.visible.includes(s)||(d.visible=[...d.visible,s])),l.metadata=d,this.store.setState({filters:l,offset:0,assets:[],folders:[],isLoading:!0}),this.selectionCtrl.resetRange(),this._debouncedLoadData(),this._pendingMetadataField===s){this._pendingMetadataField=null;const f=this.renderRoot.querySelector("ap-filters-bar");f&&(f.pendingMetadataField=null)}}_handleMetadataFieldToggle(e){const{fieldKey:s,visible:i}=e.detail,r={...this.store.getState().filters},n={...r.metadata};i?n.visible.includes(s)||(n.visible=[...n.visible,s]):n.visible=n.visible.filter(l=>l!==s),r.metadata=n,this.store.setState({filters:r})}_handleMetadataFilterRemove(e){const{fieldKey:s}=e.detail,a={...this.store.getState().filters},r={...a.metadata},n={...r.applied};delete n[s],r.applied=n,r.pinned.includes(s)||(r.visible=r.visible.filter(l=>l!==s)),a.metadata=r,this.store.setState({filters:a,offset:0,assets:[],folders:[],isLoading:!0}),this.selectionCtrl.resetRange(),this._debouncedLoadData()}_handleFilterPin(e){var l,d;const{key:s,pinned:i}=e.detail,r={...this.store.getState().filters};i?r.pinned.includes(s)||(r.pinned=[...r.pinned,s]):(r.pinned=r.pinned.filter(h=>h!==s),s in r.applied||(r.visible=r.visible.filter(h=>h!==s))),this.store.setState({filters:r});const n=((d=(l=this.store.getState().config)==null?void 0:l.auth)==null?void 0:d.projectToken)??null;Ii(n,r.pinned)}_handleMetadataPin(e){var d,h;const{fieldKey:s,pinned:i}=e.detail,r={...this.store.getState().filters},n={...r.metadata};i?n.pinned.includes(s)||(n.pinned=[...n.pinned,s]):(n.pinned=n.pinned.filter(u=>u!==s),s in n.applied||(n.visible=n.visible.filter(u=>u!==s))),r.metadata=n,this.store.setState({filters:r});const l=((h=(d=this.store.getState().config)==null?void 0:d.auth)==null?void 0:h.projectToken)??null;Di(l,n.pinned)}_handleFiltersClearAll(){const e=this.store.getState();this.store.setState({filters:{...e.filters,applied:{},visible:[...e.filters.pinned],metadata:{...e.filters.metadata,applied:{},visible:[...e.filters.metadata.pinned]}},offset:0,assets:[],folders:[],isLoading:!0});const s=this.renderRoot.querySelector("ap-filters-bar");s&&(s.activeFilter=null),this.selectionCtrl.resetRange(),this._debouncedLoadData()}_handleFilterDeactivate(e){const s=e.detail.key,a={...this.store.getState().filters};a.visible=a.visible.filter(r=>r!==s),this.store.setState({filters:a})}_handleMetadataFieldDeactivate(e){const{fieldKey:s}=e.detail,a={...this.store.getState().filters},r={...a.metadata};r.visible=r.visible.filter(n=>n!==s),a.metadata=r,this.store.setState({filters:a})}_handleFiltersSet(e){var h;const{applied:s,metadata:i}=e.detail,r={...this.store.getState().filters},n=new Set(Object.keys(((h=this.config)==null?void 0:h.forcedFilters)??{})),l={...s};for(const u of n)delete l[u];r.applied=l;const d=Object.keys(s);if(r.visible=[...new Set([...r.pinned,...d])],i){const u={...r.metadata};u.applied=i.applied;const f=Object.keys(i.applied);u.visible=[...new Set([...u.pinned,...f])],r.metadata=u}this.store.setState({filters:r,offset:0,assets:[],folders:[],isLoading:!0}),this.selectionCtrl.resetRange(),this._debouncedLoadData()}_getSortOptions(){const e=this.storeCtrl.state;return e.searchQuery?Gi:e.activeTab==="folders"?Ki:zt}_buildSearchNotation(){var a;const e=this.store.getState(),s={...Ge((a=this.config)==null?void 0:a.forcedFilters),...e.filters.applied};return _i(s,e.filters.metadata.applied).join(" ")}render(){var p,g,m,_,y,S,w,E,M,$,C,O;const e=this.storeCtrl.state,s=Array.from(e.selectedAssets.keys()),i=Array.from(e.selectedFolders.keys()),a=this.selectionCtrl.getSelectedAssets(),r=this.selectionCtrl.getSelectedFolders(),n=((p=this.config)==null?void 0:p.folderSelection)!==!1,l=o.html`
|
|
6424
6424
|
<ap-header
|
|
6425
6425
|
.activeTab=${e.activeTab}
|
|
6426
6426
|
.tabs=${((g=this.config)==null?void 0:g.tabs)??["assets","folders"]}
|
|
@@ -6838,4 +6838,4 @@
|
|
|
6838
6838
|
--sfx-up-border: transparent;
|
|
6839
6839
|
--sfx-up-radius: 0;
|
|
6840
6840
|
}
|
|
6841
|
-
`];let Ce=Ht;$t([c.state()],Ce.prototype,"_isDragOver");$t([c.state()],Ce.prototype,"_isUploaderOpen");$t([c.state()],Ce.prototype,"_folderResolveOpen");$t([c.property({type:Object})],Ce.prototype,"config");exports.AssetPicker=Ce;
|
|
6841
|
+
`];let Ce=Ht;$t([c.state()],Ce.prototype,"_isDragOver");$t([c.state()],Ce.prototype,"_isUploaderOpen");$t([c.state()],Ce.prototype,"_folderResolveOpen");$t([c.property({type:Object})],Ce.prototype,"config");exports.AssetPicker=Ce;exports.getHlsUrl=Cs;
|