web-to-print 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/cjs/app-globals-V2Kpy_OQ.js +5 -0
- package/dist/cjs/canvas-helpers-A6rp5rPD.js +765 -0
- package/dist/cjs/index-IFGFRm-i.js +1649 -0
- package/dist/cjs/index.cjs.js +232 -0
- package/dist/cjs/loader.cjs.js +13 -0
- package/dist/cjs/logo-BUX-b45R.js +18 -0
- package/dist/cjs/web-to-print.cjs.js +25 -0
- package/dist/cjs/wtp-editor_2.cjs.entry.js +12386 -0
- package/dist/cjs/wtp-logo-renderer.cjs.entry.js +353 -0
- package/dist/cjs/wtp-print-area-editor.cjs.entry.js +431 -0
- package/dist/collection/collection-manifest.json +16 -0
- package/dist/collection/components/wtp-editor/wtp-editor.css +124 -0
- package/dist/collection/components/wtp-editor/wtp-editor.js +1114 -0
- package/dist/collection/components/wtp-logo-renderer/wtp-logo-renderer.css +30 -0
- package/dist/collection/components/wtp-logo-renderer/wtp-logo-renderer.js +455 -0
- package/dist/collection/components/wtp-logo-upload/wtp-logo-upload.css +428 -0
- package/dist/collection/components/wtp-logo-upload/wtp-logo-upload.js +573 -0
- package/dist/collection/components/wtp-print-area-editor/wtp-print-area-editor.css +20 -0
- package/dist/collection/components/wtp-print-area-editor/wtp-print-area-editor.js +600 -0
- package/dist/collection/examples/schaeffler--big.svg +1 -0
- package/dist/collection/index.js +8 -0
- package/dist/collection/types/editor.js +1 -0
- package/dist/collection/types/index.js +2 -0
- package/dist/collection/types/labels.js +30 -0
- package/dist/collection/types/logo.js +13 -0
- package/dist/collection/utils/background-removal.js +717 -0
- package/dist/collection/utils/canvas-helpers.js +380 -0
- package/dist/collection/utils/format-detection.js +48 -0
- package/dist/collection/utils/html-render-helpers.js +106 -0
- package/dist/collection/utils/image-preview.js +54 -0
- package/dist/collection/utils/logo-validation.js +141 -0
- package/dist/collection/utils/pdf-export.js +224 -0
- package/dist/components/index.d.ts +35 -0
- package/dist/components/index.js +1 -0
- package/dist/components/p-5qCsRzlt.js +1 -0
- package/dist/components/p-Bn9gR_8e.js +1 -0
- package/dist/components/p-D8pVJRuX.js +1 -0
- package/dist/components/wtp-editor.d.ts +11 -0
- package/dist/components/wtp-editor.js +1 -0
- package/dist/components/wtp-logo-renderer.d.ts +11 -0
- package/dist/components/wtp-logo-renderer.js +1 -0
- package/dist/components/wtp-logo-upload.d.ts +11 -0
- package/dist/components/wtp-logo-upload.js +1 -0
- package/dist/components/wtp-print-area-editor.d.ts +11 -0
- package/dist/components/wtp-print-area-editor.js +1 -0
- package/dist/esm/app-globals-DQuL1Twl.js +3 -0
- package/dist/esm/canvas-helpers-CK8OAq2J.js +748 -0
- package/dist/esm/index-CUetmLbL.js +1641 -0
- package/dist/esm/index.js +228 -0
- package/dist/esm/loader.js +11 -0
- package/dist/esm/logo-D8pVJRuX.js +15 -0
- package/dist/esm/web-to-print.js +21 -0
- package/dist/esm/wtp-editor_2.entry.js +12383 -0
- package/dist/esm/wtp-logo-renderer.entry.js +351 -0
- package/dist/esm/wtp-print-area-editor.entry.js +429 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/types/components/wtp-editor/wtp-editor.d.ts +101 -0
- package/dist/types/components/wtp-logo-renderer/wtp-logo-renderer.d.ts +55 -0
- package/dist/types/components/wtp-logo-upload/wtp-logo-upload.d.ts +76 -0
- package/dist/types/components/wtp-print-area-editor/wtp-print-area-editor.d.ts +43 -0
- package/dist/types/components.d.ts +507 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/stencil-public-runtime.d.ts +1860 -0
- package/dist/types/types/editor.d.ts +79 -0
- package/dist/types/types/index.d.ts +5 -0
- package/dist/types/types/labels.d.ts +30 -0
- package/dist/types/types/logo.d.ts +47 -0
- package/dist/types/utils/background-removal.d.ts +95 -0
- package/dist/types/utils/canvas-helpers.d.ts +60 -0
- package/dist/types/utils/format-detection.d.ts +4 -0
- package/dist/types/utils/html-render-helpers.d.ts +44 -0
- package/dist/types/utils/image-preview.d.ts +13 -0
- package/dist/types/utils/logo-validation.d.ts +2 -0
- package/dist/types/utils/pdf-export.d.ts +32 -0
- package/dist/web-to-print/index.esm.js +1 -0
- package/dist/web-to-print/p-611ec561.entry.js +1 -0
- package/dist/web-to-print/p-703e4c52.entry.js +1 -0
- package/dist/web-to-print/p-CK8OAq2J.js +1 -0
- package/dist/web-to-print/p-CUetmLbL.js +2 -0
- package/dist/web-to-print/p-D8pVJRuX.js +1 -0
- package/dist/web-to-print/p-DQuL1Twl.js +1 -0
- package/dist/web-to-print/p-b532777b.entry.js +1 -0
- package/dist/web-to-print/web-to-print.esm.js +1 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/package.json +68 -0
- package/readme.md +490 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={urlPlaceholder:"https://example.com/logo.png",urlSubmit:"Fetch",dividerText:"or",dropPromptText:"Drag & drop your logo here or click to browse",dropPromptHint:"PNG, JPEG, SVG, TIFF, or AVIF",uploadAriaLabel:"Upload logo file",removeAriaLabel:e=>`Remove ${e}`,urlErrorEmpty:"Please enter a URL",urlErrorInvalid:"Invalid URL format",urlErrorProtocol:"Only HTTPS URLs are supported",urlErrorHttp:(e,o)=>`HTTP ${e}: ${o}`,urlErrorNetwork:"Could not fetch the image. The server may not allow cross-origin requests (CORS).",urlErrorFetch:"Failed to fetch image",bgRemovalProcessing:"Removing background...",bgRemovalUseOriginal:"Use Original",bgRemovalUseRemoved:"Without Background",bgRemovalFailed:"Failed",rejectionDpiUnit:"DPI"},o={addTextButton:"Add Text",addTextTooltip:"Add text",fontSelectTooltip:"Font family",colorPickerTooltip:"Text color",deleteButtonTooltip:"Delete selected",defaultText:"New Text"};export{o as D,e as a}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const i={minDpi:300,maxFileSize:52428800,minWidth:100,minHeight:100,allowedFormats:["png","jpeg","svg","tiff","avif"]},a={tolerance:40,minEdgeRatio:.3,autoCrop:!0,autoCropPadding:2};export{i as D,a}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface WtpEditor extends Components.WtpEditor, HTMLElement {}
|
|
4
|
+
export const WtpEditor: {
|
|
5
|
+
prototype: WtpEditor;
|
|
6
|
+
new (): WtpEditor;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t,c as i,H as e,d as o,e as s,f as a,u as r,w as n,h,p as d,i as c,j as l,k as f}from"./p-5qCsRzlt.js";import{D as p}from"./p-Bn9gR_8e.js";const b=i(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.wtpEditorReady=o(this,"wtpEditorReady"),this.wtpEditorStateChanged=o(this,"wtpEditorStateChanged"),this.wtpEditorObjectSelected=o(this,"wtpEditorObjectSelected"),this.wtpEditorObjectDeselected=o(this,"wtpEditorObjectDeselected")}get el(){return this}width=800;height=600;productImage;initialState;fonts=["Arial","Helvetica","Times New Roman","Georgia","Verdana"];printArea;debug=!1;labels={};getLabels(){return{...p,...this.labels}}selectedObjectId=null;selectedObjectType=null;selectedFont="Arial";selectedTextColor="#000000";wtpEditorReady;wtpEditorStateChanged;wtpEditorObjectSelected;wtpEditorObjectDeselected;canvas;canvasEl;objectMap=new Map;previewUrlMap=new Map;backgroundReady=Promise.resolve();componentDidLoad(){this.initCanvas()}disconnectedCallback(){this.canvas?.dispose()}onProductImageChange(){void 0!==this.canvas&&void 0!==this.productImage&&(this.canvas.setDimensions({width:this.width,height:this.height}),this.backgroundReady=s(this.canvas,this.productImage))}onSizeChange(){void 0!==this.canvas&&(this.canvas.setDimensions({width:this.width,height:this.height}),void 0!==this.productImage&&""!==this.productImage&&(this.backgroundReady=s(this.canvas,this.productImage)),this.canvas.renderAll())}onDebugChange(){this.canvas?.renderAll()}async onPrintAreaChange(){if(await this.backgroundReady,void 0!==this.canvas){for(const t of this.objectMap.values())this.clampObjectToPrintArea(t);this.canvas.renderAll()}}async addLogo(t){if(void 0===this.canvas)throw Error("Canvas not initialized");await this.backgroundReady;const i=a(),{dataUrl:e}=r(t.dataUrl),o=await n.fromURL(e),s=this.canvas.getWidth(),d=this.canvas.getHeight();if(void 0!==this.printArea){const t=h(o.width??100,o.height??100,this.printArea,s,d);o.set({left:t.x,top:t.y,originX:"center",originY:"center",scaleX:t.scaleX,scaleY:t.scaleY,angle:t.angle})}else{const t=Math.min(Math.min(.3*s/(o.width??100),.3*d/(o.height??100)),1);o.set({left:s/2,top:d/2,originX:"center",originY:"center",scaleX:t,scaleY:t})}return o._objectId=i,this.objectMap.set(i,o),void 0!==t.previewDataUrl&&this.previewUrlMap.set(i,t.previewDataUrl),this.canvas.add(o),this.canvas.setActiveObject(o),this.canvas.renderAll(),this.emitStateChanged(),i}async addText(t,i){if(void 0===this.canvas)throw Error("Canvas not initialized");await this.backgroundReady;const e=a();let o=this.canvas.getWidth()/2,s=this.canvas.getHeight()/2;if(void 0!==this.printArea){const t=d(this.printArea,this.canvas.getWidth(),this.canvas.getHeight());o=(t[0].x+t[1].x+t[2].x+t[3].x)/4,s=(t[0].y+t[1].y+t[2].y+t[3].y)/4}const r=new c(t,{left:o,top:s,originX:"center",originY:"center",fontFamily:i?.fontFamily??this.selectedFont,fontSize:i?.fontSize??24,fill:i?.fill??"#000000"});return r._objectId=e,this.objectMap.set(e,r),this.canvas.add(r),this.canvas.setActiveObject(r),this.canvas.renderAll(),this.emitStateChanged(),e}async removeObject(t){if(void 0===this.canvas)return;const i=this.objectMap.get(t);void 0!==i&&(this.canvas.remove(i),this.objectMap.delete(t),this.canvas.renderAll(),this.emitStateChanged())}async exportState(){return this.buildEditorState()}async loadState(t){if(void 0===this.canvas)throw Error("Canvas not initialized");this.canvas.clear(),this.objectMap.clear(),this.previewUrlMap.clear();for(const i of t.logos)void 0!==i.previewDataUrl&&this.previewUrlMap.set(i.id,i.previewDataUrl);if(this.canvas.setDimensions({width:t.width,height:t.height}),void 0!==t.fabricJson&&""!==t.fabricJson){await this.canvas.loadFromJSON(t.fabricJson);for(const t of this.canvas.getObjects()){const i=t._objectId;void 0!==i&&""!==i&&this.objectMap.set(i,t)}}null!=t.productImage&&""!==t.productImage&&(this.backgroundReady=s(this.canvas,t.productImage),await this.backgroundReady),this.canvas.renderAll()}async resetCanvas(){if(void 0!==this.canvas){this.canvas.discardActiveObject();for(const t of this.canvas.getObjects().slice())this.canvas.remove(t);this.objectMap.clear(),this.previewUrlMap.clear(),this.selectedObjectId=null,this.canvas.viewportTransform=[1,0,0,1,0,0],this.canvas.setDimensions({width:this.width,height:this.height}),this.canvas.backgroundColor="#ffffff",this.canvas.requestRenderAll()}}async exportImage(t="png",i=1){if(void 0===this.canvas)throw Error("Canvas not initialized");try{return this.canvas.toDataURL({multiplier:1,format:t,quality:i})}catch(t){if(t instanceof DOMException&&"SecurityError"===t.name)throw Error("Cannot export: product image is cross-origin. Use a CORS proxy or serve images from the same domain.");throw t}}async exportImageHighRes(t="png",i=1,e=3){if(void 0===this.canvas)throw Error("Canvas not initialized");this.canvas.discardActiveObject();const o=this.debug;let s;this.debug=!1,this.canvas.renderAll();try{s=this.canvas.toDataURL({multiplier:e,format:t,quality:i})}catch(t){if(this.debug=o,this.canvas.renderAll(),t instanceof DOMException&&"SecurityError"===t.name)throw Error("Cannot export: product image is cross-origin. Use a CORS proxy or serve images from the same domain.");throw t}const a=this.canvas.getWidth(),r=this.canvas.getHeight();return this.debug=o,this.canvas.renderAll(),{dataUrl:s,width:a,height:r}}async getObjects(){const t=[];for(const[i,e]of this.objectMap)t.push({id:i,type:e.type??"unknown"});return t}async updateText(t,i){if(void 0===this.canvas)return;const e=this.objectMap.get(t);void 0!==e&&"i-text"===e.type&&(e.set("text",i),this.canvas.renderAll(),this.emitStateChanged())}initCanvas(){if(void 0!==this.canvasEl){if(this.canvas=new l(this.canvasEl,{width:this.width,height:this.height,backgroundColor:"#ffffff"}),this.canvas.on("selection:created",(t=>{this.handleSelection(t.selected?.[0])})),this.canvas.on("selection:updated",(t=>{this.handleSelection(t.selected?.[0])})),this.canvas.on("selection:cleared",(()=>{this.selectedObjectId=null,this.selectedObjectType=null,this.wtpEditorObjectDeselected.emit()})),this.canvas.on("object:modified",(()=>{this.emitStateChanged()})),this.canvas.on("text:changed",(()=>{this.emitStateChanged()})),this.canvas.on("object:moving",(t=>{void 0!==t.target&&this.clampObjectToPrintArea(t.target)})),this.canvas.on("object:scaling",(t=>{void 0!==t.target&&this.clampObjectToPrintArea(t.target)})),this.canvas.on("after:render",(()=>this.drawDebugOverlay())),void 0!==this.initialState&&""!==this.initialState)try{const t=JSON.parse(this.initialState);this.loadState(t)}catch{}else void 0!==this.productImage&&""!==this.productImage&&(this.backgroundReady=s(this.canvas,this.productImage));this.wtpEditorReady.emit()}}drawDebugOverlay(){if(!this.debug||void 0===this.canvas||void 0===this.printArea)return;const t=this.canvas.getContext(),i=d(this.printArea,this.canvas.getWidth(),this.canvas.getHeight());t.save(),t.beginPath(),t.moveTo(i[0].x,i[0].y),t.lineTo(i[1].x,i[1].y),t.lineTo(i[2].x,i[2].y),t.lineTo(i[3].x,i[3].y),t.closePath(),t.fillStyle="rgba(37, 99, 235, 0.08)",t.fill(),t.strokeStyle="#2563eb",t.lineWidth=1.5,t.setLineDash([6,4]),t.stroke(),t.setLineDash([]);for(const e of i)t.beginPath(),t.arc(e.x,e.y,4,0,2*Math.PI),t.fillStyle="#2563eb",t.fill(),t.strokeStyle="#fff",t.lineWidth=1.5,t.stroke();const e=i.map((t=>t.x)),o=i.map((t=>t.y)),s=Math.min(...e),a=Math.max(...e),r=Math.min(...o),n=Math.max(...o);t.strokeStyle="rgba(220, 38, 38, 0.5)",t.lineWidth=1,t.setLineDash([3,3]),t.strokeRect(s,r,a-s,n-r),t.setLineDash([]),t.font="10px monospace",t.fillStyle="#2563eb";const h=["TL","TR","BR","BL"];for(let e=0;e<4;e++)t.fillText(h[e],i[e].x+6,i[e].y-6);t.restore()}getPrintAreaFrame(){if(void 0===this.printArea||void 0===this.canvas)return null;const t=d(this.printArea,this.canvas.getWidth(),this.canvas.getHeight()),[i,e,o,s]=t,a=(i.x+e.x+o.x+s.x)/4,r=(i.y+e.y+o.y+s.y)/4,n=(Math.hypot(e.x-i.x,e.y-i.y)+Math.hypot(o.x-s.x,o.y-s.y))/4,h=(Math.hypot(s.x-i.x,s.y-i.y)+Math.hypot(o.x-e.x,o.y-e.y))/4,c=Math.atan2(o.y-s.y,o.x-s.x);return{cx:a,cy:r,halfW:n,halfH:h,cos:Math.cos(c),sin:Math.sin(c)}}clampObjectToPrintArea(t){const i=this.getPrintAreaFrame();if(null===i)return;if(!0===t._isBackground)return;const{cx:e,cy:o,halfW:s,halfH:a,cos:r,sin:n}=i,h=(t.width??0)*(t.scaleX??1),d=(t.height??0)*(t.scaleY??1),c=(t.angle??0)*Math.PI/180-Math.atan2(n,r),l=Math.abs(Math.cos(c)),f=Math.abs(Math.sin(c));let p=(h*l+d*f)/2,b=(h*f+d*l)/2;if(p>s||b>a){const i=Math.min(s/Math.max(p,1),a/Math.max(b,1));t.set({scaleX:(t.scaleX??1)*i,scaleY:(t.scaleY??1)*i}),t.setCoords();const e=(t.width??0)*(t.scaleX??1),o=(t.height??0)*(t.scaleY??1);p=(e*l+o*f)/2,b=(e*f+o*l)/2}t.setCoords();const g=t.getCenterPoint(),u=g.x-e,w=g.y-o,v=u*r+w*n,x=-u*n+w*r,m=Math.max(-s+p,Math.min(s-p,v)),y=Math.max(-a+b,Math.min(a-b,x));m===v&&y===x||(t.set({left:(t.left??0)+(e+m*r-y*n-g.x),top:(t.top??0)+(o+m*n+y*r-g.y)}),t.setCoords())}handleSelection(t){if(void 0===t)return;const i=t._objectId;if(void 0!==i&&""!==i){if(this.selectedObjectId=i,this.selectedObjectType=t.type??null,"i-text"===t.type){const i=t;this.selectedFont=i.fontFamily??"Arial",this.selectedTextColor=i.fill??"#000000"}this.wtpEditorObjectSelected.emit({id:i,type:t.type??"unknown"})}}getObjectTransform(t){return{x:t.left??0,y:t.top??0,scaleX:t.scaleX??1,scaleY:t.scaleY??1,angle:t.angle??0}}buildEditorState(){const t=[],i=[];for(const[e,o]of this.objectMap)if("image"===o.type){const i=this.previewUrlMap.get(e);t.push({id:e,dataUrl:o.getSrc(),...void 0!==i?{previewDataUrl:i}:{},transform:this.getObjectTransform(o)})}else"i-text"===o.type&&i.push({id:e,text:o.text??"",fontFamily:o.fontFamily??"Arial",fontSize:o.fontSize??24,fill:o.fill??"#000000",transform:this.getObjectTransform(o)});return{fabricJson:void 0!==this.canvas?JSON.stringify(this.canvas.toJSON()):"",logos:t,texts:i,productImage:this.productImage??null,width:this.width,height:this.height}}emitStateChanged(){this.wtpEditorStateChanged.emit(this.buildEditorState())}handleAddText=()=>{this.addText(this.getLabels().defaultText,{fontFamily:this.selectedFont})};handleFontChange=t=>{if(this.selectedFont=t.target.value,void 0!==this.canvas&&null!==this.selectedObjectId){const t=this.objectMap.get(this.selectedObjectId);void 0!==t&&"i-text"===t.type&&(t.set("fontFamily",this.selectedFont),this.canvas.renderAll(),this.emitStateChanged())}};handleColorChange=t=>{if(this.selectedTextColor=t.target.value,void 0!==this.canvas&&null!==this.selectedObjectId){const t=this.objectMap.get(this.selectedObjectId);void 0!==t&&"i-text"===t.type&&(t.set("fill",this.selectedTextColor),this.canvas.renderAll(),this.emitStateChanged())}};handleDeleteSelected=()=>{null!==this.selectedObjectId&&(this.removeObject(this.selectedObjectId),this.selectedObjectId=null)};render(){const t=this.getLabels();return f("div",{key:"c9ef130a1fa731852990de6c3c926d0bc52e628d",class:"wtp-editor"},f("div",{key:"80f434e1784fdbe1ffc48686a2eb05e8db522dec",class:"toolbar"},f("button",{key:"8f03a61f63a605ca732f227e709db12f005888a3",class:"toolbar-btn",onClick:this.handleAddText,title:t.addTextTooltip},f("svg",{key:"990dad4cdb46e74fae7c887dde4416f5f16ac1fc",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},f("polyline",{key:"a1182b18466e0f31b95648543bd436e743a0bc09",points:"4 7 4 4 20 4 20 7"}),f("line",{key:"bb74bd40a58c5cb25a9842989bc7f5dbe94df684",x1:"9",y1:"20",x2:"15",y2:"20"}),f("line",{key:"be1eee4ddee7fadddfe00f694196861d582950e7",x1:"12",y1:"4",x2:"12",y2:"20"})),f("span",{key:"6d95e21682aa3a14de50c1b19c6f9ff01b0ba9e6"},t.addTextButton)),f("div",{key:"7180e61d20f4a5a6420dd313c78df5809a2e258e",class:"toolbar-separator"}),f("select",{key:"e44709cb401e316392dc178e2173dec0990cbadc",class:"font-select",onChange:this.handleFontChange,title:t.fontSelectTooltip},this.fonts.map((t=>f("option",{value:t,style:{fontFamily:t}},t)))),"i-text"===this.selectedObjectType&&f("input",{key:"1f369b84753de1f363e76d0b6815318055738b9c",class:"color-input",type:"color",value:this.selectedTextColor,onInput:this.handleColorChange,title:t.colorPickerTooltip}),f("div",{key:"abed11c63044bf6d27ab59ed7262e665ddf6ea32",class:"toolbar-separator"}),f("button",{key:"a7fa4df142fca5d1160a801731c3be41bddf6373",class:"toolbar-btn danger",onClick:this.handleDeleteSelected,disabled:null===this.selectedObjectId,title:t.deleteButtonTooltip},f("svg",{key:"a41f1fb373bdd2d1830b7627f6c3f9234a2a86ce",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},f("polyline",{key:"c731ac84aec857802f1ea1b85268c880c85ab254",points:"3 6 5 6 21 6"}),f("path",{key:"70a5b08147e64f940f55afd4680e9a8b5a8ec0ab",d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})))),f("div",{key:"1f04ba454f9c834a4554b018be6dba40607dbebc",class:"canvas-container"},f("canvas",{key:"4894f481c67e7021cdd575f276ac1b4c5d20951d",ref:t=>this.canvasEl=t})))}static get watchers(){return{productImage:[{onProductImageChange:0}],width:[{onSizeChange:0}],height:[{onSizeChange:0}],debug:[{onDebugChange:0}],printArea:[{onPrintAreaChange:0}]}}static get style(){return'*.sc-wtp-editor,*.sc-wtp-editor::before,*.sc-wtp-editor::after{box-sizing:border-box}.sc-wtp-editor-h{font-family:var(--wtp-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);color:var(--wtp-color-text, #1e293b);line-height:1.5}.wtp-editor.sc-wtp-editor{display:flex;flex-direction:column;border:1px solid var(--wtp-color-border, #e2e8f0);border-radius:12px;overflow:hidden;background:var(--wtp-color-bg, #ffffff)}.toolbar.sc-wtp-editor{display:flex;align-items:center;gap:8px;padding:8px 16px;border-bottom:1px solid var(--wtp-color-border, #e2e8f0);background:var(--wtp-color-bg-muted, #f8fafc);flex-wrap:wrap}.toolbar-btn.sc-wtp-editor{display:inline-flex;align-items:center;gap:8px;padding:8px 16px;font-family:var(--wtp-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);font-size:14px;font-weight:500;border-radius:8px;border:1px solid var(--wtp-color-border, #e2e8f0);background:var(--wtp-color-bg, #ffffff);color:var(--wtp-color-text, #1e293b);cursor:pointer;transition-property:all;transition-duration:250ms;transition-timing-function:ease}.toolbar-btn.sc-wtp-editor:hover{background:var(--wtp-color-bg-muted, #f8fafc)}.toolbar-btn.sc-wtp-editor:focus-visible{outline:2px solid var(--wtp-color-primary, #2563eb);outline-offset:2px}.toolbar-btn.sc-wtp-editor:disabled{opacity:0.5;cursor:not-allowed}.toolbar-btn.sc-wtp-editor{padding:4px 8px;font-size:12px}.toolbar-btn.sc-wtp-editor svg.sc-wtp-editor{width:16px;height:16px;flex-shrink:0}.toolbar-btn.danger.sc-wtp-editor:hover:not(:disabled){background:var(--wtp-color-error-light, #fee2e2);color:var(--wtp-color-error, #dc2626);border-color:var(--wtp-color-error, #dc2626)}.font-select.sc-wtp-editor{padding:4px 8px;font-family:var(--wtp-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);font-size:12px;border:1px solid var(--wtp-color-border, #e2e8f0);border-radius:8px;background:var(--wtp-color-bg, #ffffff);color:var(--wtp-color-text, #1e293b);cursor:pointer;transition-property:all;transition-duration:250ms;transition-timing-function:ease}.font-select.sc-wtp-editor:focus-visible{outline:2px solid var(--wtp-color-primary, #2563eb);outline-offset:2px}.color-input.sc-wtp-editor{width:32px;height:28px;padding:2px;border:1px solid var(--wtp-color-border, #e2e8f0);border-radius:8px;background:var(--wtp-color-bg, #ffffff);cursor:pointer;transition-property:all;transition-duration:250ms;transition-timing-function:ease}.color-input.sc-wtp-editor:focus-visible{outline:2px solid var(--wtp-color-primary, #2563eb);outline-offset:2px}.toolbar-separator.sc-wtp-editor{width:1px;height:24px;background:var(--wtp-color-border, #e2e8f0)}.toolbar-spacer.sc-wtp-editor{flex:1}.canvas-container.sc-wtp-editor{line-height:0;overflow:auto;background:repeating-conic-gradient(#e5e7eb 0% 25%, transparent 0% 50%) 50%/20px 20px}'}},[514,"wtp-editor",{width:[2],height:[2],productImage:[1,"product-image"],initialState:[1,"initial-state"],fonts:[16],printArea:[16],debug:[4],labels:[16],selectedObjectId:[32],selectedObjectType:[32],selectedFont:[32],selectedTextColor:[32],addLogo:[64],addText:[64],removeObject:[64],exportState:[64],loadState:[64],resetCanvas:[64],exportImage:[64],exportImageHighRes:[64],getObjects:[64],updateText:[64]},void 0,{productImage:[{onProductImageChange:0}],width:[{onSizeChange:0}],height:[{onSizeChange:0}],debug:[{onDebugChange:0}],printArea:[{onPrintAreaChange:0}]}]);function g(){"undefined"!=typeof customElements&&["wtp-editor"].forEach((i=>{"wtp-editor"===i&&(customElements.get(t(i))||customElements.define(t(i),b))}))}g();const u=b,w=g;export{u as WtpEditor,w as defineCustomElement}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface WtpLogoRenderer extends Components.WtpLogoRenderer, HTMLElement {}
|
|
4
|
+
export const WtpLogoRenderer: {
|
|
5
|
+
prototype: WtpLogoRenderer;
|
|
6
|
+
new (): WtpLogoRenderer;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t,c as e,H as o,d as r,u as n,l as s,k as i,h as a,p as l}from"./p-5qCsRzlt.js";function h(t){return new Promise(((e,o)=>{const r=new Image;r.onload=()=>e(r),r.onerror=()=>o(Error("Failed to load image: "+t.slice(0,80))),r.src=t}))}function c(t,e,o,r){const n=Math.min(t/o,e/r);return{fittedW:o*n,fittedH:r*n}}function d(t,e,o){return{left:t.x-e/2,top:t.y-o/2}}function g(t){if(!t.startsWith("data:image/svg+xml"))return null;let e;const o=t.indexOf(";base64,");if(-1!==o)e=atob(t.slice(o+8));else{const o=t.indexOf(",");if(-1===o)return null;e=decodeURIComponent(t.slice(o+1))}const r=e.match(/<svg[^>]*>/i);if(null===r)return null;const n=r[0],s=n.match(/viewBox=["']([^"']+)["']/);if(null!==s){const t=s[1].trim().split(/[\s,]+/),e=parseFloat(t[2]),o=parseFloat(t[3]);if(e>0&&o>0)return{width:e,height:o}}const i=n.match(/\bwidth=["']([^"']+)["']/),a=n.match(/\bheight=["']([^"']+)["']/);if(null!==i&&null!==a){const t=parseFloat(i[1]),e=parseFloat(a[1]);if(t>0&&e>0)return{width:t,height:e}}return null}const p=e(class extends o{constructor(t){super(),!1!==t&&this.__registerHost(),this.wtpRenderComplete=r(this,"wtpRenderComplete"),this.wtpRenderError=r(this,"wtpRenderError")}get el(){return this}productImage;width=600;height=400;logos=[];backgroundColor="#ffffff";printArea;wtpRenderComplete;wtpRenderError;layers=[];containerWidth=0;containerHeight=0;productImg;componentWillLoad(){this.computeLayout()}onProductImageChange(){this.computeLayout()}onLogosChange(){this.computeLayout()}onPrintAreaChange(){this.computeLayout()}onSizeChange(){this.computeLayout()}onBackgroundColorChange(){this.emitRenderComplete()}async exportImage(t="png",e=1){const o=this.containerWidth||this.width,r=this.containerHeight||this.height,n=this.layers.map((t=>({img:t.exportImg,naturalWidth:t.naturalWidth,naturalHeight:t.naturalHeight,left:t.left,top:t.top,scaleX:t.scaleX,scaleY:t.scaleY,angle:t.angle,skewX:t.skewX,skewY:t.skewY})));return function(t,e,o,r,n,s="png",i=1){const a=document.createElement("canvas");a.width=t,a.height=e;const l=a.getContext("2d");if(l.fillStyle=o,l.fillRect(0,0,t,e),void 0!==r){const{fittedW:o,fittedH:n}=c(t,e,r.naturalWidth,r.naturalHeight);l.drawImage(r,(t-o)/2,(e-n)/2,o,n)}for(const t of n){l.save(),l.translate(t.left+t.naturalWidth/2,t.top+t.naturalHeight/2),l.rotate(t.angle*Math.PI/180);const e=Math.tan(t.skewX*Math.PI/180);l.transform(1,Math.tan(t.skewY*Math.PI/180),e,1,0,0),l.scale(t.scaleX,t.scaleY),l.drawImage(t.img,-t.naturalWidth/2,-t.naturalHeight/2,t.naturalWidth,t.naturalHeight),l.restore()}return a.toDataURL("image/"+s,i)}(o,r,this.backgroundColor,this.productImg,n,t,e)}async computeLayout(){try{let t=this.width,e=this.height;if(void 0!==this.productImage&&""!==this.productImage){const o=await h(this.productImage);this.productImg=o;const{fittedW:r,fittedH:n}=c(this.width,this.height,o.naturalWidth,o.naturalHeight);t=r,e=n}else this.productImg=void 0;this.containerWidth=t,this.containerHeight=e;const o=[];for(const r of this.logos){const i=r.previewDataUrl??r.dataUrl;if(void 0!==r.transform){const t=await h(r.dataUrl),e=t.naturalWidth,n=t.naturalHeight,{left:s,top:a}=d(r.transform,e,n);o.push({id:r.id,src:i,exportImg:t,naturalWidth:e,naturalHeight:n,left:s,top:a,scaleX:r.transform.scaleX,scaleY:r.transform.scaleY,angle:r.transform.angle,skewX:r.transform.skewX??0,skewY:r.transform.skewY??0})}else if(void 0!==this.printArea){let c,p,u=i;if(void 0!==this.printArea.bulge&&0!==this.printArea.bulge){const i=Math.round(2*Math.max(t,e)),{dataUrl:g}=n(r.dataUrl,i),f=await h(g);c=f.naturalWidth,p=f.naturalHeight;const w=a(c,p,this.printArea,t,e),[m,b,C,k]=l(this.printArea,t,e),y=Math.hypot(k.x-m.x,k.y-m.y),x=Math.hypot(C.x-b.x,C.y-b.y),v=s(f,this.printArea.bulge,(y+x)/2,w.scaleX);u=v.toDataURL("image/png"),c=v.width,p=v.height;const I=await h(u),{left:M,top:W}=d(w,c,p);o.push({id:r.id,src:u,exportImg:I,naturalWidth:c,naturalHeight:p,left:M,top:W,scaleX:w.scaleX,scaleY:w.scaleY,angle:w.angle,skewX:0,skewY:0})}else{const n=g(r.dataUrl);if(null!==n)c=n.width,p=n.height;else{const t=await h(r.dataUrl);c=t.naturalWidth,p=t.naturalHeight}const s=a(c,p,this.printArea,t,e),i=await h(u),{left:l,top:f}=d(s,c,p);o.push({id:r.id,src:u,exportImg:i,naturalWidth:c,naturalHeight:p,left:l,top:f,scaleX:s.scaleX,scaleY:s.scaleY,angle:s.angle,skewX:0,skewY:0})}}}this.layers=o,this.emitRenderComplete()}catch(t){this.wtpRenderError.emit({message:t instanceof Error?t.message:"Unknown render error"})}}async emitRenderComplete(){try{const t=await this.exportImage("png");this.wtpRenderComplete.emit({dataUrl:t})}catch{}}render(){return i("div",{key:"3a720dae0cd0ab070a90b1f20dff9adb699b0ba5",class:"wtp-logo-renderer",style:{width:(this.containerWidth||this.width)+"px",height:(this.containerHeight||this.height)+"px",backgroundColor:this.backgroundColor}},void 0!==this.productImage&&""!==this.productImage&&i("img",{key:"88b50d0a4fd320a935bd7008ef3ddfee1644cbab",class:"product-bg",src:this.productImage,alt:""}),this.layers.map((t=>i("img",{key:t.id,class:"logo-layer",src:t.src,alt:"",style:{position:"absolute",left:t.left+"px",top:t.top+"px",width:t.naturalWidth+"px",height:t.naturalHeight+"px",transformOrigin:"center",transform:`rotate(${t.angle}deg) skewX(${t.skewX}deg) skewY(${t.skewY}deg) scale(${t.scaleX}, ${t.scaleY})`}}))))}static get watchers(){return{productImage:[{onProductImageChange:0}],logos:[{onLogosChange:0}],printArea:[{onPrintAreaChange:0}],width:[{onSizeChange:0}],height:[{onSizeChange:0}],backgroundColor:[{onBackgroundColorChange:0}]}}static get style(){return'*.sc-wtp-logo-renderer,*.sc-wtp-logo-renderer::before,*.sc-wtp-logo-renderer::after{box-sizing:border-box}.sc-wtp-logo-renderer-h{font-family:var(--wtp-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);color:var(--wtp-color-text, #1e293b);line-height:1.5}.wtp-logo-renderer.sc-wtp-logo-renderer{display:inline-block;position:relative;overflow:hidden;border:1px solid var(--wtp-color-border, #e2e8f0);border-radius:8px}.product-bg.sc-wtp-logo-renderer{display:block;width:100%;height:100%;object-fit:contain}.logo-layer.sc-wtp-logo-renderer{pointer-events:none}'}},[514,"wtp-logo-renderer",{productImage:[1,"product-image"],width:[2],height:[2],logos:[16],backgroundColor:[1,"background-color"],printArea:[1040],layers:[32],containerWidth:[32],containerHeight:[32],exportImage:[64]},void 0,{productImage:[{onProductImageChange:0}],logos:[{onLogosChange:0}],printArea:[{onPrintAreaChange:0}],width:[{onSizeChange:0}],height:[{onSizeChange:0}],backgroundColor:[{onBackgroundColorChange:0}]}]);function u(){"undefined"!=typeof customElements&&["wtp-logo-renderer"].forEach((e=>{"wtp-logo-renderer"===e&&(customElements.get(t(e))||customElements.define(t(e),p))}))}u();const f=p,w=u;export{f as WtpLogoRenderer,w as defineCustomElement}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface WtpLogoUpload extends Components.WtpLogoUpload, HTMLElement {}
|
|
4
|
+
export const WtpLogoUpload: {
|
|
5
|
+
prototype: WtpLogoUpload;
|
|
6
|
+
new (): WtpLogoUpload;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e,c as t,H as n,d as r,m as i,n as o,k as a}from"./p-5qCsRzlt.js";import{D as s,a as c}from"./p-D8pVJRuX.js";import{a as u}from"./p-Bn9gR_8e.js";let f=class{constructor(e){if(function(e){return"object"!=typeof e||void 0===e.length||void 0===e.readUInt8||void 0===e.readUInt16LE||void 0===e.readUInt16BE||void 0===e.readUInt32LE||void 0===e.readUInt32BE||void 0===e.readInt32LE||void 0===e.readInt32BE}(e))throw Error("DataView: Passed buffer type is unsupported.");this.buffer=e,this.byteLength=this.buffer.length}getUint8(e){return this.buffer.readUInt8(e)}getUint16(e,t){return t?this.buffer.readUInt16LE(e):this.buffer.readUInt16BE(e)}getUint32(e,t){return t?this.buffer.readUInt32LE(e):this.buffer.readUInt32BE(e)}getInt32(e,t){return t?this.buffer.readInt32LE(e):this.buffer.readInt32BE(e)}};function l(e,t,n){try{return new DataView(e,t,n)}catch(r){return new f(e,t,n)}}function d(e,t,n){const r=[];for(let i=0;i<n&&t+i<e.byteLength;i++)r.push(e.getUint8(t+i));return h(r)}function p(e,t){const n=[];let r=0;for(;t+r<e.byteLength;){const i=e.getUint8(t+r);if(0===i)break;n.push(i),r++}return h(n)}function m(e,t,n){const r=[];for(let i=0;i<n&&t+i<e.byteLength;i+=2)r.push(e.getUint16(t+i));return 0===r[r.length-1]&&r.pop(),h(r)}function g(e,t){const n=e.getUint8(t);return[n,d(e,t+1,n)]}function h(e){return e.map((e=>String.fromCharCode(e))).join("")}function b(){for(let e=1;e<arguments.length;e++)for(const t in arguments[e])arguments[0][t]=arguments[e][t];return arguments[0]}function v(e,t,n){let r=!1;Object.defineProperty(e,t,{get:()=>(r||(r=!0,Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:n.apply(e),writable:!0})),e[t]),configurable:!0,enumerable:!0})}function y(e){return"undefined"!=typeof btoa?"string"==typeof e?btoa(e):btoa(Array.prototype.reduce.call(new Uint8Array(e),((e,t)=>e+String.fromCharCode(t)),"")):"undefined"!=typeof Buffer?void 0!==Buffer.from?Buffer.from(e).toString("base64"):new Buffer(e).toString("base64"):void 0}function w(e,t){return Array(t+1).join(e)}const x=void 0,S="brotli";function I(e,t,n,r="string",i){const o=function(e){return e&&"number"==typeof e.maxDecompressedSize?e.maxDecompressedSize:134217728}(i);if(i&&t!==x){const a=i[0===t?"deflate":"brotli"];if("function"==typeof a){const t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);return Promise.resolve(a(t)).then((e=>function(e){return e&&"number"==typeof e.byteLength?e.byteLength:0}(e)>o?k(o):"dataview"===r?e instanceof DataView?e:e instanceof ArrayBuffer?new DataView(e):new DataView(e.buffer,e.byteOffset,e.byteLength):new TextDecoder(n).decode(e)))}}if(0===t&&"function"==typeof DecompressionStream)return C(e,"deflate",o).then((e=>P(e,r,n)));if(t===S){if("function"==typeof DecompressionStream)try{return C(e,"brotli",o).then((e=>P(e,r,n)))}catch(e){}return Promise.reject("Brotli decompression is not supported in this environment. Pass in a brotli decompression function via the decompress option.")}if(void 0!==t)return Promise.reject(`Unknown compression method ${t}.`);if("string"===r)try{return new TextDecoder(n).decode(e)}catch(t){const n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);return Array.from(n,(e=>String.fromCharCode(e))).join("")}return e}function C(e,t,n){const r=new DecompressionStream(t),i=new Blob([e]).stream().pipeThrough(r).getReader(),o=[];let a=0;return function e(){return i.read().then((({done:t,value:r})=>t?function(e,t){const n=new Uint8Array(t);let r=0;for(let t=0;t<e.length;t++)n.set(e[t],r),r+=e[t].byteLength;return n.buffer}(o,a):(a+=r.byteLength,a>n?i.cancel().then((()=>k(n))):(o.push(r),e()))))}()}function P(e,t,n){return"dataview"===t?new DataView(e):new TextDecoder(n).decode(e)}function k(e){return void 0!==console&&"function"==typeof console.warn&&console.warn(`ExifReader: skipped a compressed metadata block that would exceed the maximum decompressed size of ${e} bytes.`),Promise.reject(`Decompressed metadata exceeded the maximum allowed size of ${e} bytes.`)}var T={USE_FILE:!0,USE_JFIF:!0,USE_PNG_FILE:!0,USE_EXIF:!0,USE_IPTC:!0,USE_XMP:!0,USE_ICC:!0,USE_MPF:!0,USE_PHOTOSHOP:!0,USE_THUMBNAIL:!0,USE_TIFF:!0,USE_JPEG:!0,USE_PNG:!0,USE_HEIC:!0,USE_AVIF:!0,USE_JXL:!0,USE_WEBP:!0,USE_GIF:!0,USE_MAKER_NOTES:!0};function A(e){return e.map((e=>String.fromCharCode(e))).join("")}function D(e){if(e.length>=8){const t=A(e.slice(0,8));if("ASCII\0\0\0"===t)return A(e.slice(8));if("JIS\0\0\0\0\0"===t)return"[JIS encoded text]";if("UNICODE\0"===t)return"[Unicode encoded text]";if("\0\0\0\0\0\0\0\0"===t){const t=A(e.slice(8));return/[\x20-\x7e]/.test(t)?t:"[Undefined encoding]"}}return"Undefined"}function O(e){return e[0][0]/e[0][1]+e[1][0]/e[1][1]/60+e[2][0]/e[2][1]/3600}function R(e,t,n,r,i,o,a,s){if(void 0===s)return[];const c=[];let u=n.items;for(let n=0;n<s;n++){const n={extents:[]};n.itemId=F(e,u,t),u+=r.item.itemId,n.constructionMethod=1===t||2===t?15&e.getUint16(u):void 0,u+=r.item.constructionMethod,n.dataReferenceIndex=e.getUint16(u),u+=r.item.dataReferenceIndex,n.baseOffset=U(e,u,r.item.baseOffset),u+=r.item.baseOffset,n.extentCount=e.getUint16(u),u+=r.item.extentCount;for(let s=0;s<n.extentCount;s++){const s={};s.extentIndex=M(e,t,u,a),u+=r.item.extent.extentIndex,s.extentOffset=U(e,u,i),u+=r.item.extent.extentOffset,s.extentLength=U(e,u,o),u+=r.item.extent.extentLength,n.extents.push(s)}c.push(n)}return c}function F(e,t,n){return n<2?e.getUint16(t):2===n?e.getUint32(t):void 0}function M(e,t,n,r){if((1===t||2===t)&&r>0)return U(e,n,r)}function U(e,t,n){return 4===n?e.getUint32(t):8===n?(console.warn("This file uses an 8-bit offset which is currently not supported by ExifReader. Contact the maintainer to get it fixed."),function(e,t){return e.getUint32(t+4)}(e,t)):0}const E=1165519206,N=1835625829;function G(e,t){const{length:n,contentOffset:r}=L(e,t);if(n<8)return;const i=e.getUint32(t+4);if(1718909296===i)return function(e,t,n){return{type:"ftyp",majorBrand:d(e,t,4),length:n}}(e,r,n);if(1768977008===i)return function(e,t,n,r){return{type:"iprp",subBoxes:z(e,n,r-(n-t)),length:r}}(e,t,r,n);if(1768973167===i)return function(e,t,n,r){return{type:"ipco",properties:z(e,n,r-(n-t)),length:r}}(e,t,r,n);if(1668246642===i)return function(e,t,n){return{type:"colr",icc:V(e,t),length:n}}(e,r,n);const o=e.getUint8(r);return 1835365473===i?function(e,t,n,r){return{type:"meta",subBoxes:z(e,n+3,r-(n+3-t)),length:r}}(e,t,r+1,n):1768714083===i?function(e,t,n,r){const{offsets:i,sizes:o}=function(e,t){const n={item:{dataReferenceIndex:2,extentCount:2,extent:{}}};e<2?(n.itemCount=2,n.item.itemId=2):2===e&&(n.itemCount=4,n.item.itemId=4),n.item.constructionMethod=1===e||2===e?2:0;const r={offsetSize:t,lengthSize:t,baseOffsetSize:t+1,indexSize:t+1};return r.itemCount=t+2,r.items=r.itemCount+n.itemCount,r.item={itemId:0},r.item.constructionMethod=r.item.itemId+n.item.itemId,r.item.dataReferenceIndex=r.item.constructionMethod+n.item.constructionMethod,{offsets:r,sizes:n}}(t,n+3),a=e.getUint8(i.offsetSize)>>4;o.item.extent.extentOffset=a;const s=15&e.getUint8(i.lengthSize);o.item.extent.extentLength=s;const c=e.getUint8(i.baseOffsetSize)>>4;o.item.baseOffset=c;const u=function(e,t,n){if(1===n||2===n)return 15&e.getUint8(t)}(e,i.indexSize,t);o.item.extent.extentIndex=void 0!==u?u:0;const f=function(e,t,n){return n<2?e.getUint16(t):2===n?e.getUint32(t):void 0}(e,i.itemCount,t);return{type:"iloc",items:R(e,t,i,o,a,s,u,f),length:r}}(e,o,r+1,n):1768517222===i?function(e,t,n,r,i){const{offsets:o}=function(e,t){const n={entryCount:t+3},r={};return r.entryCount=0===e?2:4,n.itemInfos=n.entryCount+r.entryCount,{offsets:n}}(n,r);return{type:"iinf",itemInfos:z(e,o.itemInfos,i-(o.itemInfos-t)),length:i}}(e,t,o,r+1,n):1768842853===i?function(e,t,n,r,i){r+=3;const o={type:"infe",length:i};return 0!==n&&1!==n||(o.itemId=e.getUint16(r),o.itemProtectionIndex=e.getUint16(r+=2),o.itemName=p(e,r+=2),r+=o.itemName.length+1),n>=2&&(2===n?(o.itemId=e.getUint16(r),r+=2):3===n&&(o.itemId=e.getUint32(r),r+=4),o.itemProtectionIndex=e.getUint16(r),o.itemType=e.getUint32(r+=2),o.itemName=p(e,r+=4),r+=o.itemName.length+1,o.itemType===N?(o.contentType=p(e,r),t+i>(r+=o.contentType.length+1)&&(o.contentEncoding=p(e,r),r+=o.contentEncoding.length+1)):1970432288===o.itemType&&(o.itemUri=p(e,r),r+=o.itemUri.length+1)),o}(e,t,o,r+1,n):{type:void 0,length:n}}function L(e,t){const n=e.getUint32(t);return function(e){return 0===e}(n)?{length:e.byteLength-t,contentOffset:t+4+4}:function(e){return 1===e}(n)&&function(e,t){return 0===e.getUint32(t+8)}(e,t)?{length:e.getUint32(t+12),contentOffset:t+4+4+8}:{length:n,contentOffset:t+4+4}}function B(e){if(T.USE_EXIF||T.USE_XMP||T.USE_ICC){const t={},n=function(e){let t=0;for(;t+4+4<=e.byteLength;){const n=G(e,t);if(void 0===n)break;if("meta"===n.type)return n;t+=n.length}}(e);return n?(T.USE_EXIF&&(t.tiffHeaderOffset=function(e,t){try{const n=function(e){return e.subBoxes.find((e=>"iinf"===e.type)).itemInfos.find((e=>e.itemType===E))}(t).itemId,r=j(t,n);return _(e,r.baseOffset+r.extents[0].extentOffset)}catch(e){return}}(e,n)),T.USE_XMP&&(t.xmpChunks=function(e){try{const t=function(e){return e.subBoxes.find((e=>"iinf"===e.type)).itemInfos.find((e=>e.itemType===N&&"application/rdf+xml"===e.contentType))}(e).itemId,n=j(e,t),r=j(e,t).extents[0];return[{dataOffset:n.baseOffset+r.extentOffset,length:r.extentLength}]}catch(e){return}}(n)),T.USE_ICC&&(t.iccChunks=function(e){try{const t=e.subBoxes.find((e=>"iprp"===e.type)).subBoxes.find((e=>"ipco"===e.type)).properties.find((e=>"colr"===e.type)).icc;if(t)return[t]}catch(e){}}(n)),t.hasAppMarkers=void 0!==t.tiffHeaderOffset||void 0!==t.xmpChunks||void 0!==t.iccChunks,t):{hasAppMarkers:!1}}return{}}function j(e,t){return e.subBoxes.find((e=>"iloc"===e.type)).items.find((e=>e.itemId===t))}function _(e,t){return t+4+e.getUint32(t)}function V(e,t){const n=d(e,t,4);if("prof"===n||"rICC"===n)return{offset:t+4,length:e.getUint32(t+4),chunkNumber:1,chunksTotal:1}}function z(e,t,n){const r=[E,N],i=[];let o=t;for(;o<t+n;){const t=G(e,o);if(void 0===t)break;void 0===t.type||void 0!==t.itemType&&-1===r.indexOf(t.itemType)||i.push(t),o+=t.length}return i}const H=18761,$=19789;var W=$,X=H,K=function(e,t){if(e.getUint16(t)===H)return H;if(e.getUint16(t)===$)return $;throw Error("Illegal byte order value. Faulty image.")},Y=function(e){return!!e&&e.byteLength>=4&&function(e){const t=e.getUint16(0)===X;return 42===e.getUint16(2,t)}(e)},q=function(){return T.USE_EXIF?{hasAppMarkers:!0,tiffHeaderOffset:0}:{}},J=function(e){return!!e&&e.byteLength>=Q&&e.getUint16(0)===ee},Z=function(e){let t,n,r,i,o,a,s,c,u,f,l,d,p,m=te,g=0;for(;m+ne+5<=e.byteLength;){if(T.USE_FILE&&Ue(e,m))t=e.getUint16(m+re),n=m+re;else if(T.USE_FILE&&Ee(e,m))t=e.getUint16(m+re),r=m+re;else if(T.USE_JFIF&&Le(e,m))t=e.getUint16(m+re),i=m+ie;else if(T.USE_EXIF&&Be(e,m)){t=e.getUint16(m+re),g++;const n=m+oe;if(1===g)l=n,d=m,p=t;else if(2===g){f=Xe(e,d,p,l);const r=Xe(e,m,t,n);r>f&&(f=r,l=n,d=m,p=t)}else{const r=Xe(e,m,t,n);r>f&&(f=r,l=n,d=m,p=t)}o=l}else if(T.USE_XMP&&je(e,m))s||(s=[]),t=e.getUint16(m+re),s.push(Ve(m,t));else if(T.USE_XMP&&_e(e,m))s||(s=[]),t=e.getUint16(m+re),s.push(ze(m,t));else if(T.USE_IPTC&&He(e,m))t=e.getUint16(m+re),a=m+ae;else if(T.USE_ICC&&Ne(e,m)){t=e.getUint16(m+re);const n=m+ue,r=t-(ue-re),i=e.getUint8(m+de),o=e.getUint8(m+pe);c||(c=[]),c.push({offset:n,length:r,chunkNumber:i,chunksTotal:o})}else if(T.USE_MPF&&Ge(e,m))t=e.getUint16(m+re),u=m+fe;else{if(!$e(e,m)){if(We(e,m)){m++;continue}break}t=e.getUint16(m+re)}m+=re+t}return g>1&&function(e){void 0!==console&&"function"==typeof console.warn&&console.warn(`ExifReader: Found ${e} Exif segments (APP1). Will pick the best candidate segment.`)}(g),{hasAppMarkers:m>te,fileDataOffset:n||r,jfifDataOffset:i,tiffHeaderOffset:o,iptcDataOffset:a,xmpChunks:s,iccChunks:c,mpfDataOffset:u}};const Q=2,ee=65496,te=2,ne=4,re=2,ie=2,oe=10,ae=18,se=33,ce=79,ue=18,fe=8,le="ICC_PROFILE\0",de=ne+le.length,pe=de+1,me="MPF\0",ge=65472,he=65474,be=65476,ve=65499,ye=65501,we=65498,xe=65504,Se=65505,Ie=65506,Ce=65517,Pe=65519,ke=65534,Te=65535,Ae="JFIF",De="Exif",Oe="http://ns.adobe.com/xap/1.0/\0",Re="http://ns.adobe.com/xmp/extension/\0",Fe="Photoshop 3.0",Me="8BIM";function Ue(e,t){return e.getUint16(t)===ge}function Ee(e,t){return e.getUint16(t)===he}function Ne(e,t){const n=le.length;return e.getUint16(t)===Ie&&d(e,t+ne,n)===le}function Ge(e,t){const n=me.length;return e.getUint16(t)===Ie&&d(e,t+ne,n)===me}function Le(e,t){const n=Ae.length;return e.getUint16(t)===xe&&d(e,t+ne,n)===Ae&&0===e.getUint8(t+ne+n)}function Be(e,t){const n=De.length;return e.getUint16(t)===Se&&d(e,t+ne,n)===De&&0===e.getUint8(t+ne+n)}function je(e,t){return e.getUint16(t)===Se&&function(e,t){return d(e,t+ne,Oe.length)===Oe}(e,t)}function _e(e,t){return e.getUint16(t)===Se&&function(e,t){return d(e,t+ne,Re.length)===Re}(e,t)}function Ve(e,t){return{dataOffset:e+se,length:t-(se-re)}}function ze(e,t){return{dataOffset:e+ce,length:t-(ce-re)}}function He(e,t){const n=Fe.length,r=Me.length,i=t+ne+n+1;return e.getUint16(t)===Ce&&d(e,t+ne,n)===Fe&&0===e.getUint8(t+ne+n)&&d(e,i,r)===Me}function $e(e,t){const n=e.getUint16(t);return n>=xe&&n<=Pe||n===ke||n===ge||n===he||n===be||n===ve||n===ye||n===we}function We(e,t){return e.getUint16(t)===Te}function Xe(e,t,n,r){const i=function(e,t,n){try{if(t+8>n)return;const r=e.getUint16(t+0),i=r===X;if(!i&&r!==W)return;if(42!==e.getUint16(t+2,i))return;const o=t+e.getUint32(t+4,i);if(o+2>n)return;const a=e.getUint16(o,i);return{ifdEntries:a,isValid:o+(2+12*a+4)<=n&&a>0}}catch(e){return}}(e,r,t+re+n);if(!i)return 0;const o=Number.isInteger(i.ifdEntries)?i.ifdEntries:0;return(i.isValid?1e9:0)+1e6*o+n}var Ke=function(e){return!!e&&d(e,0,qe.length)===qe},Ye=function(e,t){const n={hasAppMarkers:!1};let r=qe.length;for(;r+Je+Ze<=e.byteLength;){if(T.USE_PNG_FILE&&ft(e,r))n.hasAppMarkers=!0,n.pngHeaderOffset=r+tt;else if(T.USE_XMP&<(e,r)){const t=ht(e,r);void 0!==t&&(n.hasAppMarkers=!0,n.xmpChunks=[{dataOffset:t,length:e.getUint32(r+Qe)-(t-(r+tt))}])}else if(dt(e,r,t)){n.hasAppMarkers=!0;const t=d(e,r+et,Ze);n.pngTextChunks||(n.pngTextChunks=[]),n.pngTextChunks.push({length:e.getUint32(r+Qe),type:t,offset:r+tt})}else if(pt(e,r))n.hasAppMarkers=!0,n.tiffHeaderOffset=r+tt;else if(T.USE_ICC&&t&&mt(e,r)){n.hasAppMarkers=!0;const t=e.getUint32(r+Qe),i=r+tt,{profileName:o,compressionMethod:a,compressedProfileOffset:s}=bt(e,i);n.iccChunks||(n.iccChunks=[]),n.iccChunks.push({offset:s,length:t-(s-i),chunkNumber:1,chunksTotal:1,profileName:o,compressionMethod:a})}else gt(e,r)&&(n.hasAppMarkers=!0,n.pngChunkOffsets||(n.pngChunkOffsets=[]),n.pngChunkOffsets.push(r+Qe));r+=e.getUint32(r+Qe)+Je+Ze+4}return n};const qe="PNG\r\n\n",Je=4,Ze=4,Qe=0,et=Je,tt=Je+Ze,nt="XML:com.adobe.xmp\0",rt="tEXt",it="iTXt",ot="zTXt",at="pHYs",st="tIME",ct="eXIf",ut="iCCP";function ft(e,t){return"IHDR"===d(e,t+et,Ze)}function lt(e,t){return d(e,t+et,Ze)===it&&d(e,t+tt,nt.length)===nt}function dt(e,t,n){const r=d(e,t+et,Ze);return r===rt||r===it||r===ot&&n}function pt(e,t){return d(e,t+et,Ze)===ct}function mt(e,t){return d(e,t+et,Ze)===ut}function gt(e,t){const n=[at,st],r=d(e,t+et,Ze);return n.includes(r)}function ht(e,t){t+=tt+nt.length+1+1;let n=0;for(;n<2&&t<e.byteLength;)0===e.getUint8(t)&&n++,t++;if(!(n<2))return t}function bt(e,t){const n=p(e,t);return{profileName:n,compressionMethod:e.getUint8(t+=n.length+1),compressedProfileOffset:t+=1}}var vt=function(e){if(!e)return!1;const t=["heic","heix","hevc","hevx","heim","heis","hevm","hevs","mif1"];try{const n=G(e,0);return n&&-1!==t.indexOf(n.majorBrand)}catch(e){return!1}},yt=function(e){return B(e)},wt=function(e){if(!e)return!1;try{const t=G(e,0);return t&&"avif"===t.majorBrand}catch(e){return!1}},xt=function(e){return B(e)},St=function(e){try{return function(e){if(!e||e.byteLength<Ct.length)return!1;for(let t=0;t<Ct.length;t++)if(e.getUint8(t)!==Ct[t])return!1;return!0}(e)||Et(e)}catch(e){return!1}},It=function(e){let t,n,r,i,o,a=0;for(Et(e)&&(o=0);a+Tt<=e.byteLength;){const{length:s,contentOffset:c}=L(e,a);if(s<Tt)break;const u=e.getUint32(a+kt);if(T.USE_EXIF&&u===At)try{t=_(e,c)}catch(e){}if(T.USE_XMP&&u===Dt&&(n=[{dataOffset:c,length:s-(c-a)}]),u===Rt&&void 0===o&&(o=c),u===Ft&&void 0===o&&c+Mt<=e.byteLength&&!(2147483647&e.getUint32(c))&&(o=c+Mt),u===Ot&&c+Ut<=e.byteLength){const o=e.getUint32(c),u=c+Ut,f=s-(u-a);T.USE_EXIF&&o===At&&void 0===t&&!r&&(r={dataOffset:u,length:f}),!T.USE_XMP||o!==Dt||n||i||(i={dataOffset:u,length:f})}a+=s}return{hasAppMarkers:void 0!==t||void 0!==n||void 0!==r||void 0!==i||void 0!==o,tiffHeaderOffset:t,xmpChunks:n,brobExifChunk:r,brobXmpChunk:i,jxlCodestreamOffset:o}};const Ct=[0,0,0,12,74,88,76,32,13,10,135,10],Pt=[255,10],kt=4,Tt=8,At=1165519206,Dt=2020437024,Ot=1651666786,Rt=1786276963,Ft=1786276976,Mt=4,Ut=4;function Et(e){return!(!e||e.byteLength<Pt.length)&&e.getUint8(0)===Pt[0]&&e.getUint8(1)===Pt[1]}var Nt=function(e){return!!e&&"RIFF"===d(e,0,4)&&"WEBP"===d(e,8,4)},Gt=function(e){let t,n,r,i,o=12,a=!1;for(;o+8<e.byteLength;){const s=d(e,o,4),c=e.getUint32(o+4,!0);T.USE_EXIF&&"EXIF"===s?(a=!0,t="Exif\0\0"===d(e,o+8,6)?o+8+6:o+8):T.USE_XMP&&"XMP "===s?(a=!0,n=[{dataOffset:o+8,length:c}]):T.USE_ICC&&"ICCP"===s?(a=!0,r=[{offset:o+8,length:c,chunkNumber:1,chunksTotal:1}]):"VP8X"===s&&(a=!0,i=o+8),o+=8+(c%2==0?c:c+1)}return{hasAppMarkers:a,tiffHeaderOffset:t,xmpChunks:n,iccChunks:r,vp8xChunkOffset:i}},Lt=function(e){return!!e&&_t.includes(d(e,0,jt))},Bt=function(){return{gifHeaderOffset:0}};const jt=6,_t=["GIF87a","GIF89a"];var Vt=function(e){return!!e&&d(e,Ht,$t.length)===$t},zt=function(e){const t=[];return t.push({dataOffset:Ht,length:e.byteLength}),{xmpChunks:t}};const Ht=0,$t="<?xpacket begin";var Wt=function(e,t){if(T.USE_TIFF&&Y(e))return Xt(q(),"tiff","TIFF");if(T.USE_JPEG&&J(e))return Xt(Z(e),"jpeg","JPEG");if(T.USE_PNG&&Ke(e))return Xt(Ye(e,t),"png","PNG");if(T.USE_HEIC&&vt(e))return Xt(yt(e),"heic","HEIC");if(T.USE_AVIF&&wt(e))return Xt(xt(e),"avif","AVIF");if(T.USE_JXL&&St(e))return Xt(It(e),"jxl","JPEG XL");if(T.USE_WEBP&&Nt(e))return Xt(Gt(e),"webp","WebP");if(T.USE_GIF&&Lt(e))return Xt(Bt(e),"gif","GIF");if(T.USE_XMP&&Vt(e))return Xt(zt(e),"xml","XML");throw Error("Invalid image format")};function Xt(e,t,n){return b({},e,{fileType:{value:t,description:n}})}var Kt={ApertureValue:e=>Math.pow(Math.sqrt(2),e[0]/e[1]).toFixed(2),ColorSpace:e=>1===e?"sRGB":65535===e?"Uncalibrated":"Unknown",ComponentsConfiguration:e=>e.map((e=>49===e?"Y":50===e?"Cb":51===e?"Cr":52===e?"R":53===e?"G":54===e?"B":void 0)).join(""),Contrast:e=>0===e?"Normal":1===e?"Soft":2===e?"Hard":"Unknown",CustomRendered:e=>0===e?"Normal process":1===e?"Custom process":"Unknown",ExposureMode:e=>0===e?"Auto exposure":1===e?"Manual exposure":2===e?"Auto bracket":"Unknown",ExposureProgram:e=>0===e?"Undefined":1===e?"Manual":2===e?"Normal program":3===e?"Aperture priority":4===e?"Shutter priority":5===e?"Creative program":6===e?"Action program":7===e?"Portrait mode":8===e?"Landscape mode":9===e?"Bulb":"Unknown",ExposureTime(e){if(e[0]/e[1]>.25){const t=e[0]/e[1];return Number.isInteger(t)?""+t:t.toFixed(1)}return 0!==e[0]?"1/"+Math.round(e[1]/e[0]):"0/"+e[1]},FNumber:e=>"f/"+Number(e[0]/e[1]).toFixed(1),FocalLength:e=>e[0]/e[1]+" mm",FocalPlaneResolutionUnit:e=>2===e?"inches":3===e?"centimeters":4===e?"millimeters":"Unknown",LightSource:e=>1===e?"Daylight":2===e?"Fluorescent":3===e?"Tungsten (incandescent light)":4===e?"Flash":9===e?"Fine weather":10===e?"Cloudy weather":11===e?"Shade":12===e?"Daylight fluorescent (D 5700 – 7100K)":13===e?"Day white fluorescent (N 4600 – 5400K)":14===e?"Cool white fluorescent (W 3900 – 4500K)":15===e?"White fluorescent (WW 3200 – 3700K)":17===e?"Standard light A":18===e?"Standard light B":19===e?"Standard light C":20===e?"D55":21===e?"D65":22===e?"D75":23===e?"D50":24===e?"ISO studio tungsten":255===e?"Other light source":"Unknown",MeteringMode:e=>1===e?"Average":2===e?"CenterWeightedAverage":3===e?"Spot":4===e?"MultiSpot":5===e?"Pattern":6===e?"Partial":255===e?"Other":"Unknown",ResolutionUnit:e=>2===e?"inches":3===e?"centimeters":"Unknown",Saturation:e=>0===e?"Normal":1===e?"Low saturation":2===e?"High saturation":"Unknown",FocalLengthIn35mmFilm:e=>0===e?"Unknown":e+" mm",SceneCaptureType:e=>0===e?"Standard":1===e?"Landscape":2===e?"Portrait":3===e?"Night scene":"Unknown",Sharpness:e=>0===e?"Normal":1===e?"Soft":2===e?"Hard":"Unknown",ShutterSpeedValue(e){const t=Math.pow(2,e[0]/e[1]);return t<=1?""+Math.round(1/t):"1/"+Math.round(t)},WhiteBalance:e=>0===e?"Auto white balance":1===e?"Manual white balance":"Unknown",XResolution:e=>""+Math.round(e[0]/e[1]),YResolution:e=>""+Math.round(e[0]/e[1])},Yt={11:"ProcessingSoftware",254:{name:"SubfileType",description:e=>({0:"Full-resolution image",1:"Reduced-resolution image",2:"Single page of multi-page image",3:"Single page of multi-page reduced-resolution image",4:"Transparency mask",5:"Transparency mask of reduced-resolution image",6:"Transparency mask of multi-page image",7:"Transparency mask of reduced-resolution multi-page image",65537:"Alternate reduced-resolution image",4294967295:"Invalid"}[e]||"Unknown")},255:{name:"OldSubfileType",description:e=>({0:"Full-resolution image",1:"Reduced-resolution image",2:"Single page of multi-page image"}[e]||"Unknown")},256:"ImageWidth",257:"ImageLength",258:"BitsPerSample",259:"Compression",262:"PhotometricInterpretation",263:{name:"Thresholding",description:e=>({1:"No dithering or halftoning",2:"Ordered dither or halfton",3:"Randomized dither"}[e]||"Unknown")},264:"CellWidth",265:"CellLength",266:{name:"FillOrder",description:e=>({1:"Normal",2:"Reversed"}[e]||"Unknown")},269:"DocumentName",270:"ImageDescription",271:"Make",272:"Model",273:"StripOffsets",274:{name:"Orientation",description:e=>1===e?"top-left":2===e?"top-right":3===e?"bottom-right":4===e?"bottom-left":5===e?"left-top":6===e?"right-top":7===e?"right-bottom":8===e?"left-bottom":"Undefined"},277:"SamplesPerPixel",278:"RowsPerStrip",279:"StripByteCounts",280:"MinSampleValue",281:"MaxSampleValue",282:{name:"XResolution",description:Kt.XResolution},283:{name:"YResolution",description:Kt.YResolution},284:"PlanarConfiguration",285:"PageName",286:{name:"XPosition",description:e=>""+Math.round(e[0]/e[1])},287:{name:"YPosition",description:e=>""+Math.round(e[0]/e[1])},290:{name:"GrayResponseUnit",description:e=>({1:"0.1",2:"0.001",3:"0.0001",4:"1e-05",5:"1e-06"}[e]||"Unknown")},296:{name:"ResolutionUnit",description:Kt.ResolutionUnit},297:"PageNumber",301:"TransferFunction",305:"Software",306:"DateTime",315:"Artist",316:"HostComputer",317:"Predictor",318:{name:"WhitePoint",description:e=>e.map((e=>`${e[0]}/${e[1]}`)).join(", ")},319:{name:"PrimaryChromaticities",description:e=>e.map((e=>`${e[0]}/${e[1]}`)).join(", ")},321:"HalftoneHints",322:"TileWidth",323:"TileLength",330:"A100DataOffset",332:{name:"InkSet",description:e=>({1:"CMYK",2:"Not CMYK"}[e]||"Unknown")},337:"TargetPrinter",338:{name:"ExtraSamples",description:e=>({0:"Unspecified",1:"Associated Alpha",2:"Unassociated Alpha"}[e]||"Unknown")},339:{name:"SampleFormat",description:e=>{const t={1:"Unsigned",2:"Signed",3:"Float",4:"Undefined",5:"Complex int",6:"Complex float"};return Array.isArray(e)?e.map((e=>t[e]||"Unknown")).join(", "):"Unknown"}},513:"JPEGInterchangeFormat",514:"JPEGInterchangeFormatLength",529:{name:"YCbCrCoefficients",description:e=>e.map((e=>""+e[0]/e[1])).join("/")},530:"YCbCrSubSampling",531:{name:"YCbCrPositioning",description:e=>1===e?"centered":2===e?"co-sited":"undefined "+e},532:{name:"ReferenceBlackWhite",description:e=>e.map((e=>""+e[0]/e[1])).join(", ")},700:"ApplicationNotes",18246:"Rating",18249:"RatingPercent",33432:{name:"Copyright",description:e=>e.join("; ")},33550:"PixelScale",33723:"IPTC-NAA",33920:"IntergraphMatrix",33922:"ModelTiePoint",34118:"SEMInfo",34264:"ModelTransform",34377:"PhotoshopSettings",34665:"Exif IFD Pointer",34675:"ICC_Profile",34735:"GeoTiffDirectory",34736:"GeoTiffDoubleParams",34737:"GeoTiffAsciiParams",34853:"GPS Info IFD Pointer",40091:{name:"XPTitle",description:qt},40092:{name:"XPComment",description:qt},40093:{name:"XPAuthor",description:qt},40094:{name:"XPKeywords",description:qt},40095:{name:"XPSubject",description:qt},42112:"GDALMetadata",42113:"GDALNoData",50341:"PrintIM",50707:"DNGBackwardVersion",50708:"UniqueCameraModel",50709:"LocalizedCameraModel",50721:"ColorMatrix1",50722:"ColorMatrix2",50723:"CameraCalibration1",50724:"CameraCalibration2",50725:"ReductionMatrix1",50726:"ReductionMatrix2",50727:"AnalogBalance",50728:"AsShotNeutral",50729:"AsShotWhiteXY",50730:"BaselineExposure",50731:"BaselineNoise",50732:"BaselineSharpness",50734:"LinearResponseLimit",50735:"CameraSerialNumber",50736:"DNGLensInfo",50739:"ShadowScale",50741:{name:"MakerNoteSafety",description:e=>({0:"Unsafe",1:"Safe"}[e]||"Unknown")},50778:{name:"CalibrationIlluminant1",description:Kt.LightSource},50779:{name:"CalibrationIlluminant2",description:Kt.LightSource},50781:"RawDataUniqueID",50827:"OriginalRawFileName",50828:"OriginalRawFileData",50831:"AsShotICCProfile",50832:"AsShotPreProfileMatrix",50833:"CurrentICCProfile",50834:"CurrentPreProfileMatrix",50879:"ColorimetricReference",50885:"SRawType",50898:"PanasonicTitle",50899:"PanasonicTitle2",50931:"CameraCalibrationSig",50932:"ProfileCalibrationSig",50933:"ProfileIFD",50934:"AsShotProfileName",50936:"ProfileName",50937:"ProfileHueSatMapDims",50938:"ProfileHueSatMapData1",50939:"ProfileHueSatMapData2",50940:"ProfileToneCurve",50941:{name:"ProfileEmbedPolicy",description:e=>({0:"Allow Copying",1:"Embed if Used",2:"Never Embed",3:"No Restrictions"}[e]||"Unknown")},50942:"ProfileCopyright",50964:"ForwardMatrix1",50965:"ForwardMatrix2",50966:"PreviewApplicationName",50967:"PreviewApplicationVersion",50968:"PreviewSettingsName",50969:"PreviewSettingsDigest",50970:{name:"PreviewColorSpace",description:e=>({1:"Gray Gamma 2.2",2:"sRGB",3:"Adobe RGB",4:"ProPhoto RGB"}[e]||"Unknown")},50971:"PreviewDateTime",50972:"RawImageDigest",50973:"OriginalRawFileDigest",50981:"ProfileLookTableDims",50982:"ProfileLookTableData",51043:"TimeCodes",51044:"FrameRate",51058:"TStop",51081:"ReelName",51089:"OriginalDefaultFinalSize",51090:"OriginalBestQualitySize",51091:"OriginalDefaultCropSize",51105:"CameraLabel",51107:{name:"ProfileHueSatMapEncoding",description:e=>({0:"Linear",1:"sRGB"}[e]||"Unknown")},51108:{name:"ProfileLookTableEncoding",description:e=>({0:"Linear",1:"sRGB"}[e]||"Unknown")},51109:"BaselineExposureOffset",51110:{name:"DefaultBlackRender",description:e=>({0:"Auto",1:"None"}[e]||"Unknown")},51111:"NewRawImageDigest",51112:"RawToPreviewGain"};function qt(e){return new TextDecoder("utf-16").decode(new Uint8Array(e)).replace(/\u0000+$/,"")}var Jt={0:{name:"GPSVersionID",description:e=>2===e[0]&&2===e[1]&&0===e[2]&&0===e[3]?"Version 2.2":"Unknown"},1:{name:"GPSLatitudeRef",description:e=>{const t=e.join("");return"N"===t?"North latitude":"S"===t?"South latitude":"Unknown"}},2:{name:"GPSLatitude",description:O},3:{name:"GPSLongitudeRef",description:e=>{const t=e.join("");return"E"===t?"East longitude":"W"===t?"West longitude":"Unknown"}},4:{name:"GPSLongitude",description:O},5:{name:"GPSAltitudeRef",description:e=>0===e?"Sea level":1===e?"Sea level reference (negative value)":"Unknown"},6:{name:"GPSAltitude",description:e=>e[0]/e[1]+" m"},7:{name:"GPSTimeStamp",description:e=>e.map((([e,t])=>{const n=e/t;return/^\d(\.|$)/.test(""+n)?"0"+n:n})).join(":")},8:"GPSSatellites",9:{name:"GPSStatus",description:e=>{const t=e.join("");return"A"===t?"Measurement in progress":"V"===t?"Measurement Interoperability":"Unknown"}},10:{name:"GPSMeasureMode",description:e=>{const t=e.join("");return"2"===t?"2-dimensional measurement":"3"===t?"3-dimensional measurement":"Unknown"}},11:"GPSDOP",12:{name:"GPSSpeedRef",description:e=>{const t=e.join("");return"K"===t?"Kilometers per hour":"M"===t?"Miles per hour":"N"===t?"Knots":"Unknown"}},13:"GPSSpeed",14:{name:"GPSTrackRef",description:e=>{const t=e.join("");return"T"===t?"True direction":"M"===t?"Magnetic direction":"Unknown"}},15:"GPSTrack",16:{name:"GPSImgDirectionRef",description:e=>{const t=e.join("");return"T"===t?"True direction":"M"===t?"Magnetic direction":"Unknown"}},17:"GPSImgDirection",18:"GPSMapDatum",19:{name:"GPSDestLatitudeRef",description:e=>{const t=e.join("");return"N"===t?"North latitude":"S"===t?"South latitude":"Unknown"}},20:{name:"GPSDestLatitude",description:e=>e[0][0]/e[0][1]+e[1][0]/e[1][1]/60+e[2][0]/e[2][1]/3600},21:{name:"GPSDestLongitudeRef",description:e=>{const t=e.join("");return"E"===t?"East longitude":"W"===t?"West longitude":"Unknown"}},22:{name:"GPSDestLongitude",description:e=>e[0][0]/e[0][1]+e[1][0]/e[1][1]/60+e[2][0]/e[2][1]/3600},23:{name:"GPSDestBearingRef",description:e=>{const t=e.join("");return"T"===t?"True direction":"M"===t?"Magnetic direction":"Unknown"}},24:"GPSDestBearing",25:{name:"GPSDestDistanceRef",description:e=>{const t=e.join("");return"K"===t?"Kilometers":"M"===t?"Miles":"N"===t?"Knots":"Unknown"}},26:"GPSDestDistance",27:{name:"GPSProcessingMethod",description:D},28:{name:"GPSAreaInformation",description:D},29:"GPSDateStamp",30:{name:"GPSDifferential",description:e=>0===e?"Measurement without differential correction":1===e?"Differential correction applied":"Unknown"},31:"GPSHPositioningError"},Zt={1:"InteroperabilityIndex",2:{name:"InteroperabilityVersion",description:e=>A(e)},4096:"RelatedImageFileFormat",4097:"RelatedImageWidth",4098:"RelatedImageHeight"},Qt={45056:{name:"MPFVersion",description:e=>A(e)},45057:"NumberOfImages",45058:"MPEntry",45059:"ImageUIDList",45060:"TotalFrames"};const en=b({},Yt,{33434:{name:"ExposureTime",description:Kt.ExposureTime},33437:{name:"FNumber",description:Kt.FNumber},34850:{name:"ExposureProgram",description:Kt.ExposureProgram},34852:"SpectralSensitivity",34855:"ISOSpeedRatings",34856:{name:"OECF",description:()=>"[Raw OECF table data]"},34858:"TimeZoneOffset",34859:"SelfTimerMode",34864:{name:"SensitivityType",description:e=>({1:"Standard Output Sensitivity",2:"Recommended Exposure Index",3:"ISO Speed",4:"Standard Output Sensitivity and Recommended Exposure Index",5:"Standard Output Sensitivity and ISO Speed",6:"Recommended Exposure Index and ISO Speed",7:"Standard Output Sensitivity, Recommended Exposure Index and ISO Speed"}[e]||"Unknown")},34865:"StandardOutputSensitivity",34866:"RecommendedExposureIndex",34867:"ISOSpeed",34868:"ISOSpeedLatitudeyyy",34869:"ISOSpeedLatitudezzz",36864:{name:"ExifVersion",description:e=>A(e)},36867:"DateTimeOriginal",36868:"DateTimeDigitized",36873:"GooglePlusUploadCode",36880:"OffsetTime",36881:"OffsetTimeOriginal",36882:"OffsetTimeDigitized",37121:{name:"ComponentsConfiguration",description:Kt.ComponentsConfiguration},37122:"CompressedBitsPerPixel",37377:{name:"ShutterSpeedValue",description:Kt.ShutterSpeedValue},37378:{name:"ApertureValue",description:Kt.ApertureValue},37379:"BrightnessValue",37380:"ExposureBiasValue",37381:{name:"MaxApertureValue",description:e=>Math.pow(Math.sqrt(2),e[0]/e[1]).toFixed(2)},37382:{name:"SubjectDistance",description:e=>e[0]/e[1]+" m"},37383:{name:"MeteringMode",description:Kt.MeteringMode},37384:{name:"LightSource",description:Kt.LightSource},37385:{name:"Flash",description:e=>0===e?"Flash did not fire":1===e?"Flash fired":5===e?"Strobe return light not detected":7===e?"Strobe return light detected":9===e?"Flash fired, compulsory flash mode":13===e?"Flash fired, compulsory flash mode, return light not detected":15===e?"Flash fired, compulsory flash mode, return light detected":16===e?"Flash did not fire, compulsory flash mode":24===e?"Flash did not fire, auto mode":25===e?"Flash fired, auto mode":29===e?"Flash fired, auto mode, return light not detected":31===e?"Flash fired, auto mode, return light detected":32===e?"No flash function":65===e?"Flash fired, red-eye reduction mode":69===e?"Flash fired, red-eye reduction mode, return light not detected":71===e?"Flash fired, red-eye reduction mode, return light detected":73===e?"Flash fired, compulsory flash mode, red-eye reduction mode":77===e?"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected":79===e?"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected":89===e?"Flash fired, auto mode, red-eye reduction mode":93===e?"Flash fired, auto mode, return light not detected, red-eye reduction mode":95===e?"Flash fired, auto mode, return light detected, red-eye reduction mode":"Unknown"},37386:{name:"FocalLength",description:Kt.FocalLength},37393:"ImageNumber",37394:{name:"SecurityClassification",description:e=>({C:"Confidential",R:"Restricted",S:"Secret",T:"Top Secret",U:"Unclassified"}[e]||"Unknown")},37395:"ImageHistory",37396:{name:"SubjectArea",description:e=>2===e.length?`Location; X: ${e[0]}, Y: ${e[1]}`:3===e.length?`Circle; X: ${e[0]}, Y: ${e[1]}, diameter: ${e[2]}`:4===e.length?`Rectangle; X: ${e[0]}, Y: ${e[1]}, width: ${e[2]}, height: ${e[3]}`:"Unknown"},37500:{name:"MakerNote",description:()=>"[Raw maker note data]"},37510:{name:"UserComment",description:D},37520:"SubSecTime",37521:"SubSecTimeOriginal",37522:"SubSecTimeDigitized",37724:"ImageSourceData",37888:{name:"AmbientTemperature",description:e=>e[0]/e[1]+" °C"},37889:{name:"Humidity",description:e=>e[0]/e[1]+" %"},37890:{name:"Pressure",description:e=>e[0]/e[1]+" hPa"},37891:{name:"WaterDepth",description:e=>e[0]/e[1]+" m"},37892:{name:"Acceleration",description:e=>e[0]/e[1]+" mGal"},37893:{name:"CameraElevationAngle",description:e=>e[0]/e[1]+" °"},40960:{name:"FlashpixVersion",description:e=>e.map((e=>String.fromCharCode(e))).join("")},40961:{name:"ColorSpace",description:Kt.ColorSpace},40962:"PixelXDimension",40963:"PixelYDimension",40964:"RelatedSoundFile",40965:"Interoperability IFD Pointer",41483:"FlashEnergy",41484:{name:"SpatialFrequencyResponse",description:()=>"[Raw SFR table data]"},41486:"FocalPlaneXResolution",41487:"FocalPlaneYResolution",41488:{name:"FocalPlaneResolutionUnit",description:Kt.FocalPlaneResolutionUnit},41492:{name:"SubjectLocation",description:([e,t])=>`X: ${e}, Y: ${t}`},41493:"ExposureIndex",41495:{name:"SensingMethod",description:e=>1===e?"Undefined":2===e?"One-chip color area sensor":3===e?"Two-chip color area sensor":4===e?"Three-chip color area sensor":5===e?"Color sequential area sensor":7===e?"Trilinear sensor":8===e?"Color sequential linear sensor":"Unknown"},41728:{name:"FileSource",description:e=>3===e?"DSC":"Unknown"},41729:{name:"SceneType",description:e=>1===e?"A directly photographed image":"Unknown"},41730:{name:"CFAPattern",description:()=>"[Raw CFA pattern table data]"},41985:{name:"CustomRendered",description:Kt.CustomRendered},41986:{name:"ExposureMode",description:Kt.ExposureMode},41987:{name:"WhiteBalance",description:Kt.WhiteBalance},41988:{name:"DigitalZoomRatio",description:e=>0===e[0]?"Digital zoom was not used":""+e[0]/e[1]},41989:{name:"FocalLengthIn35mmFilm",description:Kt.FocalLengthIn35mmFilm},41990:{name:"SceneCaptureType",description:Kt.SceneCaptureType},41991:{name:"GainControl",description:e=>0===e?"None":1===e?"Low gain up":2===e?"High gain up":3===e?"Low gain down":4===e?"High gain down":"Unknown"},41992:{name:"Contrast",description:Kt.Contrast},41993:{name:"Saturation",description:Kt.Saturation},41994:{name:"Sharpness",description:Kt.Sharpness},41995:{name:"DeviceSettingDescription",description:()=>"[Raw device settings table data]"},41996:{name:"SubjectDistanceRange",description:e=>1===e?"Macro":2===e?"Close view":3===e?"Distant view":"Unknown"},42016:"ImageUniqueID",42032:"CameraOwnerName",42033:"BodySerialNumber",42034:{name:"LensSpecification",description:e=>{const t=`${parseFloat((e[0][0]/e[0][1]).toFixed(5))}-${parseFloat((e[1][0]/e[1][1]).toFixed(5))} mm`;return 0===e[3][1]?t+" f/?":`${t} f/${parseFloat((1/(e[2][1]/e[2][1]/(e[3][0]/e[3][1]))).toFixed(5))}`}},42035:"LensMake",42036:"LensModel",42037:"LensSerialNumber",42080:{name:"CompositeImage",description:e=>({1:"Not a Composite Image",2:"General Composite Image",3:"Composite Image Captured While Shooting"}[e]||"Unknown")},42081:"SourceImageNumberOfCompositeImage",42082:"SourceExposureTimesOfCompositeImage",42240:"Gamma",59932:"Padding",59933:"OffsetSchema",65e3:"OwnerName",65001:"SerialNumber",65002:"Lens",65100:"RawFile",65101:"Converter",65102:"WhiteBalance",65105:"Exposure",65106:"Shadows",65107:"Brightness",65108:"Contrast",65109:"Saturation",65110:"Sharpness",65111:"Smoothness",65112:"MoireFilter"}),tn="0th",nn="1st",rn="exif",on="gps",an="interoperability",sn="mpf",cn="canon",un="pentax";var fn={[tn]:en,[nn]:Yt,[rn]:en,[on]:Jt,[an]:Zt,[sn]:T.USE_MPF?Qt:{},[cn]:T.USE_MAKER_NOTES?{1:{name:"CameraSettings",description:e=>e},4:{name:"ShotInfo",description:e=>e},149:"LensModel"}:{},[un]:T.USE_MAKER_NOTES?{0:{name:"PentaxVersion",description:e=>e.join(".")},5:"PentaxModelID",555:"LevelInfo"}:{}};const ln={1:1,2:1,3:2,4:4,5:8,7:1,9:4,10:8,13:4},dn={BYTE:1,ASCII:2,SHORT:3,LONG:4,RATIONAL:5,UNDEFINED:7,SLONG:9,SRATIONAL:10,IFD:13};var pn={getAsciiValue:function(e){return e.map((e=>String.fromCharCode(e)))},getByteAt:mn,getAsciiAt:function(e,t){return e.getUint8(t)},getShortAt:function(e,t,n){return e.getUint16(t,n===X)},getLongAt:gn,getRationalAt:function(e,t,n){return[gn(e,t,n),gn(e,t+4,n)]},getUndefinedAt:function(e,t){return mn(e,t)},getSlongAt:hn,getSrationalAt:function(e,t,n){return[hn(e,t,n),hn(e,t+4,n)]},getIfdPointerAt:function(e,t,n){return gn(e,t,n)},typeSizes:ln,tagTypes:dn,getTypeSize:function(e){if(void 0===dn[e])throw Error("No such type found.");return ln[dn[e]]}};function mn(e,t){return e.getUint8(t)}function gn(e,t,n){return e.getUint32(t,n===X)}function hn(e,t,n){return e.getInt32(t,n===X)}const bn={exif:!0,iptc:!0,photoshop:!0,mpf:!0,makerNotes:!0},vn={exif:!0,iptc:!0,xmp:!0,icc:!0,photoshop:!0,makerNotes:!0,mpf:!0,file:!0,jfif:!0,png:!0,riff:!0,gif:!0,gps:!0,composite:!0,thumbnail:!0},yn="Exif IFD Pointer",wn="GPS Info IFD Pointer",xn={thumbnail:["JPEGInterchangeFormat","JPEGInterchangeFormatLength"],iptc:["IPTC-NAA"],xmp:["ApplicationNotes"],icc:["ICC_Profile"],photoshop:["ImageSourceData","PhotoshopSettings"],makerNotes:["MakerNote","Make"],gps:["GPSLatitude","GPSLatitudeRef","GPSLongitude","GPSLongitudeRef","GPSAltitude","GPSAltitudeRef"]},Sn=["Image Width","Image Height"],In=["FocalLength","FocalPlaneXResolution","FocalPlaneYResolution","FocalPlaneResolutionUnit","FocalLengthIn35mmFilm"];function Cn(e){return!0===e||Array.isArray(e)&&e.length>0}function Pn(){return{isActive:!1,shouldReturnGroup:e,shouldParseGroup:e,shouldReturnTag:e,shouldParseTag:e};function e(){return!0}}const kn=Pn();function Tn({groupKey:e,hasIncludeTags:t,hasIncludeEntry:n,includeTags:r,shouldParseExif:i,shouldParseFile:o}){return!t||(n?!("thumbnail"!==e||!Array.isArray(r[e]))||r[e]:"exif"===e&&i||"file"===e&&o?[]:void 0)}function An({groupKey:e,hasIncludeTags:t,hasIncludeEntry:n,shouldParseExif:r,shouldParseFile:i,exifIncludeDependencies:o,fileIncludeDependencies:a}){return t?"exif"===e&&(r||n&&Object.keys(o).length>0)?o:"file"===e&&i?a:Object.create(null):Object.create(null)}function Dn(e,t){if(!e||!Object.prototype.hasOwnProperty.call(e,t))return!1;const n=e[t];return!0===n||Array.isArray(n)&&n.length>0}function On(e){return Array.isArray(e)&&0===e.length}function Rn({groupKey:e,includeValue:t,excludeValue:n,extraIncludeNames:r}){const i=!!bn[e],o={includeAll:!1,includeNames:void 0,includeIds:void 0,excludeAll:!1,excludeNames:void 0,excludeIds:void 0};if(!0===t)o.includeAll=!0;else if(Array.isArray(t)){o.includeNames=Object.create(null),i&&(o.includeIds=Object.create(null));for(let e=0;e<t.length;e++)a(o,t[e]);for(const e in r)o.includeNames[e.toLowerCase()]=!0}else if(r&&Object.keys(r).length>0){o.includeNames=Object.create(null);for(const e in r)o.includeNames[e.toLowerCase()]=!0}if(!0===n)return o.excludeAll=!0,o;if(Array.isArray(n)){o.excludeNames=Object.create(null),i&&(o.excludeIds=Object.create(null));for(let e=0;e<n.length;e++)s(o,n[e])}return o;function a(e,t){"number"==typeof t&&e.includeIds?e.includeIds[t+""]=!0:"string"==typeof t&&(e.includeNames[t.toLowerCase()]=!0)}function s(e,t){"number"==typeof t&&e.excludeIds?e.excludeIds[t+""]=!0:"string"==typeof t&&(e.excludeNames[t.toLowerCase()]=!0)}}function Fn(e,t,n){return!(e.excludeAll||(e.includeAll?Mn(e,t,n):(e.includeNames||e.includeIds)&&!function(e,t,n){return!(void 0===n||!e.includeIds||!e.includeIds[n+""])||!!(t&&e.includeNames&&e.includeNames[(t+"").toLowerCase()])}(e,t,n)||Mn(e,t,n)))}function Mn(e,t,n){return!(void 0===n||!e.excludeIds||!e.excludeIds[n+""])||!!(t&&e.excludeNames&&e.excludeNames[(t+"").toLowerCase()])}const Un={1:pn.getByteAt,2:pn.getAsciiAt,3:pn.getShortAt,4:pn.getLongAt,5:pn.getRationalAt,7:pn.getUndefinedAt,9:pn.getSlongAt,10:pn.getSrationalAt,13:pn.getIfdPointerAt};function En(e,t,n){const r=t+4;if(!(r+pn.getTypeSize("LONG")>e.byteLength))return t+pn.getLongAt(e,r,n)}function Nn(e,t,n,r,i,o,a=!1,s=kn,c="exif"){const u=pn.getTypeSize("SHORT"),f={},l=function(e,t,n){return t+pn.getTypeSize("SHORT")<=e.byteLength?pn.getShortAt(e,t,n):0}(e,r,i);r+=u;for(let u=0;u<l&&!(r+12>e.byteLength);u++){const u=Gn(e,t,n,r,i,o,s,c);void 0!==u&&(f[u.name]={id:u.id,value:u.value,description:u.description},a&&(f[u.name].computed=jn(u.tagType,u.value)),("MakerNote"===u.name||t===un&&"LevelInfo"===u.name)&&(f[u.name].__offset=u.__offset)),r+=12}if(T.USE_THUMBNAIL&&r<e.byteLength-pn.getTypeSize("LONG")){const c=pn.getLongAt(e,r,i);0!==c&&t===tn&&s.shouldParseGroup("thumbnail")&&(f.Thumbnail=Nn(e,"1st",n,n+c,i,o,a,s,"thumbnail"))}return f}function Gn(e,t,n,r,i,o=!1,a=kn,s="exif"){const c=pn.getTypeSize("SHORT"),u=c+pn.getTypeSize("SHORT"),f=u+pn.getTypeSize("LONG"),l=pn.getShortAt(e,r,i),d=pn.getShortAt(e,r+c,i),p=pn.getLongAt(e,r+u,i);let m,g;if(void 0===pn.typeSizes[d]||!o&&void 0===fn[t][l])return;const h=function(e,t){if(void 0!==fn[e][t]){if("string"==typeof fn[e][t])return fn[e][t];if(fn[e][t].name)return fn[e][t].name}return"undefined-"+t}(t,l);if(!a.shouldParseTag(s,h,l))return;!function(e,t){return pn.typeSizes[e]*t<=pn.getTypeSize("LONG")}(d,p)?(g=pn.getLongAt(e,r+f,i),m=function(e,t,n,r,i){return t+n+pn.typeSizes[r]*i<=e.byteLength}(e,n,g,d,p)?Ln(e,n+g,d,p,i,33723===l):"<faulty value>"):(g=r+f,m=Ln(e,g,d,p,i)),d===pn.tagTypes.ASCII&&(m=function(e){const t=[];let n=0;for(let r=0;r<e.length;r++)"\0"!==e[r]?(void 0===t[n]&&(t[n]=""),t[n]+=e[r]):n++;return t}(m),m=function(e){try{return e.map((e=>decodeURIComponent(escape(e))))}catch(t){return e}}(m));let b=m;if(void 0!==fn[t][l])if(void 0!==fn[t][l].name&&void 0!==fn[t][l].description)try{b=fn[t][l].description(m)}catch(e){b=Bn(m)}else b=d===pn.tagTypes.RATIONAL||d===pn.tagTypes.SRATIONAL?""+m[0]/m[1]:Bn(m);return{id:l,name:h,value:m,description:b,tagType:d,__offset:g}}function Ln(e,t,n,r,i,o=!1){let a=[];o&&(r*=pn.typeSizes[n],n=pn.tagTypes.BYTE);for(let o=0;o<r;o++)a.push(Un[n](e,t,i)),t+=pn.typeSizes[n];return n===pn.tagTypes.ASCII?a=pn.getAsciiValue(a):1===a.length&&(a=a[0]),a}function Bn(e){return e instanceof Array?e.join(", "):e}function jn(e,t){return e===pn.tagTypes.ASCII?Array.isArray(t)&&1===t.length?t[0]:t:e===pn.tagTypes.RATIONAL||e===pn.tagTypes.SRATIONAL?function(e){return!(!Array.isArray(e)||2!==e.length)&&("number"==typeof e[0]&&"number"==typeof e[1])}(t)?_n(t):Array.isArray(t)?t.map((e=>_n(e))):t:t}function _n(e){if(!Array.isArray(e)||2!==e.length)return e;const t=e[0],n=e[1];return Number.isFinite(t)&&Number.isFinite(n)?0===n?null:t/n:e}const Vn="Exif IFD Pointer",zn="GPS Info IFD Pointer",Hn="Interoperability IFD Pointer";var $n=function(e,t,n,r=!1,i){const o=K(e,t);let a=function(e,t,n,r,i,o){const a=En(e,t,n);return void 0===a?{}:Nn(e,tn,t,a,n,r,i,o,"exif")}(e,t,o,n,r,i);return a=function(e,t,n,r,i,o,a){return void 0!==e[Vn]?b(e,Nn(t,rn,n,n+e[Vn].value,r,i,o,a,"exif")):e}(a,e,t,o,n,r,i),a=function(e,t,n,r,i,o,a){return void 0!==e[zn]?b(e,Nn(t,"gps",n,n+e[zn].value,r,i,o,a,"exif")):e}(a,e,t,o,n,r,i),a=function(e,t,n,r,i,o,a){return void 0!==e[Hn]?b(e,Nn(t,an,n,n+e[Hn].value,r,i,o,a,"exif")):e}(a,e,t,o,n,r,i),{tags:a,byteOrder:o}};var Wn=function(e,t,n,r=!1,i){const o=K(e,t),a=En(e,t,o);if(void 0===a)return{};return function(e,t,n,r){if(!n.MPEntry)return n;const i=[];for(let o=0;o<Math.ceil(n.MPEntry.value.length/Xn);o++){i[o]={};const a=Kn(n.MPEntry.value,o*Xn,pn.getTypeSize("LONG"),r);i[o].ImageFlags=Yn(a),i[o].ImageFormat=qn(a),i[o].ImageType=Jn(a);const s=Kn(n.MPEntry.value,o*Xn+4,pn.getTypeSize("LONG"),r);i[o].ImageSize={value:s,description:""+s};const c=Zn(o,n.MPEntry,r,t);i[o].ImageOffset={value:c,description:""+c};const u=Kn(n.MPEntry.value,o*Xn+12,pn.getTypeSize("SHORT"),r);i[o].DependentImage1EntryNumber={value:u,description:""+u};const f=Kn(n.MPEntry.value,o*Xn+14,pn.getTypeSize("SHORT"),r);i[o].DependentImage2EntryNumber={value:f,description:""+f},i[o].image=e.buffer.slice(c,c+s),v(i[o],"base64",(function(){return y(this.image)}))}return n.Images=i,n}(e,t,Nn(e,"mpf",t,a,o,n,r,i,"mpf"),o)};const Xn=16;function Kn(e,t,n,r){if(r===X){let r=0;for(let i=0;i<n;i++)r+=e[t+i]<<8*i;return r}let i=0;for(let r=0;r<n;r++)i+=e[t+r]<<8*(n-1-r);return i}function Yn(e){const t=[e>>31&1,e>>30&1,e>>29&1],n=[];return t[0]&&n.push("Dependent Parent Image"),t[1]&&n.push("Dependent Child Image"),t[2]&&n.push("Representative Image"),{value:t,description:n.join(", ")||"None"}}function qn(e){const t=e>>24&7;return{value:t,description:0===t?"JPEG":"Unknown"}}function Jn(e){const t=16777215&e;return{value:t,description:{196608:"Baseline MP Primary Image",65537:"Large Thumbnail (VGA equivalent)",65538:"Large Thumbnail (Full HD equivalent)",131073:"Multi-Frame Image (Panorama)",131074:"Multi-Frame Image (Disparity)",131075:"Multi-Frame Image (Multi-Angle)",0:"Undefined"}[t]||"Unknown"}}function Zn(e,t,n,r){return function(e){return 0===e}(e)?0:Kn(t.value,e*Xn+8,pn.getTypeSize("LONG"),n)+r}var Qn=function(e,t){const n=function(e,t){return pn.getShortAt(e,t)}(e,t),r=function(e,t,n){if(8>n)return;const r=pn.getByteAt(e,t+7);return{value:r,description:""+r}}(e,t,n);return{"Bits Per Sample":er(e,t,n),"Image Height":tr(e,t,n),"Image Width":nr(e,t,n),"Color Components":r,Subsampling:r&&rr(e,t,r.value,n)}};function er(e,t,n){if(3>n)return;const r=pn.getByteAt(e,t+2);return{value:r,description:""+r}}function tr(e,t,n){if(5>n)return;const r=pn.getShortAt(e,t+3);return{value:r,description:r+"px"}}function nr(e,t,n){if(7>n)return;const r=pn.getShortAt(e,t+5);return{value:r,description:r+"px"}}function rr(e,t,n,r){if(8+3*n>r)return;const i=[];for(let r=0;r<n;r++){const n=t+8+3*r;i.push([pn.getByteAt(e,n),pn.getByteAt(e,n+1),pn.getByteAt(e,n+2)])}return{value:i,description:i.length>1?ir(i)+or(i):""}}function ir(e){const t={1:"Y",2:"Cb",3:"Cr",4:"I",5:"Q"};return e.map((e=>t[e[0]])).join("")}function or(e){const t={17:"4:4:4 (1 1)",18:"4:4:0 (1 2)",20:"4:4:1 (1 4)",33:"4:2:2 (2 1)",34:"4:2:0 (2 2)",36:"4:2:1 (2 4)",65:"4:1:1 (4 1)",66:"4:1:0 (4 2)"};return 0===e.length||void 0===e[0][1]||void 0===t[e[0][1]]?"":t[e[0][1]]}var ar=function(e,t){const n={};try{const r=function(e,t){let n=t,r=0;return{readBits(t){let i=0;for(let o=0;o<t;o++){if(n>=e.byteLength)throw Error("Unexpected end of data");i|=(e.getUint8(n)>>r&1)<<o,r++,r>=8&&(r=0,n++)}return i}}}(e,t+sr),{height:i,width:o}=function(e){let t,n;if(e.readBits(1)){t=8*(e.readBits(5)+1);const r=e.readBits(3);n=0===r?8*(e.readBits(5)+1):Math.ceil(t*ur[r])}else{t=fr(e);const r=e.readBits(3);n=0===r?fr(e):Math.ceil(t*ur[r])}return{height:t,width:n}}(r);n["Image Height"]={value:i,description:i+"px"},n["Image Width"]={value:o,description:o+"px"}}catch(e){}return n};const sr=2,cr=[9,13,18,30],ur=[0,1,1.2,4/3,1.5,16/9,5/4,2];function fr(e){const t=e.readBits(2);return 1+e.readBits(cr[t])}var lr=function(e,t){const n=function(e,t){return pn.getShortAt(e,t)}(e,t),r=function(e,t,n){if(15>n)return;const r=pn.getByteAt(e,t+14);return{value:r,description:r+"px"}}(e,t,n),i=function(e,t,n){if(16>n)return;const r=pn.getByteAt(e,t+15);return{value:r,description:r+"px"}}(e,t,n),o={"JFIF Version":dr(e,t,n),"Resolution Unit":pr(e,t,n),XResolution:gr(e,t,n),YResolution:hr(e,t,n),"JFIF Thumbnail Width":r,"JFIF Thumbnail Height":i};if(void 0!==r&&void 0!==i){const a=function(e,t,n,r){if(0===n||16+n>r)return;return{value:e.buffer.slice(t+16,t+16+n),description:"<24-bit RGB pixel data>"}}(e,t,3*r.value*i.value,n);a&&(o["JFIF Thumbnail"]=a)}for(const e in o)void 0===o[e]&&delete o[e];return o};function dr(e,t,n){if(9>n)return;const r=pn.getByteAt(e,t+7),i=pn.getByteAt(e,t+7+1);return{value:256*r+i,description:r+"."+i}}function pr(e,t,n){if(10>n)return;const r=pn.getByteAt(e,t+9);return{value:r,description:mr(r)}}function mr(e){return 0===e?"None":1===e?"inches":2===e?"cm":"Unknown"}function gr(e,t,n){if(12>n)return;const r=pn.getShortAt(e,t+10);return{value:r,description:""+r}}function hr(e,t,n){if(14>n)return;const r=pn.getShortAt(e,t+12);return{value:r,description:""+r}}var br={iptc:{256:{name:"Model Version",description:e=>""+((e[0]<<8)+e[1])},261:{name:"Destination",repeatable:!0},276:{name:"File Format",description:e=>""+((e[0]<<8)+e[1])},278:{name:"File Format Version",description:e=>""+((e[0]<<8)+e[1])},286:"Service Identifier",296:"Envelope Number",306:"Product ID",316:"Envelope Priority",326:{name:"Date Sent",description:vr},336:{name:"Time Sent",description:yr},346:{name:"Coded Character Set",description:wr,encoding_name:wr},356:"UNO",376:{name:"ARM Identifier",description:e=>""+((e[0]<<8)+e[1])},378:{name:"ARM Version",description:e=>""+((e[0]<<8)+e[1])},512:{name:"Record Version",description:e=>""+((e[0]<<8)+e[1])},515:"Object Type Reference",516:"Object Attribute Reference",517:"Object Name",519:"Edit Status",520:{name:"Editorial Update",description:e=>"01"===A(e)?"Additional Language":"Unknown"},522:"Urgency",524:{name:"Subject Reference",repeatable:!0,description:e=>{const t=A(e).split(":");return t[2]+(t[3]?"/"+t[3]:"")+(t[4]?"/"+t[4]:"")}},527:"Category",532:{name:"Supplemental Category",repeatable:!0},534:"Fixture Identifier",537:{name:"Keywords",repeatable:!0},538:{name:"Content Location Code",repeatable:!0},539:{name:"Content Location Name",repeatable:!0},542:"Release Date",547:"Release Time",549:"Expiration Date",550:"Expiration Time",552:"Special Instructions",554:{name:"Action Advised",description:e=>{const t=A(e);return"01"===t?"Object Kill":"02"===t?"Object Replace":"03"===t?"Object Append":"04"===t?"Object Reference":"Unknown"}},557:{name:"Reference Service",repeatable:!0},559:{name:"Reference Date",repeatable:!0},562:{name:"Reference Number",repeatable:!0},567:{name:"Date Created",description:vr},572:{name:"Time Created",description:yr},574:{name:"Digital Creation Date",description:vr},575:{name:"Digital Creation Time",description:yr},577:"Originating Program",582:"Program Version",587:{name:"Object Cycle",description:e=>{const t=A(e);return"a"===t?"morning":"p"===t?"evening":"b"===t?"both":"Unknown"}},592:{name:"By-line",repeatable:!0},597:{name:"By-line Title",repeatable:!0},602:"City",604:"Sub-location",607:"Province/State",612:"Country/Primary Location Code",613:"Country/Primary Location Name",615:"Original Transmission Reference",617:"Headline",622:"Credit",627:"Source",628:"Copyright Notice",630:{name:"Contact",repeatable:!0},632:"Caption/Abstract",634:{name:"Writer/Editor",repeatable:!0},637:{name:"Rasterized Caption",description:e=>e},642:"Image Type",643:{name:"Image Orientation",description:e=>{const t=A(e);return"P"===t?"Portrait":"L"===t?"Landscape":"S"===t?"Square":"Unknown"}},647:"Language Identifier",662:{name:"Audio Type",description:e=>{const t=A(e),n=t.charAt(0),r=t.charAt(1);let i="";return"1"===n?i+="Mono":"2"===n&&(i+="Stereo"),"A"===r?i+=", actuality":"C"===r?i+=", question and answer session":"M"===r?i+=", music, transmitted by itself":"Q"===r?i+=", response to a question":"R"===r?i+=", raw sound":"S"===r?i+=", scener":"V"===r?i+=", voicer":"W"===r&&(i+=", wrap"),""!==i?i:t}},663:{name:"Audio Sampling Rate",description:e=>parseInt(A(e),10)+" Hz"},664:{name:"Audio Sampling Resolution",description:e=>{const t=parseInt(A(e),10);return t+(1===t?" bit":" bits")}},665:{name:"Audio Duration",description:e=>{const t=A(e);return t.length>=6?t.substr(0,2)+":"+t.substr(2,2)+":"+t.substr(4,2):t}},666:"Audio Outcue",698:"Short Document ID",699:"Unique Document ID",700:"Owner ID",712:{name:e=>2===e.length?"ObjectData Preview File Format":"Record 2 destination",description:e=>{if(2===e.length){const t=(e[0]<<8)+e[1];return 0===t?"No ObjectData":1===t?"IPTC-NAA Digital Newsphoto Parameter Record":2===t?"IPTC7901 Recommended Message Format":3===t?"Tagged Image File Format (Adobe/Aldus Image data)":4===t?"Illustrator (Adobe Graphics data)":5===t?"AppleSingle (Apple Computer Inc)":6===t?"NAA 89-3 (ANPA 1312)":7===t?"MacBinary II":8===t?"IPTC Unstructured Character Oriented File Format (UCOFF)":9===t?"United Press International ANPA 1312 variant":10===t?"United Press International Down-Load Message":11===t?"JPEG File Interchange (JFIF)":12===t?"Photo-CD Image-Pac (Eastman Kodak)":13===t?"Microsoft Bit Mapped Graphics File [*.BMP]":14===t?"Digital Audio File [*.WAV] (Microsoft & Creative Labs)":15===t?"Audio plus Moving Video [*.AVI] (Microsoft)":16===t?"PC DOS/Windows Executable Files [*.COM][*.EXE]":17===t?"Compressed Binary File [*.ZIP] (PKWare Inc)":18===t?"Audio Interchange File Format AIFF (Apple Computer Inc)":19===t?"RIFF Wave (Microsoft Corporation)":20===t?"Freehand (Macromedia/Aldus)":21===t?'Hypertext Markup Language "HTML" (The Internet Society)':22===t?"MPEG 2 Audio Layer 2 (Musicom), ISO/IEC":23===t?"MPEG 2 Audio Layer 3, ISO/IEC":24===t?"Portable Document File (*.PDF) Adobe":25===t?"News Industry Text Format (NITF)":26===t?"Tape Archive (*.TAR)":27===t?"Tidningarnas Telegrambyrå NITF version (TTNITF DTD)":28===t?"Ritzaus Bureau NITF version (RBNITF DTD)":29===t?"Corel Draw [*.CDR]":"Unknown format "+t}return A(e)}},713:{name:"ObjectData Preview File Format Version",description:(e,t)=>{const n={"00":{"00":"1"},"01":{"01":"1","02":"2","03":"3","04":"4"},"02":{"04":"4"},"03":{"01":"5.0","02":"6.0"},"04":{"01":"1.40"},"05":{"01":"2"},"06":{"01":"1"},11:{"01":"1.02"},20:{"01":"3.1","02":"4.0","03":"5.0","04":"5.5"},21:{"02":"2.0"}},r=A(e);if(t["ObjectData Preview File Format"]){const e=A(t["ObjectData Preview File Format"].value);if(n[e]&&n[e][r])return n[e][r]}return r}},714:"ObjectData Preview Data",1802:{name:"Size Mode",description:e=>""+e[0]},1812:{name:"Max Subfile Size",description:e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<8)+e[n];return""+t}},1882:{name:"ObjectData Size Announced",description:e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<8)+e[n];return""+t}},1887:{name:"Maximum ObjectData Size",description:e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<8)+e[n];return""+t}}}};function vr(e){const t=A(e);return t.length>=8?t.substr(0,4)+"-"+t.substr(4,2)+"-"+t.substr(6,2):t}function yr(e){const t=A(e);let n=t;return t.length>=6&&(n=t.substr(0,2)+":"+t.substr(2,2)+":"+t.substr(4,2),11===t.length&&(n+=t.substr(6,1)+t.substr(7,2)+":"+t.substr(9,2))),n}function wr(e){const t=A(e);return"%G"===t?"UTF-8":"%5"===t?"Windows-1252":"%/G"===t?"UTF-8 Level 1":"%/H"===t?"UTF-8 Level 2":"%/I"===t?"UTF-8 Level 3":"/A"===t?"ISO-8859-1":"/B"===t?"ISO-8859-2":"/C"===t?"ISO-8859-3":"/D"===t?"ISO-8859-4":"/@"===t?"ISO-8859-5":"/G"===t?"ISO-8859-6":"/F"===t?"ISO-8859-7":"/H"===t?"ISO-8859-8":"Unknown"}var xr=function(){if("undefined"!=typeof TextDecoder)return TextDecoder};const Sr={128:8364,130:8218,131:402,132:8222,133:8230,134:8224,135:8225,136:710,137:8240,138:352,139:8249,140:338,142:381,145:8216,146:8217,147:8220,148:8221,149:8226,150:8211,151:8212,152:732,153:8482,154:353,155:8250,156:339,158:382,159:376};var Ir=function(e,t){if("string"==typeof t)return function(e){try{return decodeURIComponent(escape(e))}catch(t){return e}}(t);const n=xr();if(void 0!==n&&void 0!==e)try{return new n(e).decode(t instanceof DataView?t.buffer:Uint8Array.from(t))}catch(e){}const r=t.map((e=>String.fromCharCode(e))).join("");try{return decodeURIComponent(escape(r))}catch(e){return function(e){const t=e instanceof DataView,n=t?e.byteLength:e.length,r=t?t=>e.getUint8(t):t=>e[t],i=Array(n);for(let e=0;e<n;e++){const t=r(e),n=Sr[t];i[e]=void 0!==n?n:t}return String.fromCharCode.apply(null,i)}(t)}},Cr=function(e,t,n,r=kn){try{if(Array.isArray(e))return Ar(new DataView(Uint8Array.from(e).buffer),{size:e.length},0,n,r);const{naaBlock:i,dataOffset:o}=function(e,t){for(;t+12<=e.byteLength;){const n=Pr(e,t);if(kr(n))return{naaBlock:n,dataOffset:t+n.headerSize};t+=n.headerSize+n.size+Tr(n)}throw Error("No IPTC NAA resource block.")}(e,t);return Ar(e,i,o,n,r)}catch(e){return{}}};function Pr(e,t){if(943868237!==e.getUint32(t,!1))throw Error("Not an IPTC resource block.");const n=e.getUint8(t+4+2),r=(n%2==0?n+1:n)+1;return{headerSize:6+r+4,type:e.getUint16(t+4),size:e.getUint32(t+4+2+r)}}function kr(e){return 1028===e.type}function Tr(e){return e.size%2!=0?1:0}function Ar(e,t,n,r,i){const o={};let a;const s=n+t.size;for(;n<s&&n<e.byteLength;){const{tag:t,tagSize:s}=Dr(e,n,o,a,r,i);if(null===t)break;t&&("encoding"in t&&(a=t.encoding),void 0===o[t.name]||void 0===t.repeatable?o[t.name]={id:t.id,value:t.value,description:t.description}:(o[t.name]instanceof Array||(o[t.name]=[{id:o[t.name].id,value:o[t.name].value,description:o[t.name].description}]),o[t.name].push({id:t.id,value:t.value,description:t.description}))),n+=5+s}return o}function Dr(e,t,n={},r,i=!1,o=kn){if(function(e,t){return 28!==e.getUint8(t)}(e,t))return{tag:null,tagSize:0};const a=e.getUint16(t+1),s=e.getUint16(t+3);if(!i&&!br.iptc[a])return{tag:void 0,tagSize:s};if(!o.shouldParseTag("iptc",function(e,t){const n=br.iptc[e];return n?"string"==typeof n?n:n&&"string"==typeof n.name?n.name:void 0:t?"undefined-"+e:void 0}(a,i),a))return{tag:void 0,tagSize:s};const c=function(e,t,n){const r=[];for(let i=0;i<n;i++)r.push(e.getUint8(t+i));return r}(e,t+5,s),u={id:a,name:Or(br.iptc[a],a,c),value:c,description:Rr(br.iptc[a],c,n,r)};return function(e){return br.iptc[e]&&br.iptc[e].repeatable}(a)&&(u.repeatable=!0),function(e){return br.iptc[e]&&void 0!==br.iptc[e].encoding_name}(a)&&(u.encoding=br.iptc[a].encoding_name(c)),{tag:u,tagSize:s}}function Or(e,t,n){return e?function(e){return"string"==typeof e}(e)?e:function(e){return"function"==typeof e.name}(e)?e.name(n):e.name:"undefined-"+t}function Rr(e,t,n,r){if(function(e){return e&&void 0!==e.description}(e))try{return e.description(t,n)}catch(e){}return function(e,t){return e&&t instanceof Array}(e,t)?Ir(r,t):t}var Fr={"tiff:Orientation":e=>"1"===e?"Horizontal (normal)":"2"===e?"Mirror horizontal":"3"===e?"Rotate 180":"4"===e?"Mirror vertical":"5"===e?"Mirror horizontal and rotate 270 CW":"6"===e?"Rotate 90 CW":"7"===e?"Mirror horizontal and rotate 90 CW":"8"===e?"Rotate 270 CW":e,"tiff:ResolutionUnit":e=>Kt.ResolutionUnit(parseInt(e,10)),"tiff:XResolution":e=>Mr(Kt.XResolution,e),"tiff:YResolution":e=>Mr(Kt.YResolution,e),"exif:ApertureValue":e=>Mr(Kt.ApertureValue,e),"exif:GPSLatitude":Er,"exif:GPSLongitude":Er,"exif:FNumber":e=>Mr(Kt.FNumber,e),"exif:FocalLength":e=>Mr(Kt.FocalLength,e),"exif:FocalPlaneResolutionUnit":e=>Kt.FocalPlaneResolutionUnit(parseInt(e,10)),"exif:ColorSpace":e=>Kt.ColorSpace(function(e){return"0x"===e.substring(0,2)?parseInt(e.substring(2),16):parseInt(e,10)}(e)),"exif:ComponentsConfiguration"(e,t){if(/^\d, \d, \d, \d$/.test(t)){const e=t.split(", ").map((e=>e.charCodeAt(0)));return Kt.ComponentsConfiguration(e)}return t},"exif:Contrast":e=>Kt.Contrast(parseInt(e,10)),"exif:CustomRendered":e=>Kt.CustomRendered(parseInt(e,10)),"exif:ExposureMode":e=>Kt.ExposureMode(parseInt(e,10)),"exif:ExposureProgram":e=>Kt.ExposureProgram(parseInt(e,10)),"exif:ExposureTime":e=>Ur(e)?Kt.ExposureTime(e.split("/").map((e=>parseInt(e,10)))):e,"exif:MeteringMode":e=>Kt.MeteringMode(parseInt(e,10)),"exif:Saturation":e=>Kt.Saturation(parseInt(e,10)),"exif:SceneCaptureType":e=>Kt.SceneCaptureType(parseInt(e,10)),"exif:Sharpness":e=>Kt.Sharpness(parseInt(e,10)),"exif:ShutterSpeedValue":e=>Mr(Kt.ShutterSpeedValue,e),"exif:WhiteBalance":e=>Kt.WhiteBalance(parseInt(e,10))};function Mr(e,t){return Ur(t)?e(t.split("/")):t}function Ur(e){return/^-?\d+\/-?\d+$/.test(e)}function Er(e){const[t,n]=e.split(",");if(void 0!==t&&void 0!==n){const e=parseFloat(t),r=parseFloat(n),i=n.charAt(n.length-1);if(!Number.isNaN(e)&&!Number.isNaN(r))return""+(e+r/60)+i}return e}var Nr=function(e){if(e)return e;if("undefined"!=typeof DOMParser)return new DOMParser;try{const{DOMParser:e,onErrorStopParsing:t}=__non_webpack_require__("@xmldom/xmldom");return new e({onError:t})}catch(e){return}};const Gr={xmp:"http://ns.adobe.com/xap/1.0/",tiff:"http://ns.adobe.com/tiff/1.0/",exif:"http://ns.adobe.com/exif/1.0/",dc:"http://purl.org/dc/elements/1.1/",xmpMM:"http://ns.adobe.com/xap/1.0/mm/",stEvt:"http://ns.adobe.com/xap/1.0/sType/ResourceEvent#",stRef:"http://ns.adobe.com/xap/1.0/sType/ResourceRef#",photoshop:"http://ns.adobe.com/photoshop/1.0/"};var Lr=function(e,t,n){const r={};if("string"==typeof e)return _r(r,e,n),r;const[i,o]=function(e,t){if(0===t.length)return[];const n=[jr(e,t.slice(0,1))];return t.length>1&&n.push(jr(e,t.slice(1))),n}(e,t),a=_r(r,i,n);if(o){const i=_r(r,o,n);a||i||(delete r._raw,_r(r,jr(e,t),n))}return r};class Br extends Error{constructor(e){super(e),this.name="ParseError"}}function jr(e,t){const n=t.reduce(((e,t)=>e+t.length),0),r=new Uint8Array(n);let i=0;for(let n=0;n<t.length;n++){const o=t[n],a=e.buffer.slice(o.dataOffset,o.dataOffset+o.length);r.set(new Uint8Array(a),i),i+=o.length}return new DataView(r.buffer)}function _r(e,t,n){try{const{doc:r,raw:i}=function(e,t){const n=Nr(t);if(!n)throw console.warn("Warning: DOMParser is not available. It is needed to be able to parse XMP tags."),Error();const r="string"==typeof e?e:d(e,0,e.byteLength);return{doc:Vr(n,function(e){return e.replace(/^.+(<\?xpacket begin)/,"$1").replace(/(<\?xpacket end=".*"\?>).+$/,"$1")}(r)),raw:r}}(t,n);return e._raw=(e._raw||"")+i,b(e,Wr(Hr(zr(r),!0))),!0}catch(e){return!1}}function Vr(e,t,n=!1){try{const n=e.parseFromString(t,"application/xml"),r=n.getElementsByTagName("parsererror");if(r.length>0)throw new Br(r[0].textContent);return n}catch(r){if("ParseError"===r.name&&function(e){const t=["prefix is non-null and namespace is null","prefix not bound to a namespace","prefix inte bundet till en namnrymd",/Namespace prefix .+ is not defined/];for(let n=0;n<t.length;n++)if(RegExp(t[n]).test(e.message))return!0;return!1}(r)&&!n)return Vr(e,function(e){const t=e.match(/<([A-Za-z_][A-Za-z0-9._-]*)([^>]*)>/);if(!t)return e;const n=t[1],r=function(e){const t=[],n=/xmlns:([\w-]+)=["'][^"']+["']/g;let r;for(;null!==(r=n.exec(e));)-1===t.indexOf(r[1])&&t.push(r[1]);return t}(e),i=function(e){const t=[],n=/\b([A-Za-z_][A-Za-z0-9._-]*):[A-Za-z_][A-Za-z0-9._-]*\b/g;let r;for(;null!==(r=n.exec(e));){const e=r[1];"xmlns"!==e&&"xml"!==e&&-1===t.indexOf(e)&&t.push(e)}return t}(e).filter((e=>-1===r.indexOf(e)));return 0===i.length?e:function(e,t,n){const r=RegExp("<"+t+"([^>]*)>");return e.replace(r,"<"+t+"$1"+n+">")}(e,n,function(e){const t=[];for(let n=0;n<e.length;n++){const r=e[n];t.push(" xmlns:"+r+'="'+(Gr[r]||"http://fallback.namespace/"+r)+'"')}return t.join("")}(i))}(t),!0);throw r}}function zr(e){for(let t=0;t<e.childNodes.length;t++){if("x:xmpmeta"===e.childNodes[t].tagName)return zr(e.childNodes[t]);if("rdf:RDF"===e.childNodes[t].tagName)return e.childNodes[t]}throw Error()}function Hr(e,t=!1){const n=function(e){const t=[];for(let n=0;n<e.childNodes.length;n++)t.push(e.childNodes[n]);return t}(e);return function(e){return 1===e.length&&"#text"===e[0].nodeName}(n)?t?{}:function(e){return e.nodeValue}(n[0]):function(e){const t={};return e.forEach((e=>{if(function(e){return e.nodeName&&"#text"!==e.nodeName}(e)){const n=function(e){return{attributes:$r(e),value:Hr(e)}}(e);void 0!==t[e.nodeName]?(Array.isArray(t[e.nodeName])||(t[e.nodeName]=[t[e.nodeName]]),t[e.nodeName].push(n)):t[e.nodeName]=n}})),t}(n)}function $r(e){const t={};for(let n=0;n<e.attributes.length;n++)t[e.attributes[n].nodeName]=decodeURIComponent(escape(e.attributes[n].value));return t}function Wr(e){const t={};if("string"==typeof e)return e;for(const n in e){let r=e[n];Array.isArray(r)||(r=[r]),r.forEach((e=>{b(t,Xr(e.attributes)),"object"==typeof e.value&&b(t,Qr(e.value))}))}return t}function Xr(e){const t={};for(const n in e)try{Kr(n)&&(t[qr(n)]={value:e[n],attributes:{},description:Jr(e[n],n)})}catch(e){}return t}function Kr(e){return"rdf:parseType"!==e&&!Yr(e)}function Yr(e){return"xmlns"===e.split(":")[0]}function qr(e){return/^MicrosoftPhoto(_\d+_)?:Rating$/i.test(e)?"RatingPercent":e.split(":")[1]}function Jr(e,t){if(Array.isArray(e)){const n=function(e){return e.map((e=>Jr(void 0!==e.value?e.value:e))).join(", ")}(e);return t&&"function"==typeof Fr[t]?Fr[t](e,n):n}if("object"==typeof e)return function(e){const t=[];for(const n in e)t.push(`${Zr(n)}: ${Jr(e[n].value)}`);return t.join("; ")}(e);try{return t&&"function"==typeof Fr[t]?Fr[t](e):decodeURIComponent(escape(e))}catch(t){return e}}function Zr(e){return"CiAdrCity"===e?"CreatorCity":"CiAdrCtry"===e?"CreatorCountry":"CiAdrExtadr"===e?"CreatorAddress":"CiAdrPcode"===e?"CreatorPostalCode":"CiAdrRegion"===e?"CreatorRegion":"CiEmailWork"===e?"CreatorWorkEmail":"CiTelWork"===e?"CreatorWorkPhone":"CiUrlWork"===e?"CreatorWorkUrl":e}function Qr(e){const t={};for(const n in e)try{Yr(n)||(t[qr(n)]=ei(e[n],n))}catch(e){}return t}function ei(e,t){return function(e){return Array.isArray(e)}(e)?function(e,t){return ui(e[e.length-1],t)}(e,t):function(e){return"Resource"===e.attributes["rdf:parseType"]&&"string"==typeof e.value&&""===e.value.trim()}(e)?{value:"",attributes:{},description:""}:ti(e)?ni(e,t):ii(e)?oi(e,t):ai(e)?si(e,t):function(e){return void 0!==ci(e.value)}(e)?function(e,t){let n=ci(e.value).value["rdf:li"];const r=ri(e),i=[];return void 0===n?n=[]:Array.isArray(n)||(n=[n]),n.forEach((e=>{i.push(function(e){return ti(e)?ni(e):ii(e)?oi(e).value:ai(e)?si(e).value:ui(e)}(e))})),{value:i,attributes:r,description:Jr(i,t)}}(e,t):ui(e,t)}function ti(e){return"Resource"===e.attributes["rdf:parseType"]&&void 0!==e.value["rdf:value"]||void 0!==e.value["rdf:Description"]&&void 0!==e.value["rdf:Description"].value["rdf:value"]}function ni(e,t){const n=ri(e);void 0!==e.value["rdf:Description"]&&(e=e.value["rdf:Description"]),b(n,ri(e),function(e){const t={};for(const n in e.value)"rdf:value"===n||Yr(n)||(t[qr(n)]=e.value[n].value);return t}(e));const r=function(e){return fi(e.value["rdf:value"])||e.value["rdf:value"].value}(e);return{value:r,attributes:n,description:Jr(r,t)}}function ri(e){const t={};for(const n in e.attributes)"rdf:parseType"===n||"rdf:resource"===n||Yr(n)||(t[qr(n)]=e.attributes[n]);return t}function ii(e){return"Resource"===e.attributes["rdf:parseType"]||void 0!==e.value["rdf:Description"]&&void 0===e.value["rdf:Description"].value["rdf:value"]}function oi(e,t){const n={value:{},attributes:{}};return void 0!==e.value["rdf:Description"]&&(b(n.value,Xr(e.value["rdf:Description"].attributes)),b(n.attributes,ri(e)),e=e.value["rdf:Description"]),b(n.value,Qr(e.value)),n.description=Jr(n.value,t),n}function ai(e){return 0===Object.keys(e.value).length&&void 0===e.attributes["xml:lang"]&&void 0===e.attributes["rdf:resource"]}function si(e,t){const n=Xr(e.attributes);return{value:n,attributes:{},description:Jr(n,t)}}function ci(e){return e["rdf:Bag"]||e["rdf:Seq"]||e["rdf:Alt"]}function ui(e,t){const n=fi(e)||Wr(e.value);return{value:n,attributes:ri(e),description:Jr(n,t)}}function fi(e){return e.attributes&&e.attributes["rdf:resource"]}const li=0,di=1,pi=2,mi=3,gi=4,hi=5,bi=6,vi=7,yi=8;var wi={2e3:{name:"PathInformation",description:function(e){const t={},n=[];for(let r=0;r<e.byteLength;r+=26){const i=pn.getShortAt(e,r);xi[i]&&(t[i]||(t[i]=xi[i].description),n.push({type:i,path:xi[i].path(e,r+2)}))}return JSON.stringify({types:t,paths:n})}},2999:{name:"ClippingPathName",description(e){const[,t]=g(e,0);return t}}};const xi={[li]:{description:"Closed subpath length",path:(e,t)=>[pn.getShortAt(e,t)]},[di]:{description:"Closed subpath Bezier knot, linked",path:Si},[pi]:{description:"Closed subpath Bezier knot, unlinked",path:Si},[mi]:{description:"Open subpath length",path:(e,t)=>[pn.getShortAt(e,t)]},[gi]:{description:"Open subpath Bezier knot, linked",path:Si},[hi]:{description:"Open subpath Bezier knot, unlinked",path:Si},[bi]:{description:"Path fill rule",path:()=>[]},[yi]:{description:"Initial fill rule",path:(e,t)=>[pn.getShortAt(e,t)]},[vi]:{description:"Clipboard",path:function(e,t){return[[Ci(e,t,8),Ci(e,t+4,8),Ci(e,t+8,8),Ci(e,t+12,8)],Ci(e,t+16,8)]}}};function Si(e,t){const n=[];for(let r=0;r<24;r+=8)n.push(Ii(e,t+r));return n}function Ii(e,t){const n=Ci(e,t,8);return[Ci(e,t+4,8),n]}function Ci(e,t,n){const r=pn.getLongAt(e,t),i=r>>>31==0?1:-1,o=(2130706432&r)>>>32-n,a=r&parseInt(w("1",32-n),2);return i*function(e){return parseInt(e.replace(".",""),2)/Math.pow(2,(e.split(".")[1]||"").length)}(o.toString(2)+"."+function(e,t){return w("0",t-e.length)+e}(a.toString(2),32-n))}var Pi=function(e,t,n=kn){const r=l(new Uint8Array(e).buffer),i={};let o=0;for(;o<e.length;){const e=d(r,o,Di);o+=Di;const a=pn.getShortAt(r,o);o+=Ti;const{tagName:s,tagNameSize:c}=Ri(r,o);o+=c;const u=pn.getLongAt(r,o);if(o+=Ai,e===ki){const e=Oi(a,s,t);if(!n.shouldParseTag("photoshop",e,a)){o+=u+u%2;continue}const c=l(r.buffer,o,u),f={id:a,value:d(c,0,u)};if(wi[a]){try{f.description=wi[a].description(c)}catch(e){f.description="<no description formatter>"}i[s||wi[a].name]=f}else t&&(i["undefined-"+a]=f)}o+=u+u%2}return i};const ki="8BIM",Ti=2,Ai=4,Di=ki.length;function Oi(e,t,n){return t||(wi[e]&&wi[e].name?wi[e].name:n?"undefined-"+e:void 0)}function Ri(e,t){const[n,r]=g(e,t);return{tagName:r,tagNameSize:1+n+(n%2==0?1:0)}}const Fi={desc:{name:"ICC Description"},cprt:{name:"ICC Copyright"},dmdd:{name:"ICC Device Model Description"},vued:{name:"ICC Viewing Conditions Description"},dmnd:{name:"ICC Device Manufacturer for Display"},tech:{name:"Technology"}},Mi={4:{name:"Preferred CMM type",value:(e,t)=>d(e,t,4),description:e=>null!==e?Ui(e):""},8:{name:"Profile Version",value:(e,t)=>e.getUint8(t).toString(10)+"."+(e.getUint8(t+1)>>4).toString(10)+"."+(e.getUint8(t+1)%16).toString(10)},12:{name:"Profile/Device class",value:(e,t)=>d(e,t,4),description:e=>{switch(e.toLowerCase()){case"scnr":return"Input Device profile";case"mntr":return"Display Device profile";case"prtr":return"Output Device profile";case"link":return"DeviceLink profile";case"abst":return"Abstract profile";case"spac":return"ColorSpace profile";case"nmcl":return"NamedColor profile";case"cenc":return"ColorEncodingSpace profile";case"mid ":return"MultiplexIdentification profile";case"mlnk":return"MultiplexLink profile";case"mvis":return"MultiplexVisualization profile";default:return e}}},16:{name:"Color Space",value:(e,t)=>d(e,t,4)},20:{name:"Connection Space",value:(e,t)=>d(e,t,4)},24:{name:"ICC Profile Date",value:(e,t)=>function(e,t){const n=e.getUint16(t),r=e.getUint16(t+2)-1,i=e.getUint16(t+4),o=e.getUint16(t+6),a=e.getUint16(t+8),s=e.getUint16(t+10);return new Date(Date.UTC(n,r,i,o,a,s))}(e,t).toISOString()},36:{name:"ICC Signature",value:(e,t)=>function(e){return String.fromCharCode.apply(null,new Uint8Array(e))}(e.buffer.slice(t,t+4))},40:{name:"Primary Platform",value:(e,t)=>d(e,t,4),description:e=>Ui(e)},48:{name:"Device Manufacturer",value:(e,t)=>d(e,t,4),description:e=>Ui(e)},52:{name:"Device Model Number",value:(e,t)=>d(e,t,4)},64:{name:"Rendering Intent",value:(e,t)=>e.getUint32(t),description:e=>{switch(e){case 0:return"Perceptual";case 1:return"Relative Colorimetric";case 2:return"Saturation";case 3:return"Absolute Colorimetric";default:return e}}},80:{name:"Profile Creator",value:(e,t)=>d(e,t,4)}};function Ui(e){switch(e.toLowerCase()){case"appl":return"Apple";case"adbe":return"Adobe";case"msft":return"Microsoft";case"sunw":return"Sun Microsystems";case"sgi":return"Silicon Graphics";case"tgnt":return"Taligent";default:return e}}var Ei=function(e,t,n,r){return n&&t[0].compressionMethod!==x?function(e,t,n){if(!function(e){return 0===e}(t[0].compressionMethod))return{};return I(new DataView(e.buffer.slice(t[0].offset,t[0].offset+t[0].length)),t[0].compressionMethod,"utf-8","dataview",n).then($i).catch((()=>({})))}(e,t,r):function(e,t){try{const n=t.reduce(((e,t)=>e+t.length),0),r=new Uint8Array(n);let i=0;const o=function(e){return Array.isArray(e)?new DataView(Uint8Array.from(e).buffer).buffer:e.buffer}(e);for(let e=1;e<=t.length;e++){const n=t.find((t=>t.chunkNumber===e));if(!n)throw Error(`ICC chunk ${e} not found`);const a=o.slice(n.offset,n.offset+n.length),s=new Uint8Array(a);r.set(s,i),i+=s.length}return $i(new DataView(r.buffer))}catch(e){return{}}}(e,t)};const Ni=84,Gi=128,Li="acsp",Bi="desc",ji="mluc",_i="text",Vi="sig ",zi=12;function Hi(e,t){return e.length<t+zi}function $i(e){const t=e.buffer,n=e.getUint32();if(e.byteLength!==n)throw Error("ICC profile length not matching");if(e.byteLength<Ni)throw Error("ICC profile too short");const r={},i=Object.keys(Mi);for(let t=0;t<i.length;t++){const n=i[t],o=Mi[n],a=o.value(e,parseInt(n,10));let s=a;o.description&&(s=o.description(a)),r[o.name]={value:a,description:s}}if(Wi(t.slice(36,40))!==Li)throw Error("ICC profile: missing signature");if(function(e){return e.length<Gi+4}(t))return r;const o=e.getUint32(128);let a=132;for(let n=0;n<o;n++){if(Hi(t,a))return r;const n=d(e,a,4),i=e.getUint32(a+4),o=e.getUint32(a+8);if(i>t.length)return r;const s=d(e,i,4);if(s===Bi){const a=e.getUint32(i+8);if(a>o)return r;Xi(r,n,Wi(t.slice(i+12,i+a+11)))}else if(s===ji){const t=e.getUint32(i+8),o=e.getUint32(i+12);if(o<12)return r;if(t*o>e.byteLength-i-16)return r;let a=i+16;const s=[];for(let n=0;n<t;n++){const t=d(e,a+0,2),n=d(e,a+2,2),r=e.getUint32(a+4),c=e.getUint32(a+8),u=m(e,i+c,r);s.push({languageCode:t,countryCode:n,text:u}),a+=o}if(1===t)Xi(r,n,s[0].text);else{const e={};for(let t=0;t<s.length;t++)e[`${s[t].languageCode}-${s[t].countryCode}`]=s[t].text;Xi(r,n,e)}}else s===_i?Xi(r,n,Wi(t.slice(i+8,i+o-7))):s===Vi&&Xi(r,n,Wi(t.slice(i+8,i+12)));a+=12}return r}function Wi(e){return String.fromCharCode.apply(null,new Uint8Array(e))}function Xi(e,t,n){Fi[t]?e[Fi[t].name]={value:n,description:n}:e[t]={value:n,description:n}}var Ki=function(e,t,n,r,i,o=!1,a){let s=Nn(e,cn,t,t+n,r,i,o,a,"makerNotes");return s.ShotInfo&&(s=b({},s,function(e){const t={};return void 0!==e[27]&&(t.AutoRotate={value:e[27],description:Yi(e[27])}),t}(s.ShotInfo.value)),delete s.ShotInfo),s.CameraSettings&&(s=b({},s,function(e){const t={};if(!Array.isArray(e))return t;const n=e[22];return Number.isFinite(n)&&(t.LensType={value:n,description:""+n}),t}(s.CameraSettings.value)),delete s.CameraSettings),s};function Yi(e){return 0===e?"None":1===e?"Rotate 90 CW":2===e?"Rotate 180":3===e?"Rotate 270 CW":"Unknown"}const qi={K3_III:78420},Ji={CAMERA_ORIENTATION:1,ROLL_ANGLE:3,PITCH_ANGLE:5};var Zi=function(e,t,n,r,i=!1,o){const a=K(e,t+n+8),s=t+n;let c=Nn(e,un,s,s+10,a,r,i,o,"makerNotes");return function(e){return e.PentaxModelID&&e.PentaxModelID.value===qi.K3_III&&e.LevelInfo}(c)&&(c=b({},c,function(e,t,n){const r={};if(t+7>e.byteLength)return r;const i=e.getInt8(t+Ji.CAMERA_ORIENTATION);r.CameraOrientation={value:i,description:Qi(i)};const o=e.getInt16(t+Ji.ROLL_ANGLE,n===X);r.RollAngle={value:o,description:eo(o)};const a=e.getInt16(t+Ji.PITCH_ANGLE,n===X);return r.PitchAngle={value:a,description:to(a)},r}(e,s+c.LevelInfo.__offset,a)),delete c.LevelInfo),c};function Qi(e){return 0===e?"Horizontal (normal)":1===e?"Rotate 270 CW":2===e?"Rotate 180":3===e?"Rotate 90 CW":4===e?"Upwards":5===e?"Downwards":"Unknown"}function eo(e){return""+-.5*e}function to(e){return""+-.5*e}var no=function(e,t){return{"Image Width":ro(e,t),"Image Height":io(e,t),"Bit Depth":oo(e,t),"Color Type":ao(e,t),Compression:so(e,t),Filter:co(e,t),Interlace:uo(e,t)}};function ro(e,t){if(t+0+4>e.byteLength)return;const n=pn.getLongAt(e,t);return{value:n,description:n+"px"}}function io(e,t){if(t+4+4>e.byteLength)return;const n=pn.getLongAt(e,t+4);return{value:n,description:n+"px"}}function oo(e,t){if(t+8+1>e.byteLength)return;const n=pn.getByteAt(e,t+8);return{value:n,description:""+n}}function ao(e,t){if(t+9+1>e.byteLength)return;const n=pn.getByteAt(e,t+9);return{value:n,description:{0:"Grayscale",2:"RGB",3:"Palette",4:"Grayscale with Alpha",6:"RGB with Alpha"}[n]||"Unknown"}}function so(e,t){if(t+10+1>e.byteLength)return;const n=pn.getByteAt(e,t+10);return{value:n,description:0===n?"Deflate/Inflate":"Unknown"}}function co(e,t){if(t+11+1>e.byteLength)return;const n=pn.getByteAt(e,t+11);return{value:n,description:0===n?"Adaptive":"Unknown"}}function uo(e,t){if(t+12+1>e.byteLength)return;const n=pn.getByteAt(e,t+12);return{value:n,description:{0:"Noninterlaced",1:"Adam7 Interlace"}[n]||"Unknown"}}var fo=function(e,t,n,r,i=!1,o=kn,a){const s={},c=[];for(let u=0;u<t.length;u++){const{offset:f,length:l,type:d}=t[u],p=wo(e,f,l,d,n,a);if(p instanceof Promise)c.push(p.then((({name:e,value:t,description:n})=>{try{if(T.USE_EXIF&&ko(e,t))return o.shouldParseGroup("exif")?{__exif:$n(Ao(t),yo,r,i,o).tags}:{};if(T.USE_IPTC&&To(e,t))return o.shouldParseGroup("iptc")?{__iptc:Cr(Ao(t),0,r,o)}:{};if(e&&!ko(e,t)&&!To(e,t))return o.shouldParseGroup("png")?{[e]:{value:t,description:n}}:{}}catch(e){}return{}})));else{const{name:e,value:t,description:n}=p;e&&o.shouldParseGroup("png")&&(s[e]={value:t,description:n})}}return{readTags:s,readTagsPromise:c.length>0?Promise.all(c):void 0}};const lo="STATE_KEYWORD",po="STATE_COMPRESSION",mo="STATE_LANG",go="STATE_TRANSLATED_KEYWORD",ho="STATE_TEXT",bo=1,vo=1,yo=6;function wo(e,t,n,r,i,o){const a=[],s=[];let c,u=lo,f=x;for(let i=0;i<n&&t+i<e.byteLength;i++){if(u===po){f=xo({type:r,dataView:e,offset:t+i}),r===it&&(i+=bo),u=So(r,u);continue}if(u===ho){c=new DataView(e.buffer.slice(t+i,t+n));break}const o=e.getUint8(t+i);0===o?u=So(r,u):u===lo?a.push(o):u===mo&&s.push(o)}if(f!==x&&!i)return{};const l=I(c,f,function(e){return e===rt||e===ot?"latin1":"utf-8"}(r),"string",o);return l instanceof Promise?l.then((e=>Io(e,r,s,a))).catch((()=>Io("<text using unknown compression>".split(""),r,s,a))):Io(l,r,s,a)}function xo({type:e,dataView:t,offset:n}){if(e===it){if(t.getUint8(n)===vo)return t.getUint8(n+1)}else if(e===ot)return t.getUint8(n);return x}function So(e,t){return t===lo&&[it,ot].includes(e)?po:t===po?e===it?mo:ho:t===mo?go:ho}function Io(e,t,n,r){const i=function(e){return e instanceof DataView?d(e,0,e.byteLength):e}(e);return{name:Co(t,n,r),value:i,description:t===it?Po(e):i}}function Co(e,t,n){const r=h(n);return e===rt||0===t.length?r:`${r} (${h(t)})`}function Po(e){return Ir("UTF-8",e)}function ko(e,t){return"raw profile type exif"===e.toLowerCase()&&"exif"===t.substring(1,5)}function To(e,t){return"raw profile type iptc"===e.toLowerCase()&&"iptc"===t.substring(1,5)}function Ao(e){return function(e){const t=new DataView(new ArrayBuffer(e.length/2));for(let n=0;n<e.length;n+=2)t.setUint8(n/2,parseInt(e.substring(n,n+2),16));return t}(e.match(/\n(exif|iptc)\n\s*\d+\n([\s\S]*)$/)[2].replace(/\n/g,""))}var Do=function(e,t){const n={};for(let r=0;r<t.length;r++){const i=pn.getLongAt(e,t[r]+Qe),o=d(e,t[r]+et,Ze);o===at?(n["Pixels Per Unit X"]=Oo(e,t[r],i),n["Pixels Per Unit Y"]=Ro(e,t[r],i),n["Pixel Units"]=Fo(e,t[r],i)):o===st&&(n["Modify Date"]=Mo(e,t[r],i))}return n};function Oo(e,t,n){if(!Uo(e,t,n,0,4))return;const r=pn.getLongAt(e,t+tt+0);return{value:r,description:""+r}}function Ro(e,t,n){if(!Uo(e,t,n,4,4))return;const r=pn.getLongAt(e,t+tt+4);return{value:r,description:""+r}}function Fo(e,t,n){if(!Uo(e,t,n,8,1))return;const r=pn.getByteAt(e,t+tt+8);return{value:r,description:1===r?"meters":"Unknown"}}function Mo(e,t,n){if(!Uo(e,t,n,0,7))return;const r=pn.getShortAt(e,t+tt),i=pn.getByteAt(e,t+tt+2),o=pn.getByteAt(e,t+tt+3),a=pn.getByteAt(e,t+tt+4),s=pn.getByteAt(e,t+tt+5),c=pn.getByteAt(e,t+tt+6);return{value:[r,i,o,a,s,c],description:`${Eo(r,4)}-${Eo(i,2)}-${Eo(o,2)} ${Eo(a,2)}:${Eo(s,2)}:${Eo(c,2)}`}}function Uo(e,t,n,r,i){return r+i<=n&&t+tt+r+i<=e.byteLength}function Eo(e,t){return`${"0".repeat(t-(""+e).length)}${e}`}var No=function(e,t){const n={},r=pn.getByteAt(e,t);return n.Alpha=function(e){const t=16&e;return{value:t?1:0,description:t?"Yes":"No"}}(r),n.Animation=function(e){const t=2&e;return{value:t?1:0,description:t?"Yes":"No"}}(r),n.ImageWidth=Bo(e,t+Go),n.ImageHeight=Bo(e,t+Lo),n};const Go=4,Lo=7;function Bo(e,t){const n=pn.getByteAt(e,t)+256*pn.getByteAt(e,t+1)+65536*pn.getByteAt(e,t+2)+1;return{value:n,description:n+"px"}}var jo=function(e){return{"GIF Version":_o(e),"Image Width":Vo(e),"Image Height":zo(e),"Global Color Map":Ho(e),"Bits Per Pixel":Wo(e),"Color Resolution Depth":$o(e)}};function _o(e){if(6>e.byteLength)return;const t=d(e,3,3);return{value:t,description:t}}function Vo(e){if(8>e.byteLength)return;const t=e.getUint16(6,!0);return{value:t,description:t+"px"}}function zo(e){if(10>e.byteLength)return;const t=e.getUint16(8,!0);return{value:t,description:t+"px"}}function Ho(e){if(11>e.byteLength)return;const t=(128&e.getUint8(10))>>>7;return{value:t,description:1===t?"Yes":"No"}}function $o(e){if(11>e.byteLength)return;const t=1+((112&e.getUint8(10))>>>4);return{value:t,description:`${t} ${1===t?"bit":"bits"}`}}function Wo(e){if(11>e.byteLength)return;const t=1+(7&e.getUint8(10));return{value:t,description:`${t} ${1===t?"bit":"bits"}`}}const Xo=[6,7,99];var Ko={get:function(e,t,n){if(function(e){return e&&(void 0===e.Compression||Xo.includes(e.Compression.value))&&e.JPEGInterchangeFormat&&e.JPEGInterchangeFormat.value&&e.JPEGInterchangeFormatLength&&e.JPEGInterchangeFormatLength.value}(t)){t.type="image/jpeg";const r=n+t.JPEGInterchangeFormat.value;t.image=e.buffer.slice(r,r+t.JPEGInterchangeFormatLength.value),v(t,"base64",(function(){return y(this.image)}))}return t}};var Yo={get:function(e,t){const n={};let r=!1;const i=qo(e,"exif","FocalLength",t),o=qo(e,"exif","FocalPlaneXResolution",t),a=qo(e,"exif","FocalPlaneYResolution",t),s=qo(e,"exif","FocalPlaneResolutionUnit",t),c=qo(e,"file","Image Width",t),u=qo(e,"file","Image Height",t),f=qo(e,"exif","FocalLengthIn35mmFilm",t)||function(e,t,n,r,i,o){if(e&&t&&n&&r&&i&&o)try{let a;switch(n){case 2:a=25.4;break;case 3:a=10;break;case 4:a=1;break;default:return}return o[0]/o[1]*(43.27/Math.sqrt((r/(e[0]/e[1]*a))**2+(i/(t[0]/t[1]*a))**2))}catch(e){}}(o,a,s,c,u,i);f&&(n.FocalLength35efl={value:f,description:Kt.FocalLengthIn35mmFilm(f)},r=!0);const l=function(e,t){if(e&&t)try{const n=t/(e[0]/e[1]);return{value:n,description:n.toFixed(1)}}catch(e){}}(i,f);l&&(n.ScaleFactorTo35mmEquivalent=l,r=!0);const d=function(e){if(e)try{const t=2*Math.atan(36/(2*e))*(180/Math.PI);return{value:t,description:t.toFixed(1)+" deg"}}catch(e){}}(f);if(d&&(n.FieldOfView=d,r=!0),r)return n}};function qo(e,t,n,r){return r&&e[t]&&e[t][n]?e[t][n].value:!r&&e[n]?e[n].value:void 0}function Jo({mergeSteps:e,deferredResults:t,parsedGroups:n,expanded:r,tagFilter:i,dataView:o,tiffHeaderOffset:a,fileType:s,pngTextChunks:c,pngTextIsAsync:u,thumbnailIfdTags:f,deps:l}){let d={};for(let c=0;c<e.length;c++)d=Zo({step:e[c],deferredResults:t,parsedGroups:n,expanded:r,tagFilter:i,dataView:o,tiffHeaderOffset:a,fileType:s,thumbnailIfdTags:f,tags:d,deps:l});return r&&u&&i.shouldReturnGroup("png")&&d.png&&(d.pngText=l.objectAssign({},d.png)),r&&i.shouldReturnGroup("png")&&l.hasPngTextData(c)&&d.png&&!d.pngText&&(d.pngText=l.objectAssign({},d.png)),d}function Zo({step:e,deferredResults:t,parsedGroups:n,expanded:r,tagFilter:i,dataView:o,tiffHeaderOffset:a,fileType:s,thumbnailIfdTags:c,tags:u,deps:f}){if("mergeGroupAssign"===e.type){const t=f.filterTagsForReturn(e.groupKey,e.parsedTags,i);return Qo(u,e.groupKey,t,r,f)}if("mergeGroupMerge"===e.type){const t=f.filterTagsForReturn(e.groupKey,e.parsedTags,i);return function(e,t,n,r,i){return r?(e[t]=e[t]?i.objectAssign({},e[t],n):n,e):i.objectAssign({},e,n)}(u,e.groupKey,t,r,f)}if("mergeXmpGroupAssign"===e.type){const t=f.filterTagsForReturn("xmp",e.parsedTags,i);if(r)return u.xmp=t,u;const n=f.objectAssign({},t);return delete n._raw,f.objectAssign({},u,n)}if("mergeIccDeferred"===e.type){const o=f.filterTagsForParse("icc",t[e.deferredKey],i);return n.icc=o,i.shouldReturnGroup("icc")?Qo(u,"icc",f.filterTagsForReturn("icc",o,i),r,f):u}if("mergeBrobExifDeferred"===e.type){const o=t[e.deferredKey];if(!o||0===Object.keys(o).length)return u;const a=f.filterTagsForParse("exif",o,i);return n.exif=n.exif?f.objectAssign({},n.exif,a):a,i.shouldReturnGroup("exif")?Qo(u,"exif",f.filterTagsForReturn("exif",a,i),r,f):u}if("mergeBrobXmpDeferred"===e.type){const o=t[e.deferredKey];if(!o||0===Object.keys(o).length)return u;const a=f.filterTagsForParse("xmp",o,i);if(n.xmp=a,!i.shouldReturnGroup("xmp"))return u;const s=f.filterTagsForReturn("xmp",a,i);if(r)return u.xmp=s,u;const c=f.objectAssign({},s);return delete c._raw,f.objectAssign({},u,c)}if("mergePngFile"===e.type){const t=f.filterTagsForReturn("png",e.parsedTags,i);return i.shouldReturnGroup("png")?r?(u.png=u.png?f.objectAssign({},u.png,t):t,u.pngFile=t,u):f.objectAssign({},u,t):u}if("mergePngChunk"===e.type){const t=f.filterTagsForReturn("png",e.parsedTags,i);return i.shouldReturnGroup("png")?r?(u.png=u.png?f.objectAssign({},u.png,t):t,u):f.objectAssign({},u,t):u}if("processPngTextReadTags"===e.type)return ea({readTags:e.readTags,parsedGroups:n,expanded:r,tagFilter:i,tags:u,deps:f});if("processPngTextReadTagsDeferredList"===e.type){const o=t[e.deferredKey]||[];for(let e=0;e<o.length;e++)u=ea({readTags:o[e],parsedGroups:n,expanded:r,tagFilter:i,tags:u,deps:f});return u}if("gps"===e.type){if(r&&i.shouldReturnGroup("gps")&&n.exif){const e=f.getGpsGroupFromExifTags(n.exif);if(e){const t=f.filterTagsForReturn("gps",e,i);u.gps=t}}return u}if("composite"===e.type){if(!i.shouldReturnGroup("composite"))return u;let e=u,t=r;i.isActive&&(e={exif:n.exif,file:n.file},t=!0);const o=f.Composite.get(e,t);return o?Qo(u,"composite",f.filterTagsForReturn("composite",o,i),r,f):u}if("thumbnail"===e.type){if(!i.shouldReturnGroup("thumbnail")||!i.shouldReturnTag("thumbnail","Thumbnail"))return delete u.Thumbnail,u;if(!c)return u;const e=c?f.filterTagsForParse("thumbnail",c,i):void 0;e&&(n.thumbnail=e);const t=(f.Constants.USE_JPEG||f.Constants.USE_WEBP)&&f.Constants.USE_EXIF&&f.Constants.USE_THUMBNAIL&&f.Thumbnail.get(o,e,a);return t?u.Thumbnail=t:delete u.Thumbnail,u}return"fileType"===e.type?(s&&i.shouldReturnGroup("file")&&i.shouldReturnTag("file","FileType")&&(r?(u.file||(u.file={}),u.file.FileType=s):u.FileType=s),u):u}function Qo(e,t,n,r,i){return r?(e[t]=n,e):i.objectAssign({},e,n)}function ea({readTags:e,parsedGroups:t,expanded:n,tagFilter:r,tags:i,deps:o}){const a=e.__exif,s=e.__iptc;if(delete e.__exif,delete e.__iptc,a){const e=o.filterTagsForParse("exif",a,r);if(t.exif=t.exif?o.objectAssign({},t.exif,e):e,r.shouldReturnGroup("exif")){const t=o.filterTagsForReturn("exif",e,r);n?i.exif=i.exif?o.objectAssign({},i.exif,t):t:i=o.objectAssign({},i,t)}}if(s){const e=o.filterTagsForParse("iptc",s,r);if(t.iptc=t.iptc?o.objectAssign({},t.iptc,e):e,r.shouldReturnGroup("iptc")){const t=o.filterTagsForReturn("iptc",e,r);n?i.iptc=i.iptc?o.objectAssign({},i.iptc,t):t:i=o.objectAssign({},i,t)}}if(r.shouldReturnGroup("png")){const a=o.filterTagsForParse("png",e,r),s=o.filterTagsForReturn("png",a,r);t.pngText=a,n?(i.png=i.png?o.objectAssign({},i.png,s):s,s&&Object.keys(s).length>0&&(i.pngText=i.pngText?o.objectAssign({},i.pngText,s):s)):i=o.objectAssign({},i,s)}return i}function ta(e){this.name="MetadataMissingError",this.message=e||"No Exif data",this.stack=Error().stack}ta.prototype=Error();var na={MetadataMissingError:ta},ra=function(e,t={}){if(function(e){return"string"==typeof e}(e)){if(t.async=!0,"undefined"==typeof Promise)throw Error("Promise is required when async mode is enabled.");return function(e,t){return/^\w+:\/\//.test(e)?"undefined"!=typeof fetch?function(e,{length:t}={}){const n={method:"GET"};return Number.isInteger(t)&&t>=0&&(n.headers={range:"bytes=0-"+(t-1)}),fetch(e,n).then((e=>e.arrayBuffer()))}(e,t):function(e,{length:t}={}){return new Promise(((n,r)=>{const i={};Number.isInteger(t)&&t>=0&&(i.headers={range:"bytes=0-"+(t-1)});const o=function(e){return/^https:\/\//.test(e)?__non_webpack_require__("https").get:__non_webpack_require__("http").get}(e);o(e,i,(e=>{if(e.statusCode>=200&&e.statusCode<=299){const t=[];e.on("data",(e=>t.push(Buffer.from(e)))),e.on("error",(e=>r(e))),e.on("end",(()=>n(Buffer.concat(t))))}else r(`Could not fetch file: ${e.statusCode} ${e.statusMessage}`),e.resume()})).on("error",(e=>r(e)))}))}(e,t):function(e){return/^data:[^;,]*(;base64)?,/.test(e)}(e)?Promise.resolve(function(e){const t=e.substring(e.indexOf(",")+1);if(-1!==e.indexOf(";base64")){if("undefined"!=typeof atob)return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer;if("undefined"==typeof Buffer)return;return void 0!==Buffer.from?Buffer.from(t,"base64"):new Buffer(t,"base64")}const n=decodeURIComponent(t);return"undefined"!=typeof Buffer?void 0!==Buffer.from?Buffer.from(n):new Buffer(n):Uint8Array.from(n,(e=>e.charCodeAt(0))).buffer}(e)):function(e,{length:t}={}){return new Promise(((n,r)=>{const i=function(){try{return __non_webpack_require__("fs")}catch(e){return}}();i.open(e,((o,a)=>{o?r(o):i.stat(e,((o,s)=>{if(o)r(o);else{const o=Math.min(s.size,void 0!==t?t:s.size),c=Buffer.alloc(o);i.read(a,{buffer:c,length:o},(t=>{t?r(t):i.close(a,(t=>{t&&console.warn(`Could not close file ${e}:`,t),n(c)}))}))}}))}))}))}(e,t)}(e,t).then((e=>ia(e,t)))}if(function(e){return"undefined"!=typeof File&&e instanceof File}(e)){if(t.async=!0,"undefined"==typeof Promise)throw Error("Promise is required when async mode is enabled.");return function(e,{length:t}){return new Promise(((n,r)=>{const i=new FileReader;i.onload=e=>n(e.target.result),i.onerror=()=>r(i.error),Number.isInteger(t)&&t>=0&&void 0!==e.slice?i.readAsArrayBuffer(e.slice(0,t)):i.readAsArrayBuffer(e)}))}(e,t).then((e=>ia(e,t)))}return ia(e,t)};function ia(e,t){return function(e){try{return Buffer.isBuffer(e)}catch(e){return!1}}(e)&&(e=new Uint8Array(e).buffer),oa(function(e){try{return new DataView(e)}catch(t){return new f(e)}}(e),t)}function oa(e,{expanded:t=!1,async:n=!1,computed:r=!1,includeUnknown:i=!1,domParser:o,includeTags:a,excludeTags:s,decompress:c}={expanded:!1,async:!1,computed:!1,includeUnknown:!1,domParser:void 0,includeTags:void 0,excludeTags:void 0,decompress:void 0}){const u=function({includeTags:e,excludeTags:t}={}){const n=!!e,r=!!t,i=n||r,o=Object.create(null),a=Object.create(null),s=Object.create(null);if(!i)return Pn();const c=n&&(Dn(e,"iptc")||Dn(e,"xmp")||Dn(e,"icc")||Dn(e,"photoshop")||Dn(e,"makerNotes")||Dn(e,"thumbnail")||Dn(e,"gps")||Dn(e,"composite")),u=n&&Dn(e,"composite");let f=Object.create(null);n&&(f=function(e){const t=function(e){const t=Object.create(null);if(!e)return t;Array.isArray(e.exif)&&e.exif.length>0&&(t[yn]=!0,function(e,t){for(let n=0;n<t.length;n++){const r=t[n];if("string"!=typeof r)continue;const i=r.toLowerCase();0===i.indexOf("gps")&&(e[wn]=!0),0!==i.indexOf("interoperability")&&0!==i.indexOf("relatedimage")||(e["Interoperability IFD Pointer"]=!0)}}(t,e.exif));for(const n in xn)if(Cn(e[n])){const e=xn[n];for(let n=0;n<e.length;n++)t[e[n]]=!0;t[yn]=!0}return Cn(e.gps)&&(t[wn]=!0,t[yn]=!0),t}(e);return Dn(e,"composite")&&function(e,t){for(let n=0;n<t.length;n++)e[t[n]]=!0}(t,In),t}(e));let l=Object.create(null);n&&u&&(l=function(e){const t=Object.create(null);for(let n=0;n<e.length;n++)t[e[n].toLowerCase()]=!0;return t}(Sn));for(const i in vn){const d=n&&Object.prototype.hasOwnProperty.call(e,i);let p;r&&Object.prototype.hasOwnProperty.call(t,i)&&!d&&(p=t[i]);const m=Rn({groupKey:i,includeValue:d?e[i]:void 0,excludeValue:p,extraIncludeNames:Object.create(null)});o[i]=!n||d,d&&On(e[i])&&(o[i]=!1),m.excludeAll&&(o[i]=!1),a[i]=m;const g=Rn({groupKey:i,includeValue:Tn({groupKey:i,hasIncludeTags:n,hasIncludeEntry:d,includeTags:e,shouldParseExif:c,shouldParseFile:u}),excludeValue:p,extraIncludeNames:An({groupKey:i,hasIncludeTags:n,hasIncludeEntry:d,shouldParseExif:c,shouldParseFile:u,exifIncludeDependencies:f,fileIncludeDependencies:l})});s[i]=g}return{isActive:i,shouldReturnGroup:d,shouldParseGroup:p,shouldReturnTag:function(e,t,n){return!vn[e]||!!d(e)&&Fn(a[e],t,n)},shouldParseTag:function(e,t,n){return!vn[e]||!!p(e)&&Fn(s[e],t,n)}};function d(e){return!vn[e]||!!o[e]}function p(e){return!vn[e]||!!d(e)||("exif"===e?c:"file"===e&&u)}}({includeTags:a,excludeTags:s}),f=Object.create(null),l=[],d=Object.create(null),p=[];let m,g,v=!1;const{fileType:y,fileDataOffset:w,jfifDataOffset:x,tiffHeaderOffset:C,iptcDataOffset:P,xmpChunks:k,iccChunks:A,mpfDataOffset:D,pngHeaderOffset:O,pngTextChunks:R,pngChunkOffsets:F,vp8xChunkOffset:M,gifHeaderOffset:U,brobExifChunk:E,brobXmpChunk:N,jxlCodestreamOffset:G}=Wt(e,n),L=function({fileType:e,fileDataOffset:t,jfifDataOffset:n,tiffHeaderOffset:r,iptcDataOffset:i,xmpChunks:o,iccChunks:a,mpfDataOffset:s,pngHeaderOffset:c,pngTextChunks:u,pngChunkOffsets:f,vp8xChunkOffset:l,gifHeaderOffset:d,jxlCodestreamOffset:p}){return!!e||T.USE_JPEG&&T.USE_FILE&&fa(t)||T.USE_JPEG&&T.USE_JFIF&&la(n)||T.USE_EXIF&&da(r)||T.USE_JPEG&&T.USE_IPTC&&pa(i)||T.USE_XMP&&ma(o)||(T.USE_JPEG||T.USE_WEBP)&&T.USE_ICC&&ga(a)||T.USE_MPF&&ha(s)||T.USE_PNG&&T.USE_PNG_FILE&&ba(c)||T.USE_PNG&&va(u)||T.USE_PNG&&ya(f)||T.USE_WEBP&&wa(l)||T.USE_GIF&&xa(d)||T.USE_JXL&&Sa(p)}({fileType:y,fileDataOffset:w,jfifDataOffset:x,tiffHeaderOffset:C,iptcDataOffset:P,xmpChunks:k,iccChunks:A,mpfDataOffset:D,pngHeaderOffset:O,pngTextChunks:R,pngChunkOffsets:F,vp8xChunkOffset:M,gifHeaderOffset:U,jxlCodestreamOffset:G});if(T.USE_JPEG&&T.USE_FILE&&fa(w)&&u.shouldParseGroup("file")&&function(e){return!e||(!0===e.composite||(!!(Array.isArray(e.composite)&&e.composite.length>0)||(!e.file||!0===e.file||(!Array.isArray(e.file)||!(1===e.file.length&&"FileType"===e.file[0])))))}(a)){const t=aa("file",Qn(e,w),u);f.file=t,u.shouldReturnGroup("file")&&l.push({type:"mergeGroupAssign",groupKey:"file",parsedTags:t})}if(T.USE_JPEG&&T.USE_JFIF&&la(x)&&u.shouldParseGroup("jfif")){const t=aa("jfif",lr(e,x),u);f.jfif=t,u.shouldReturnGroup("jfif")&&l.push({type:"mergeGroupAssign",groupKey:"jfif",parsedTags:t})}if(T.USE_EXIF&&da(C)&&u.shouldParseGroup("exif")){const{tags:n,byteOrder:a}=$n(e,C,i,r,u);n.Thumbnail&&(m=n.Thumbnail,delete n.Thumbnail);const s=aa("exif",n,u);if(f.exif=s,T.USE_TIFF&&T.USE_IPTC&&s["IPTC-NAA"]&&!pa(P)&&u.shouldParseGroup("iptc")){const e=aa("iptc",Cr(s["IPTC-NAA"].value,0,i,u),u);f.iptc=e,u.shouldReturnGroup("iptc")&&l.push({type:"mergeGroupAssign",groupKey:"iptc",parsedTags:e})}if(T.USE_TIFF&&T.USE_XMP&&s.ApplicationNotes&&!ma(k)&&u.shouldParseGroup("xmp")){const e=aa("xmp",Lr(h(s.ApplicationNotes.value),void 0,o),u);if(f.xmp=e,u.shouldReturnGroup("xmp")){const n={type:"mergeXmpGroupAssign",parsedTags:e};t?l.push(n):g=n}}if(T.USE_PHOTOSHOP&&s.ImageSourceData&&s.PhotoshopSettings&&u.shouldParseGroup("photoshop")){const e=aa("photoshop",Pi(s.PhotoshopSettings.value,i,u),u);f.photoshop=e,u.shouldReturnGroup("photoshop")&&l.push({type:"mergeGroupAssign",groupKey:"photoshop",parsedTags:e})}if(T.USE_TIFF&&T.USE_ICC&&s.ICC_Profile&&!ga(A)&&u.shouldParseGroup("icc")){const e=aa("icc",Ei(s.ICC_Profile.value,[{offset:0,length:s.ICC_Profile.value.length,chunkNumber:1,chunksTotal:1}]),u);f.icc=e,u.shouldReturnGroup("icc")&&l.push({type:"mergeGroupAssign",groupKey:"icc",parsedTags:e})}if(T.USE_MAKER_NOTES&&s.MakerNote&&u.shouldParseGroup("makerNotes"))if(function(e){return e.Make&&e.Make.value&&Array.isArray(e.Make.value)&&"Canon"===e.Make.value[0]&&e.MakerNote&&e.MakerNote.__offset}(s)){const t=Ki(e,C,s.MakerNote.__offset,a,i,r,u);f.makerNotes=t,u.shouldReturnGroup("makerNotes")&&l.push({type:"mergeGroupAssign",groupKey:"makerNotes",parsedTags:t})}else if(function(e){const t="PENTAX ";return e.MakerNote.value.length>7&&h(e.MakerNote.value.slice(0,7))===t&&e.MakerNote.__offset}(s)){const t=Zi(e,C,s.MakerNote.__offset,i,r,u);f.makerNotes=t,u.shouldReturnGroup("makerNotes")&&l.push({type:"mergeGroupAssign",groupKey:"makerNotes",parsedTags:t})}s.MakerNote&&delete s.MakerNote.__offset,u.shouldReturnGroup("exif")&&l.push({type:"mergeGroupAssign",groupKey:"exif",parsedTags:s}),!t&&g&&(l.push(g),g=void 0)}if(T.USE_JPEG&&T.USE_IPTC&&pa(P)&&u.shouldParseGroup("iptc")){const t=aa("iptc",Cr(e,P,i,u),u);f.iptc=t,u.shouldReturnGroup("iptc")&&l.push({type:"mergeGroupAssign",groupKey:"iptc",parsedTags:t})}if(T.USE_XMP&&ma(k)&&u.shouldParseGroup("xmp")){const t=aa("xmp",Lr(e,k,o),u);f.xmp=t,u.shouldReturnGroup("xmp")&&l.push({type:"mergeXmpGroupAssign",parsedTags:t})}if(T.USE_JXL&&T.USE_EXIF&&E&&!da(C)&&u.shouldParseGroup("exif")&&n){const t=new DataView(e.buffer,e.byteOffset+E.dataOffset,E.length);p.push(I(t,S,void 0,"dataview",c).then((e=>{const t=_(e,0),{tags:n}=$n(e,t,i,r,u);n.Thumbnail&&delete n.Thumbnail,d.brobExif=n})).catch((()=>{d.brobExif={}}))),l.push({type:"mergeBrobExifDeferred",deferredKey:"brobExif"})}if(T.USE_JXL&&T.USE_XMP&&N&&!ma(k)&&u.shouldParseGroup("xmp")&&n){const t=new DataView(e.buffer,e.byteOffset+N.dataOffset,N.length);p.push(I(t,S,void 0,"dataview",c).then((e=>{d.brobXmp=Lr(e,[{dataOffset:0,length:e.byteLength}],o)})).catch((()=>{d.brobXmp={}}))),l.push({type:"mergeBrobXmpDeferred",deferredKey:"brobXmp"})}if((T.USE_JPEG||T.USE_WEBP)&&T.USE_ICC&&ga(A)&&u.shouldParseGroup("icc")){const t=Ei(e,A,n,c);if(function(e){return!!e&&"function"==typeof e.then}(t)){if(!n)throw Error("Promise is required when async mode is enabled.");p.push(t.then((e=>{d.iccApp=e}))),l.push({type:"mergeIccDeferred",deferredKey:"iccApp"})}else{const e=aa("icc",t,u);f.icc=e,u.shouldReturnGroup("icc")&&l.push({type:"mergeGroupAssign",groupKey:"icc",parsedTags:e})}}if(T.USE_MPF&&ha(D)&&u.shouldParseGroup("mpf")){const t=aa("mpf",Wn(e,D,i,r,u),u);f.mpf=t,u.shouldReturnGroup("mpf")&&l.push({type:"mergeGroupAssign",groupKey:"mpf",parsedTags:t})}if(T.USE_PNG&&T.USE_PNG_FILE&&ba(O)&&u.shouldParseGroup("png")){const t=aa("png",no(e,O),u);f.pngFile=t,u.shouldReturnGroup("png")&&l.push({type:"mergePngFile",parsedTags:t})}if(T.USE_PNG&&va(R)&&(u.shouldParseGroup("png")||u.shouldParseGroup("exif")||u.shouldParseGroup("iptc"))){const{readTags:t,readTagsPromise:o}=fo(e,R,n,i,r,u,c);v=!!o,l.push({type:"processPngTextReadTags",readTags:t}),o&&(p.push(o.then((e=>{d.pngTextTagList=e}))),l.push({type:"processPngTextReadTagsDeferredList",deferredKey:"pngTextTagList"}))}if(T.USE_PNG&&ya(F)&&u.shouldParseGroup("png")){const t=aa("png",Do(e,F),u);f.pngChunk=t,u.shouldReturnGroup("png")&&l.push({type:"mergePngChunk",parsedTags:t})}if(T.USE_WEBP&&wa(M)&&u.shouldParseGroup("riff")){const t=aa("riff",No(e,M),u);f.riff=t,u.shouldReturnGroup("riff")&&l.push({type:"mergeGroupMerge",groupKey:"riff",parsedTags:t})}if(T.USE_GIF&&xa(U)&&u.shouldParseGroup("gif")){const t=aa("gif",jo(e,U),u);f.gif=t,u.shouldReturnGroup("gif")&&l.push({type:"mergeGroupMerge",groupKey:"gif",parsedTags:t})}if(T.USE_JXL&&Sa(G)&&u.shouldParseGroup("file")){const t=aa("file",ar(e,G),u);f.file=t,u.shouldReturnGroup("file")&&l.push({type:"mergeGroupAssign",groupKey:"file",parsedTags:t})}if(l.push({type:"gps"}),l.push({type:"composite"}),l.push({type:"thumbnail"}),l.push({type:"fileType"}),!L)throw new na.MetadataMissingError;const B={objectAssign:b,hasPngTextData:va,filterTagsForParse:aa,filterTagsForReturn:sa,getGpsGroupFromExifTags:ua,Constants:T,Composite:Yo,Thumbnail:Ko};if(n){if("undefined"==typeof Promise)throw Error("Promise is required when async mode is enabled.");return Promise.all(p).then((()=>Jo({mergeSteps:l,deferredResults:d,parsedGroups:f,expanded:t,tagFilter:u,dataView:e,tiffHeaderOffset:C,fileType:y,pngTextChunks:R,pngTextIsAsync:v,thumbnailIfdTags:m,deps:B})))}return Jo({mergeSteps:l,deferredResults:d,parsedGroups:f,expanded:t,tagFilter:u,dataView:e,tiffHeaderOffset:C,fileType:y,pngTextChunks:R,pngTextIsAsync:v,thumbnailIfdTags:m,deps:B})}function aa(e,t,n){return n.isActive?ca(e,t,n.shouldParseTag):t}function sa(e,t,n){return n.isActive?ca(e,t,n.shouldReturnTag):t}function ca(e,t,n){if(!t)return t;const r={};for(const o in t){const a=t[o];n(e,o,i(a))&&(r[o]=a)}return r;function i(e){if(e){if(Array.isArray(e)){if(0===e.length)return;return e[0].id}return e.id}}}function ua(e){let t;if(e.GPSLatitude&&e.GPSLatitudeRef){t=t||{};try{t.Latitude=O(e.GPSLatitude.value),"S"===e.GPSLatitudeRef.value.join("")&&(t.Latitude=-t.Latitude)}catch(e){}}if(e.GPSLongitude&&e.GPSLongitudeRef){t=t||{};try{t.Longitude=O(e.GPSLongitude.value),"W"===e.GPSLongitudeRef.value.join("")&&(t.Longitude=-t.Longitude)}catch(e){}}if(e.GPSAltitude&&e.GPSAltitudeRef){t=t||{};try{t.Altitude=e.GPSAltitude.value[0]/e.GPSAltitude.value[1],1===e.GPSAltitudeRef.value&&(t.Altitude=-t.Altitude)}catch(e){}}if(t)return t}function fa(e){return void 0!==e}function la(e){return void 0!==e}function da(e){return void 0!==e}function pa(e){return void 0!==e}function ma(e){return Array.isArray(e)&&e.length>0}function ga(e){return Array.isArray(e)&&e.length>0}function ha(e){return void 0!==e}function ba(e){return void 0!==e}function va(e){return Array.isArray(e)&&e.length>0}function ya(e){return void 0!==e}function wa(e){return void 0!==e}function xa(e){return void 0!==e}function Sa(e){return void 0!==e}const Ia=[{format:"png",bytes:[137,80,78,71]},{format:"jpeg",bytes:[255,216,255]},{format:"tiff",bytes:[73,73,42,0]},{format:"tiff",bytes:[77,77,0,42]},{format:"avif",bytes:[102,116,121,112,97,118,105,102],offset:4}];function Ca(e){const t=e.trim();return t.startsWith("<?xml")||t.startsWith("<svg")}function Pa(e,t,n){return{code:e,severity:t,message:n}}async function ka(e,t=s){const n=[],r=await async function(e){const t=await e.slice(0,16).arrayBuffer(),n=function(e){for(const t of Ia){const n=t.offset??0;if(!(e.length<n+t.bytes.length)&&t.bytes.every(((t,r)=>e[n+r]===t)))return t.format}return null}(new Uint8Array(t));return null!==n?n:("image/svg+xml"===e.type||e.name.endsWith(".svg"))&&Ca(await e.text())?"svg":function(e){return{"image/png":"png","image/jpeg":"jpeg","image/svg+xml":"svg","image/tiff":"tiff","image/avif":"avif"}[e]??"unknown"}(e.type)}(e);t.allowedFormats.includes(r)||n.push(Pa("FORMAT_NOT_ALLOWED","error",`Format "${r}" is not allowed. Allowed: ${t.allowedFormats.join(", ")}`)),e.size>t.maxFileSize&&n.push(Pa("FILE_TOO_LARGE","error",`File size exceeds ${Math.round(t.maxFileSize/1048576)}MB limit`)),"svg"===r&&(Ca(await e.text())||n.push(Pa("INVALID_SVG","error","File does not contain valid SVG content")));const{dpiX:i,dpiY:o}=await async function(e,t){if("jpeg"!==t&&"tiff"!==t&&"png"!==t&&"avif"!==t)return{dpiX:null,dpiY:null};try{const n=await e.arrayBuffer(),r=ra(n,{expanded:!0}),i=r.exif?.XResolution?.value,o=r.exif?.YResolution?.value;if(null!=i&&null!=o)return{dpiX:Array.isArray(i)?i[0]/i[1]:Number(i),dpiY:Array.isArray(o)?o[0]/o[1]:Number(o)};if("png"===t&&"pHYs"in r){const e=r.pHYs,t=e?.["Pixels Per Unit X"]?.value,n=e?.["Pixels Per Unit Y"]?.value,i=e?.Unit?.value;if(null!=t&&null!=n&&1===i)return{dpiX:Math.round(Number(t)/39.3701),dpiY:Math.round(Number(n)/39.3701)}}return{dpiX:null,dpiY:null}}catch{return{dpiX:null,dpiY:null}}}(e,r),{width:a,height:c}=await async function(e,t){if("svg"===t){const t=await e.text(),n=t.match(/viewBox=["'](\d+[\s,]+\d+[\s,]+(\d+(?:\.\d+)?)[\s,]+(\d+(?:\.\d+)?))["']/);if(null!==n)return{width:Math.round(parseFloat(n[2])),height:Math.round(parseFloat(n[3]))};const r=t.match(/width=["'](\d+(?:\.\d+)?)(?:px)?["']/),i=t.match(/height=["'](\d+(?:\.\d+)?)(?:px)?["']/);return{width:null!==r?Math.round(parseFloat(r[1])):0,height:null!==i?Math.round(parseFloat(i[1])):0}}try{const t=await e.arrayBuffer(),n=ra(t,{expanded:!0}),r=n.file?.["Image Width"]?.value??n.exif?.ImageWidth?.value??n.exif?.PixelXDimension?.value,i=n.file?.["Image Height"]?.value??n.exif?.ImageLength?.value??n.exif?.PixelYDimension?.value;if(null!=r&&null!=i)return{width:Number(r),height:Number(i)}}catch{}return void 0!==globalThis.Image?new Promise((t=>{const n=URL.createObjectURL(e),r=new globalThis.Image;r.onload=()=>{URL.revokeObjectURL(n),t({width:r.naturalWidth,height:r.naturalHeight})},r.onerror=()=>{URL.revokeObjectURL(n),t({width:0,height:0})},r.src=n})):{width:0,height:0}}(e,r),u="png"===r||"jpeg"===r||"tiff"===r||"avif"===r;u&&(null===i||null===o?n.push(Pa("DPI_UNKNOWN","warning","Could not determine image DPI. Recommended minimum is "+t.minDpi+" DPI")):(i<t.minDpi||o<t.minDpi)&&n.push(Pa("DPI_TOO_LOW","error",`Image DPI (${Math.min(i,o)}) is below minimum ${t.minDpi} DPI`))),u&&(a>0&&a<t.minWidth&&n.push(Pa("WIDTH_TOO_SMALL","error",`Image width (${a}px) is below minimum ${t.minWidth}px`)),c>0&&c<t.minHeight&&n.push(Pa("HEIGHT_TOO_SMALL","error",`Image height (${c}px) is below minimum ${t.minHeight}px`)));const f={format:r,width:a,height:c,dpiX:i,dpiY:o,fileSize:e.size,fileName:e.name,mimeType:e.type,hasTransparency:"png"===r||"svg"===r||"avif"===r};return{valid:!n.some((e=>"error"===e.severity)),metadata:f,issues:n}}function Ta(e,t,n,r,i,o){return Math.sqrt((e-r)**2+(t-i)**2+(n-o)**2)}function Aa(e,t,n=60){if(0===e.length)return null;const r=new Map;for(const[t,n,i]of e){const e=`${Math.floor(t/24)},${Math.floor(n/24)},${Math.floor(i/24)}`,o=r.get(e);void 0!==o?(o.count++,o.sumR+=t,o.sumG+=n,o.sumB+=i):r.set(e,{count:1,sumR:t,sumG:n,sumB:i})}let i=null;for(const e of r.values())(null===i||e.count>i.count)&&(i=e);if(null===i)return null;const o=Math.round(i.sumR/i.count),a=Math.round(i.sumG/i.count),s=Math.round(i.sumB/i.count);let c=0,u=0,f=0,l=0;for(const[t,r,i]of e)Ta(t,r,i,o,a,s)<=n&&(c++,u+=t,f+=r,l+=i);return c/e.length<t?null:[Math.round(u/c),Math.round(f/c),Math.round(l/c)]}function Da(e){const{data:t,width:n,height:r}=e,i=[];for(let e=0;e<r;e++)for(let o=0;o<n;o++){const a=4*(e*n+o);if(0===t[a+3])continue;let s=!1;for(let i=-1;i<=1&&!s;i++)for(let a=-1;a<=1&&!s;a++){if(0===a&&0===i)continue;const c=o+a,u=e+i;c>=0&&c<n&&u>=0&&u<r&&0===t[4*(u*n+c)+3]&&(s=!0)}s&&i.push([t[a],t[a+1],t[a+2]])}return i}function Oa(e,t,n){const{data:r}=e,[i,o,a]=t;let s=0;for(let e=0;e<r.length;e+=4)0!==r[e+3]&&Ta(r[e],r[e+1],r[e+2],i,o,a)<=n&&(r[e+3]=0,s++);return s}function Ra(e,t,n){const{data:r,width:i,height:o}=e,[a,s,c]=t;let u=0,f=0;for(let e=0;e<o;e++)for(let t=0;t<i;t++){const l=4*(e*i+t);if(0===r[l+3])continue;if(Ta(r[l],r[l+1],r[l+2],a,s,c)<=n)continue;u++;let d=!1;for(let n=-1;n<=1&&!d;n++)for(let a=-1;a<=1&&!d;a++){if(0===a&&0===n)continue;const s=t+a,c=e+n;s>=0&&s<i&&c>=0&&c<o&&0===r[4*(c*i+s)+3]&&(d=!0)}d&&f++}return 0===u?0:f/u}function Fa(e,t,n,r){if(0===r)return 0;const{data:i,width:o,height:a}=e,s=o*a,[c,u,f]=t,l=new Uint8Array(s),d=new Int32Array(s);let p=0;for(let e=0;e<s;e++){if(0!==l[e])continue;l[e]=1;const t=4*e;if(0===i[t+3])continue;if(Ta(i[t],i[t+1],i[t+2],c,u,f)>n)continue;let s=0,m=0;d[m++]=e;let g=1;for(;s<m;){const e=d[s++],t=e%o,r=(e-t)/o;for(let e=-1;e<=1;e++)for(let s=-1;s<=1;s++){if(0===s&&0===e)continue;const p=t+s,h=r+e;if(p<0||p>=o||h<0||h>=a)continue;const b=h*o+p;if(0!==l[b])continue;l[b]=1;const v=4*b;0!==i[v+3]&&(Ta(i[v],i[v+1],i[v+2],c,u,f)>n||(d[m++]=b,g++))}}if(g>p&&(p=g),p>=.8*r)return p/r}return p/r}async function Ma(e,t=800){if(function(e){return e.startsWith("data:image/svg+xml")}(e))return e;if(void 0===globalThis.Image||"undefined"==typeof document)return e;const n=await function(e){return new Promise(((t,n)=>{const r=new Image;r.onload=()=>t(r),r.onerror=()=>n(Error("Failed to load image for preview generation")),r.src=e}))}(e),{width:r,height:i}=n;if(r<=t&&i<=t)return e;const o=t/Math.max(r,i),a=Math.round(r*o),s=Math.round(i*o),c=document.createElement("canvas");c.width=a,c.height=s;const u=c.getContext("2d");return null===u?e:(u.drawImage(n,0,0,a,s),c.toDataURL("image/png"))}const Ua=t(class extends n{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.wtpLogoValidated=r(this,"wtpLogoValidated"),this.wtpLogoRejected=r(this,"wtpLogoRejected"),this.wtpLogoProcessing=r(this,"wtpLogoProcessing"),this.wtpLogoSelected=r(this,"wtpLogoSelected")}config=s;accept="image/png,image/jpeg,image/svg+xml,image/tiff,image/avif";multiple=!1;disabled=!1;enableBackgroundRemoval=!1;bgRemovalConfig={};labels={};getLabels(){return{...u,...this.labels}}isDragOver=!1;previews=[];selectedIndex=-1;rejections=[];isProcessing=!1;pendingChoices=[];urlInput="";urlError=null;isUrlFetching=!1;wtpLogoValidated;wtpLogoRejected;wtpLogoProcessing;wtpLogoSelected;fileInputRef;async buildLogoData(e,t){return{dataUrl:e,previewDataUrl:await Ma(e),metadata:t}}isRasterFormat(e){return["png","jpeg","tiff","avif"].includes(e)}async processFiles(e){if(this.disabled)return;this.isProcessing=!0,this.rejections=[],this.wtpLogoProcessing.emit(!0);const t=Array.from(e);for(const e of t){const t=await ka(e,this.config);if(t.valid){const n=await this.fileToDataUrl(e);let r;const a=t.metadata;if("svg"===a.format){r=await i(n);const e=o(r);null!==e&&(a.width=e.width,a.height=e.height)}else r=n;if(this.enableBackgroundRemoval&&this.isRasterFormat(a.format))this.addPendingChoice(r,a,e);else{const e=await this.buildLogoData(r,a);this.previews=[...this.previews,e],this.selectedIndex=this.previews.length-1,this.wtpLogoValidated.emit(e),this.wtpLogoSelected.emit(e)}}else this.rejections=[...this.rejections,{fileName:e.name,issues:t.issues}],this.wtpLogoRejected.emit({file:e,issues:t.issues})}this.isProcessing=!1,this.wtpLogoProcessing.emit(!1)}addPendingChoice(e,t,n){this.pendingChoices=[...this.pendingChoices,{originalDataUrl:e,removedBgDataUrl:null,removedBgWidth:null,removedBgHeight:null,metadata:t,status:"processing",errorMessage:null}],this.performBackgroundRemoval(n,this.pendingChoices.length-1)}async performBackgroundRemoval(e,t){try{const n=await async function(e,t){const{tolerance:n,minEdgeRatio:r,autoCrop:i,autoCropPadding:o}={...c,...t},a=await function(e){return new Promise(((t,n)=>{const r=URL.createObjectURL(e),i=new Image;i.onload=()=>{URL.revokeObjectURL(r),t(i)},i.onerror=()=>{URL.revokeObjectURL(r),n(Error("Failed to load image"))},i.src=r}))}(e),s=document.createElement("canvas");s.width=a.naturalWidth,s.height=a.naturalHeight;const u=s.getContext("2d");if(null===u)throw Error("Could not get canvas 2d context");u.drawImage(a,0,0);const f=u.getImageData(0,0,s.width,s.height),l={data:f.data,width:s.width,height:s.height},d=function(e){const{data:t,width:n,height:r}=e,i=[],o=(e,r)=>{const o=4*(r*n+e);0!==t[o+3]&&i.push([t[o],t[o+1],t[o+2]])};for(let e=0;e<n;e++)o(e,0),o(e,r-1);for(let e=1;e<r-1;e++)o(0,e),o(n-1,e);return i}(l),p=2*l.width+2*Math.max(0,l.height-2);let m=null;(p>0?d.length/p:0)>=.5&&(m=Aa(d,r,n)),null!==m&&(function(e,t,n){const{data:r,width:i,height:o}=e,a=i*o,s=new Uint8Array(a),c=new Int32Array(a);let u=0,f=0;const[l,d,p]=t,m=(e,t)=>{const o=t*i+e;if(0!==s[o])return;s[o]=1;const a=4*o;0!==r[a+3]&&Ta(r[a],r[a+1],r[a+2],l,d,p)<=n&&(c[f++]=o)};for(let e=0;e<i;e++)m(e,0),m(e,o-1);for(let e=1;e<o-1;e++)m(0,e),m(i-1,e);for(;u<f;){const e=c[u++];r[4*e+3]=0;const t=e%i,n=(e-t)/i;t>0&&m(t-1,n),t<i-1&&m(t+1,n),n>0&&m(t,n-1),n<o-1&&m(t,n+1),t>0&&n>0&&m(t-1,n-1),t<i-1&&n>0&&m(t+1,n-1),t>0&&n<o-1&&m(t-1,n+1),t<i-1&&n<o-1&&m(t+1,n+1)}}(l,m,n),function(e,t,n){const{data:r,width:i,height:o}=e,a=i*o,[s,c,u]=t,f=new Uint8Array(a);for(let e=0;e<a;e++){const t=4*e;r[t+3]>0&&Ta(r[t],r[t+1],r[t+2],s,c,u)<=n&&(f[e]=1)}const l=new Int32Array(a).fill(-1),d=[];let p=0;for(let e=0;e<a;e++){if(1!==f[e]||-1!==l[e])continue;const t=p++;d.push(!1);const n=[e];for(l[e]=t;n.length>0;){const e=n.pop(),a=e%i,s=(e-a)/i;for(let e=-1;e<=1;e++)for(let c=-1;c<=1;c++){if(0===c&&0===e)continue;const u=a+c,p=s+e;if(u<0||u>=i||p<0||p>=o)continue;const m=p*i+u;0!==r[4*m+3]?1===f[m]&&-1===l[m]&&(l[m]=t,n.push(m)):d[t]=!0}}}for(let e=0;e<a;e++)-1===l[e]||d[l[e]]||(r[4*e+3]=0)}(l,m,n));let g=!1;for(let e=0;e<l.data.length;e+=4)if(0===l.data[e+3]){g=!0;break}if(!g)throw Error("No dominant background color detected");let h=m??[255,255,255];for(let e=0;e<3;e++){const e=Da(l),t=Aa(e,r,n);if(null===t)break;let i=0,o=0,a=l.width,s=0,c=l.height,u=0;for(let e=0;e<l.data.length;e+=4)if(l.data[e+3]>0&&(i++,Ta(l.data[e],l.data[e+1],l.data[e+2],t[0],t[1],t[2])<=n)){o++;const t=e/4,n=t%l.width,r=(t-n)/l.width;n<a&&(a=n),n>s&&(s=n),r<c&&(c=r),r>u&&(u=r)}if(0===i||o/i>.9)break;if(o/i>.4&&Ra(l,t,n)>.5)break;let f=0;for(const[r,i,o]of e)Ta(r,i,o,t[0],t[1],t[2])<=n&&f++;if(o>0&&f/o>.7)break;const d=(s-a+1)*(u-c+1);if(d>0&&o/d<.45)break;if(Fa(l,t,n,o)<.8)break;if(0===Oa(l,t,n))break;h=t}!function(e,t,n){const{data:r,width:i,height:o}=e,[a,s,c]=t,u=[];for(let e=0;e<o;e++)for(let t=0;t<i;t++){const n=e*i+t;if(0===r[4*n+3])continue;let a=!1;for(let n=-1;n<=1&&!a;n++)for(let s=-1;s<=1&&!a;s++){if(0===s&&0===n)continue;const c=t+s,u=e+n;c>=0&&c<i&&u>=0&&u<o&&0===r[4*(u*i+c)+3]&&(a=!0)}a&&u.push(n)}for(const e of u){const t=4*e,i=Ta(r[t],r[t+1],r[t+2],a,s,c);r[t+3]=Math.min(255,Math.round(i/n*255))}}(l,h,n),u.putImageData(f,0,0);let b=s;if(i){const e=function(e,t=0){const{data:n,width:r,height:i}=e;let o=r,a=i,s=-1,c=-1;for(let e=0;e<i;e++)for(let i=0;i<r;i++)n[4*(e*r+i)+3]>t&&(i<o&&(o=i),i>s&&(s=i),e<a&&(a=e),e>c&&(c=e));return-1===s?null:[o,a,s,c]}(l);if(null!==e){const[t,n,r,i]=e,a=Math.max(0,t-o),c=Math.max(0,n-o),u=Math.min(s.width,r+1+o)-a,f=Math.min(s.height,i+1+o)-c;if(u<s.width||f<s.height){const e=document.createElement("canvas");e.width=u,e.height=f;const t=e.getContext("2d");null!==t&&(t.drawImage(s,a,c,u,f,0,0,u,f),b=e)}}}return{blob:await new Promise(((e,t)=>{b.toBlob((n=>{null!==n?e(n):t(Error("Canvas toBlob failed"))}),"image/png")})),dataUrl:b.toDataURL("image/png"),width:b.width,height:b.height}}(e,this.bgRemovalConfig);this.pendingChoices=this.pendingChoices.map(((e,r)=>r===t?{...e,removedBgDataUrl:n.dataUrl,removedBgWidth:n.width,removedBgHeight:n.height,status:"ready"}:e))}catch(e){const n=e instanceof Error?e.message:"Background removal failed";this.pendingChoices=this.pendingChoices.map(((e,r)=>r===t?{...e,status:"error",errorMessage:n}:e))}}async selectChoice(e,t){const n=this.pendingChoices[e];if(void 0===n)return;const r=t&&null!==n.removedBgDataUrl?n.removedBgDataUrl:n.originalDataUrl,i=t&&null!==n.removedBgWidth&&null!==n.removedBgHeight?{...n.metadata,width:n.removedBgWidth,height:n.removedBgHeight}:n.metadata,o=await this.buildLogoData(r,i);this.previews=[...this.previews,o],this.selectedIndex=this.previews.length-1,this.wtpLogoValidated.emit(o),this.wtpLogoSelected.emit(o),this.pendingChoices=this.pendingChoices.filter(((t,n)=>n!==e))}extractFileNameFromUrl(e){try{const t=new URL(e).pathname.split("/"),n=t[t.length-1];return void 0!==n&&""!==n&&n.includes(".")?decodeURIComponent(n):"downloaded-image"}catch{return"downloaded-image"}}async handleUrlSubmit(){const e=this.urlInput.trim(),t=this.getLabels();if(this.urlError=null,""===e)return void(this.urlError=t.urlErrorEmpty);let n;try{n=new URL(e)}catch{return void(this.urlError=t.urlErrorInvalid)}if("https:"===n.protocol){this.isUrlFetching=!0;try{const n=await fetch(e,{mode:"cors"});if(!n.ok)return void(this.urlError=t.urlErrorHttp(n.status,n.statusText));const r=await n.blob(),i=this.extractFileNameFromUrl(e),o=new File([r],i,{type:r.type});this.urlInput="",await this.processFiles([o])}catch(e){const n=e instanceof Error?e.message:t.urlErrorFetch;this.urlError=n.includes("Failed to fetch")||n.includes("NetworkError")?t.urlErrorNetwork:n}finally{this.isUrlFetching=!1}}else this.urlError=t.urlErrorProtocol}fileToDataUrl(e){return new Promise(((t,n)=>{const r=new FileReader;r.onload=()=>t(r.result),r.onerror=()=>n(Error("Failed to read file")),r.readAsDataURL(e)}))}handleDragOver=e=>{e.preventDefault(),e.stopPropagation(),this.disabled||(this.isDragOver=!0)};handleDragLeave=e=>{e.preventDefault(),e.stopPropagation(),this.isDragOver=!1};handleDrop=e=>{e.preventDefault(),e.stopPropagation(),this.isDragOver=!1,void 0!==e.dataTransfer?.files&&this.processFiles(e.dataTransfer.files)};handleInputChange=e=>{const t=e.target;null!==t.files&&this.processFiles(t.files)};handleClick=()=>{this.disabled||this.fileInputRef?.click()};handleKeyDown=e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.handleClick())};handleUrlInput=e=>{this.urlInput=e.target.value};handleUrlInputKeyDown=e=>{"Enter"===e.key&&(e.preventDefault(),this.handleUrlSubmit())};handleUrlSubmitClick=()=>{this.handleUrlSubmit()};handleSelectOriginal=e=>{const t=e.currentTarget.closest("[data-index]");null!==t&&this.selectChoice(Number(t.dataset.index),!1)};handleSelectRemoved=e=>{const t=e.currentTarget.closest("[data-index]");null!==t&&this.selectChoice(Number(t.dataset.index),!0)};handleSelectPreview=e=>{const t=e.currentTarget.closest("[data-index]");if(null===t)return;const n=Number(t.dataset.index);this.selectedIndex=n,this.wtpLogoSelected.emit(this.previews[n])};handleRemovePreview=e=>{e.stopPropagation();const t=e.currentTarget.closest("[data-index]");if(null===t)return;const n=Number(t.dataset.index);this.previews=this.previews.filter(((e,t)=>t!==n)),this.selectedIndex===n?(this.selectedIndex=this.previews.length>0?0:-1,this.selectedIndex>=0&&this.wtpLogoSelected.emit(this.previews[this.selectedIndex])):this.selectedIndex>n&&this.selectedIndex--};render(){const e=this.getLabels();return a("div",{key:"605b0b0f0e3d523fad548c8e250deb586fa047cd",class:"wtp-logo-upload",part:"root"},a("div",{key:"206c52a14ba4bf1ca88361298ea1dd34ede33abe",class:"url-input-section"},a("div",{key:"8bbe6a257f53d3aaf40566b1686c77352a571182",class:"url-input-wrapper"},a("input",{key:"88f87e7772bf404088a1978a3964af098362d2fd",type:"url",class:"url-input",part:"url-input",placeholder:e.urlPlaceholder,value:this.urlInput,disabled:this.disabled||this.isUrlFetching,onInput:this.handleUrlInput,onKeyDown:this.handleUrlInputKeyDown}),a("button",{key:"77b0b04012be3869fcad0841542ff6ba65175b69",class:"url-submit-btn",part:"url-submit-btn",disabled:this.disabled||this.isUrlFetching||""===this.urlInput.trim(),onClick:this.handleUrlSubmitClick},this.isUrlFetching?a("span",{class:"spinner-sm"}):e.urlSubmit)),null!==this.urlError&&a("p",{key:"21af070e82a88911b00cfb35c21c9f4a0b1f9537",class:"url-error",part:"url-error"},this.urlError)),a("div",{key:"40ea61275f84ea49bde47d4a2d7df6b48733b8df",class:"divider",part:"divider"},a("span",{key:"617d48c410b5166efbe38902fbc36a537f98f359",class:"divider-text"},e.dividerText)),a("div",{key:"56aebdb221b17ed365e8e1b780f643d2985a0a76",class:{"upload-zone":!0,"drag-over":this.isDragOver,disabled:this.disabled},part:`upload-zone${this.isDragOver?" drag-over":""}${this.disabled?" disabled":""}`,onDragOver:this.handleDragOver,onDragLeave:this.handleDragLeave,onDrop:this.handleDrop,onClick:this.handleClick,onKeyDown:this.handleKeyDown,role:"button",tabindex:this.disabled?-1:0,"aria-label":e.uploadAriaLabel,"aria-disabled":this.disabled?"true":void 0},a("input",{key:"b4dd839c3d9dfa26f7e22058ca8d88d1b5128a78",type:"file",ref:e=>this.fileInputRef=e,accept:this.accept,multiple:this.multiple,onChange:this.handleInputChange,class:"file-input",tabindex:-1}),a("slot",{key:"77c9c469ed07b881d8e09d15ba6ab39938c8685e",name:"prompt"},a("div",{key:"1dc98ac4ee1f0a830fff45c420dcdb83d5e51e08",class:"default-prompt"},a("svg",{key:"6b0b37518c24f7af3d69df7cfb00a367ceeed172",class:"upload-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},a("path",{key:"7f8c88dc1022380127cac7dc278b6363013293f8",d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),a("polyline",{key:"0ae415e56725fa3e35229dd95824c69c35b8b157",points:"17 8 12 3 7 8"}),a("line",{key:"4aceb053d8f82b24b01c250337d17787435b93a2",x1:"12",y1:"3",x2:"12",y2:"15"})),a("p",{key:"dbc8e47dc04b7f1c03053e244c7d8c5d5e70b533",class:"prompt-text",part:"prompt-text"},e.dropPromptText),a("p",{key:"f3c1d7b332ce6439725dcf15eda5732a8f6d45e2",class:"prompt-hint",part:"prompt-hint"},e.dropPromptHint))),this.isProcessing&&a("div",{key:"4f5730a0bfd918788c851dd7b4e0282643e782cc",class:"processing-overlay"},a("span",{key:"d1f7e503dd250b7125132790976554c3b91a0aba",class:"spinner"}))),this.rejections.length>0&&a("div",{key:"5f2aa8bb1b64d70db7138ff2eddda68ed7aa62e3",class:"rejections",part:"rejections"},this.rejections.map((e=>a("div",{class:"rejection-item",part:"rejection-item"},a("strong",null,e.fileName),a("ul",null,e.issues.filter((e=>"error"===e.severity)).map((e=>a("li",{class:"error"},e.message))),e.issues.filter((e=>"warning"===e.severity)).map((e=>a("li",{class:"warning"},e.message)))))))),this.pendingChoices.length>0&&a("div",{key:"c1c43dfeb2d32a66261c70d3c4edd0339c88f098",class:"pending-choices",part:"pending-choices"},this.pendingChoices.map(((t,n)=>a("div",{class:"choice-card",part:"choice-card"},a("p",{class:"choice-title"},t.metadata.fileName),a("div",{class:"choice-options"},a("button",{class:"choice-option",part:"choice-option","data-index":n,onClick:this.handleSelectOriginal},a("img",{src:t.originalDataUrl,alt:"Original",class:"choice-image"}),a("span",{class:"choice-label"},e.bgRemovalUseOriginal)),a("button",{class:{"choice-option":!0,"choice-option--disabled":"processing"===t.status},part:"choice-option",disabled:"processing"===t.status,"data-index":n,onClick:this.handleSelectRemoved},"processing"===t.status&&a("div",{class:"choice-image choice-image--loading"},a("span",{class:"spinner-sm"}),a("span",{class:"choice-loading-text"},e.bgRemovalProcessing)),"ready"===t.status&&null!==t.removedBgDataUrl&&a("img",{src:t.removedBgDataUrl,alt:"Background removed",class:"choice-image choice-image--transparent"}),"error"===t.status&&a("div",{class:"choice-image choice-image--error"},a("span",{class:"choice-error-text"},t.errorMessage)),a("span",{class:"choice-label"},"error"===t.status?e.bgRemovalFailed:e.bgRemovalUseRemoved))))))),this.previews.length>0&&a("div",{key:"69d0dab6c5377d471b8802d7ba92c640785e3d52",class:"previews",part:"previews"},this.previews.map(((t,n)=>a("div",{class:{"preview-item":!0,"preview-item--selected":n===this.selectedIndex},part:"preview-item"+(n===this.selectedIndex?" selected":""),"data-index":n,onClick:this.handleSelectPreview,role:"button",tabindex:0},a("img",{src:t.previewDataUrl??t.dataUrl,alt:t.metadata.fileName,class:"preview-image"}),a("div",{class:"preview-info"},a("span",{class:"preview-name"},t.metadata.fileName),a("span",{class:"preview-dims"},t.metadata.width," x ",t.metadata.height,"px"),null!==t.metadata.dpiX&&a("span",{class:"preview-dpi"},t.metadata.dpiX," ",e.rejectionDpiUnit)),a("button",{class:"remove-btn",part:"remove-btn","data-index":n,onClick:this.handleRemovePreview,"aria-label":e.removeAriaLabel(t.metadata.fileName)},a("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},a("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a("line",{x1:"6",y1:"6",x2:"18",y2:"18"}))))))))}static get style(){return'*,*::before,*::after{box-sizing:border-box}:host{font-family:var(--wtp-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);color:var(--wtp-color-text, #1e293b);line-height:1.5}.wtp-logo-upload{display:flex;flex-direction:column;gap:16px;width:100%}.url-input-section{display:flex;flex-direction:column;gap:4px}.url-input-wrapper{display:flex;gap:8px}.url-input{flex:1;padding:8px 16px;font-family:var(--wtp-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);font-size:14px;border:1px solid var(--wtp-color-border, #e2e8f0);border-radius:8px;background:var(--wtp-color-bg, #ffffff);color:var(--wtp-color-text, #1e293b);transition-property:border-color;transition-duration:250ms;transition-timing-function:ease}.url-input::placeholder{color:var(--wtp-color-text-muted, #64748b)}.url-input:focus{outline:none;border-color:var(--wtp-color-primary, #2563eb)}.url-input:disabled{opacity:0.5;cursor:not-allowed}.url-submit-btn{display:inline-flex;align-items:center;gap:8px;padding:8px 16px;font-family:var(--wtp-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);font-size:14px;font-weight:500;border-radius:8px;border:1px solid var(--wtp-color-border, #e2e8f0);background:var(--wtp-color-bg, #ffffff);color:var(--wtp-color-text, #1e293b);cursor:pointer;transition-property:all;transition-duration:250ms;transition-timing-function:ease}.url-submit-btn:hover{background:var(--wtp-color-bg-muted, #f8fafc)}.url-submit-btn:focus-visible{outline:2px solid var(--wtp-color-primary, #2563eb);outline-offset:2px}.url-submit-btn:disabled{opacity:0.5;cursor:not-allowed}.url-submit-btn{background:var(--wtp-color-primary, #2563eb);color:var(--wtp-color-bg, #ffffff);border-color:var(--wtp-color-primary, #2563eb);min-width:72px;justify-content:center}.url-submit-btn:hover:not(:disabled){background:var(--wtp-color-primary-hover, #1d4ed8);border-color:var(--wtp-color-primary-hover, #1d4ed8)}.url-submit-btn:disabled{opacity:0.5;cursor:not-allowed}.url-error{margin:0;font-size:12px;color:var(--wtp-color-error, #dc2626)}.divider{display:flex;align-items:center;gap:16px}.divider::before,.divider::after{content:"";flex:1;height:1px;background:var(--wtp-color-border, #e2e8f0)}.divider-text{font-size:14px;color:var(--wtp-color-text-muted, #64748b);text-transform:lowercase}.upload-zone{display:flex;align-items:center;justify-content:center;position:relative;min-height:160px;padding:32px;border:2px dashed var(--wtp-color-border, #e2e8f0);border-radius:12px;background:var(--wtp-color-bg-muted, #f8fafc);cursor:pointer;transition-property:border-color background-color;transition-duration:250ms;transition-timing-function:ease}.upload-zone:hover{border-color:var(--wtp-color-primary, #2563eb);background:var(--wtp-color-primary-light, #dbeafe)}.upload-zone:focus-visible{outline:2px solid var(--wtp-color-primary, #2563eb);outline-offset:2px}.upload-zone.drag-over{border-color:var(--wtp-color-primary, #2563eb);background:var(--wtp-color-primary-light, #dbeafe);border-style:solid}.upload-zone.disabled{opacity:0.5;cursor:not-allowed;pointer-events:none}.file-input{position:absolute;width:0;height:0;opacity:0;overflow:hidden}.default-prompt{display:flex;flex-direction:column;align-items:center;gap:8px;text-align:center}.upload-icon{width:40px;height:40px;color:var(--wtp-color-secondary, #64748b)}.prompt-text{margin:0;font-size:16px;font-weight:500;color:var(--wtp-color-text, #1e293b)}.prompt-hint{margin:0;font-size:14px;color:var(--wtp-color-text-muted, #64748b)}.processing-overlay{display:flex;align-items:center;justify-content:center;position:absolute;inset:0;background:rgba(255, 255, 255, 0.8);border-radius:12px}.spinner{display:block;width:32px;height:32px;border:3px solid var(--wtp-color-border, #e2e8f0);border-top-color:var(--wtp-color-primary, #2563eb);border-radius:50%;animation:wtp-spin 0.8s linear infinite}.spinner-sm{display:inline-block;width:16px;height:16px;border:2px solid var(--wtp-color-border, #e2e8f0);border-top-color:var(--wtp-color-primary, #2563eb);border-radius:50%;animation:wtp-spin 0.8s linear infinite}@keyframes wtp-spin{to{transform:rotate(360deg)}}.rejections{display:flex;flex-direction:column;gap:8px}.rejection-item{padding:8px 16px;border-radius:8px;background:var(--wtp-color-error-light, #fee2e2);font-size:14px}.rejection-item strong{color:var(--wtp-color-error, #dc2626)}.rejection-item ul{margin:4px 0 0;padding-left:24px}.rejection-item .error{color:var(--wtp-color-error, #dc2626)}.rejection-item .warning{color:var(--wtp-color-warning, #d97706)}.pending-choices{display:flex;flex-direction:column;gap:16px}.choice-card{border:1px solid var(--wtp-color-border, #e2e8f0);border-radius:12px;padding:16px;background:var(--wtp-color-bg, #ffffff)}.choice-title{margin:0 0 8px;font-size:14px;font-weight:500;color:var(--wtp-color-text, #1e293b);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.choice-options{display:grid;grid-template-columns:1fr 1fr;gap:16px}.choice-option{display:flex;flex-direction:column;align-items:center;gap:8px;padding:8px;border:2px solid var(--wtp-color-border, #e2e8f0);border-radius:8px;background:var(--wtp-color-bg, #ffffff);cursor:pointer;transition-property:border-color;transition-duration:250ms;transition-timing-function:ease}.choice-option:hover:not(:disabled){border-color:var(--wtp-color-primary, #2563eb)}.choice-option:focus-visible{outline:2px solid var(--wtp-color-primary, #2563eb);outline-offset:2px}.choice-option--disabled{opacity:0.7;cursor:wait}.choice-image{width:100%;height:120px;object-fit:contain;border-radius:4px}.choice-image--transparent{background:repeating-conic-gradient(#e2e8f0 0% 25%, #fff 0% 50%) 50%/12px 12px}.choice-image--loading{display:flex;align-items:center;justify-content:center;flex-direction:column;gap:4px;background:var(--wtp-color-bg-muted, #f8fafc)}.choice-image--error{display:flex;align-items:center;justify-content:center;background:var(--wtp-color-error-light, #fee2e2);padding:8px}.choice-loading-text{font-size:12px;color:var(--wtp-color-text-muted, #64748b)}.choice-error-text{font-size:12px;color:var(--wtp-color-error, #dc2626);text-align:center}.choice-label{font-size:14px;font-weight:500;color:var(--wtp-color-text, #1e293b)}.previews{display:grid;grid-template-columns:repeat(auto-fill, minmax(140px, 1fr));gap:16px}.preview-item{display:flex;flex-direction:column;position:relative;border:2px solid var(--wtp-color-border, #e2e8f0);border-radius:8px;overflow:hidden;background:var(--wtp-color-bg, #ffffff);cursor:pointer;transition-property:border-color box-shadow;transition-duration:250ms;transition-timing-function:ease}.preview-item:hover{border-color:var(--wtp-color-secondary, #64748b)}.preview-item--selected{border-color:var(--wtp-color-primary, #2563eb);box-shadow:0 0 0 2px var(--wtp-color-primary-fade, rgba(37, 99, 235, 0.2))}.preview-image{width:100%;height:100px;object-fit:contain;background:var(--wtp-color-bg-muted, #f8fafc);padding:8px}.preview-info{display:flex;flex-direction:column;padding:8px;gap:2px;font-size:12px;color:var(--wtp-color-text-muted, #64748b)}.preview-name{font-weight:500;color:var(--wtp-color-text, #1e293b);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.remove-btn{position:absolute;top:4px;right:4px;display:flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:9999px;background:rgba(0, 0, 0, 0.5);color:white;cursor:pointer;transition-property:all;transition-duration:250ms;transition-timing-function:ease}.remove-btn:hover{background:rgba(0, 0, 0, 0.7)}.remove-btn svg{width:14px;height:14px}'}},[769,"wtp-logo-upload",{config:[16],accept:[1],multiple:[4],disabled:[4],enableBackgroundRemoval:[4,"enable-background-removal"],bgRemovalConfig:[16],labels:[16],isDragOver:[32],previews:[32],selectedIndex:[32],rejections:[32],isProcessing:[32],pendingChoices:[32],urlInput:[32],urlError:[32],isUrlFetching:[32]}]);function Ea(){"undefined"!=typeof customElements&&["wtp-logo-upload"].forEach((t=>{"wtp-logo-upload"===t&&(customElements.get(e(t))||customElements.define(e(t),Ua))}))}Ea();const Na=Ua,Ga=Ea;export{Na as WtpLogoUpload,Ga as defineCustomElement}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface WtpPrintAreaEditor extends Components.WtpPrintAreaEditor, HTMLElement {}
|
|
4
|
+
export const WtpPrintAreaEditor: {
|
|
5
|
+
prototype: WtpPrintAreaEditor;
|
|
6
|
+
new (): WtpPrintAreaEditor;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t,c as i,H as e,d as s,j as h,e as a,o as r,N as n,p as o,q as c,k as d,J as f,v as p}from"./p-5qCsRzlt.js";class l extends f{constructor(t){super(t),this.cornerOffsets=t?.cornerOffsets??[new n(-50,-50),new n(50,-50),new n(50,50),new n(-50,50)],this.bulge=t?.bulge??0,this.objectCaching=!1}_render(t){const[i,e,s,h]=this.cornerOffsets;t.beginPath(),t.moveTo(i.x,i.y),0!==this.bulge?t.quadraticCurveTo((i.x+e.x)/2,(i.y+e.y)/2-this.bulge*(this.height??1),e.x,e.y):t.lineTo(e.x,e.y),t.lineTo(s.x,s.y),0!==this.bulge?t.quadraticCurveTo((s.x+h.x)/2,(s.y+h.y)/2-this.bulge*(this.height??1),h.x,h.y):t.lineTo(h.x,h.y),t.closePath(),this._renderPaintInOrder(t)}recalcBounds(){const t=this.getCenterPoint(),i=this.cornerOffsets.map((i=>new n(t.x+i.x,t.y+i.y))),e=i.map((t=>t.x)),s=i.map((t=>t.y)),h=Math.min(...e),a=Math.max(...e),r=Math.min(...s),o=Math.max(...s),c=(h+a)/2,d=(r+o)/2;this.cornerOffsets=i.map((t=>new n(t.x-c,t.y-d))),this.set({left:c,top:d,width:Math.max(a-h,1),height:Math.max(o-r,1)}),this.setCoords()}}function g(t){return new p({x:0,y:0,sizeX:14,sizeY:14,touchSizeX:28,touchSizeY:28,cursorStyleHandler:()=>"move",positionHandler:(i,e,s)=>new n(s.cornerOffsets[t].x,s.cornerOffsets[t].y).transform(e),actionHandler:(i,e,s,h)=>{const a=e.target,r=a.getCenterPoint();return a.cornerOffsets[t]=new n(s-r.x,h-r.y),a.recalcBounds(),!0},render:(t,i,e)=>{t.save(),t.fillStyle="#2563eb",t.strokeStyle="#ffffff",t.lineWidth=2,t.beginPath(),t.arc(i,e,7,0,2*Math.PI),t.fill(),t.stroke(),t.restore()}})}const w=i(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.wtpPrintAreaChange=s(this,"wtpPrintAreaChange")}get el(){return this}productImage;width=800;height=600;printArea;wtpPrintAreaChange;canvas;canvasEl;areaQuad;bgLoadGen=0;componentDidLoad(){this.initCanvas()}disconnectedCallback(){++this.bgLoadGen,this.canvas?.dispose()}async onProductImageChange(){void 0!==this.canvas&&void 0!==this.productImage&&await this.reloadCanvas()}async onSizeChange(){void 0!==this.canvas&&await this.reloadCanvas()}onPrintAreaChange(){this.syncQuadFromPrintArea()}async getPrintArea(){return this.readQuadAsPrintArea()}async setPrintArea(t){this.printArea=t,this.syncQuadFromPrintArea()}async initCanvas(){void 0!==this.canvasEl&&(this.canvas=new h(this.canvasEl,{width:this.width,height:this.height,backgroundColor:"#ffffff",selection:!1}),this.canvas.on("object:modified",(t=>{t.target===this.areaQuad&&this.emitPrintArea()})),this.canvas.on("object:moving",(t=>{t.target===this.areaQuad&&this.clampQuadToBounds()})),await this.reloadCanvas())}async reloadCanvas(){if(void 0===this.canvas)return;const t=++this.bgLoadGen;this.areaQuad=void 0,this.canvas.discardActiveObject();for(const t of this.canvas.getObjects().slice())this.canvas.remove(t);this.canvas.viewportTransform=[1,0,0,1,0,0],this.canvas.setDimensions({width:this.width,height:this.height}),this.canvas.backgroundColor="#ffffff",this.canvas.requestRenderAll(),void 0!==this.productImage&&""!==this.productImage&&await a(this.canvas,this.productImage),t===this.bgLoadGen&&(this.createAreaQuad(),this.canvas.renderAll())}createAreaQuad(){if(void 0===this.canvas)return;const t=this.printArea??r(),i=this.canvas.getWidth(),e=this.canvas.getHeight(),[s,h,a,c]=o(t,i,e),d=(s.x+h.x+a.x+c.x)/4,f=(s.y+h.y+a.y+c.y)/4,w=[s.x,h.x,a.x,c.x],u=[s.y,h.y,a.y,c.y],b=Math.max(Math.max(...w)-Math.min(...w),1),M=Math.max(Math.max(...u)-Math.min(...u),1);this.areaQuad=new l({left:d,top:f,width:b,height:M,cornerOffsets:[new n(s.x-d,s.y-f),new n(h.x-d,h.y-f),new n(a.x-d,a.y-f),new n(c.x-d,c.y-f)],bulge:t.bulge??0,originX:"center",originY:"center",fill:"rgba(37, 99, 235, 0.15)",stroke:"#2563eb",strokeWidth:2,strokeDashArray:[6,4],lockScalingX:!0,lockScalingY:!0,lockRotation:!0,hasRotatingPoint:!1,borderColor:"#2563eb"}),this.areaQuad.controls={corner0:g(0),corner1:g(1),corner2:g(2),corner3:g(3),bulgeHandle:new p({x:.5,y:0,offsetX:24,sizeX:14,sizeY:14,touchSizeX:28,touchSizeY:28,cursorStyleHandler:()=>"ns-resize",positionHandler:(t,i,e)=>new n(.5*t.x+24,-e.bulge*t.y/2).transform(i),actionHandler:(t,i,e,s)=>{const h=i.target,a=h.getCenterPoint();return h.bulge=Math.max(-1,Math.min(1,(a.y-s)/Math.max((h.height??0)*(h.scaleY??1)/2,1))),!0},render:(t,i,e,s,h)=>{const a=(h.height??0)*(h.scaleY??1)/2,r=(h.angle??0)*Math.PI/180,n=i+Math.sin(r)*a,o=e-Math.cos(r)*a,c=i-Math.sin(r)*a,d=e+Math.cos(r)*a;t.save(),t.strokeStyle="rgba(37, 99, 235, 0.3)",t.lineWidth=2,t.setLineDash([3,3]),t.beginPath(),t.moveTo(n,o-4),t.lineTo(c,d+4),t.stroke(),t.setLineDash([]),t.fillStyle="#2563eb",t.strokeStyle="#ffffff",t.lineWidth=2,t.beginPath(),t.arc(i,e,7,0,2*Math.PI),t.fill(),t.stroke(),t.fillStyle="rgba(37, 99, 235, 0.5)",t.beginPath(),t.moveTo(n,o-4),t.lineTo(n-4,o-4+6),t.lineTo(n+4,o-4+6),t.closePath(),t.fill(),t.font="bold 10px sans-serif",t.textAlign="center",t.fillText("+",n,o-4-4),t.beginPath(),t.moveTo(c,d+4),t.lineTo(c-4,d+4-6),t.lineTo(c+4,d+4-6),t.closePath(),t.fill(),t.fillText("−",c,d+4+12),t.restore()}})},this.canvas.add(this.areaQuad),this.canvas.renderAll()}syncQuadFromPrintArea(){if(void 0===this.areaQuad||void 0===this.canvas)return;const t=this.printArea??r(),i=this.canvas.getWidth(),e=this.canvas.getHeight(),[s,h,a,c]=o(t,i,e),d=(s.x+h.x+a.x+c.x)/4,f=(s.y+h.y+a.y+c.y)/4,p=[s.x,h.x,a.x,c.x],l=[s.y,h.y,a.y,c.y];this.areaQuad.cornerOffsets=[new n(s.x-d,s.y-f),new n(h.x-d,h.y-f),new n(a.x-d,a.y-f),new n(c.x-d,c.y-f)],this.areaQuad.bulge=t.bulge??0,this.areaQuad.set({left:d,top:f,width:Math.max(Math.max(...p)-Math.min(...p),1),height:Math.max(Math.max(...l)-Math.min(...l),1),scaleX:1,scaleY:1}),this.areaQuad.setCoords(),this.canvas.renderAll()}clampQuadToBounds(){if(void 0===this.areaQuad)return;const t=this.areaQuad.getCenterPoint(),i=this.areaQuad.cornerOffsets.map((i=>({x:t.x+i.x,y:t.y+i.y})));let e=0,s=0;for(const t of i)t.x<0&&(e=Math.max(e,-t.x)),t.x>this.canvas.getWidth()&&(e=Math.min(e,this.canvas.getWidth()-t.x)),t.y<0&&(s=Math.max(s,-t.y)),t.y>this.canvas.getHeight()&&(s=Math.min(s,this.canvas.getHeight()-t.y));0===e&&0===s||this.areaQuad.set({left:(this.areaQuad.left??0)+e,top:(this.areaQuad.top??0)+s})}readQuadAsPrintArea(){if(void 0===this.areaQuad)return this.printArea??r();const t=this.areaQuad.getCenterPoint(),i=[{x:t.x+this.areaQuad.cornerOffsets[0].x,y:t.y+this.areaQuad.cornerOffsets[0].y},{x:t.x+this.areaQuad.cornerOffsets[1].x,y:t.y+this.areaQuad.cornerOffsets[1].y},{x:t.x+this.areaQuad.cornerOffsets[2].x,y:t.y+this.areaQuad.cornerOffsets[2].y},{x:t.x+this.areaQuad.cornerOffsets[3].x,y:t.y+this.areaQuad.cornerOffsets[3].y}],e=this.canvas.getWidth(),s=this.canvas.getHeight();return c(i,e,s,this.areaQuad.bulge)}emitPrintArea(){const t=this.readQuadAsPrintArea();this.printArea=t,this.wtpPrintAreaChange.emit(t)}render(){return d("div",{key:"fbeaeb8ac49780440ceb1bffa38689a23aeef66a",class:"wtp-print-area-editor"},d("canvas",{key:"b7e97909efaa17c7ffb4b089cf31e508e20c094e",ref:t=>this.canvasEl=t}))}static get watchers(){return{productImage:[{onProductImageChange:0}],width:[{onSizeChange:0}],height:[{onSizeChange:0}],printArea:[{onPrintAreaChange:0}]}}static get style(){return'*.sc-wtp-print-area-editor,*.sc-wtp-print-area-editor::before,*.sc-wtp-print-area-editor::after{box-sizing:border-box}.sc-wtp-print-area-editor-h{font-family:var(--wtp-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);color:var(--wtp-color-text, #1e293b);line-height:1.5}.wtp-print-area-editor.sc-wtp-print-area-editor{display:inline-block;line-height:0;border:1px solid var(--wtp-color-border, #e2e8f0);border-radius:8px;overflow:hidden;background:repeating-conic-gradient(#e5e7eb 0% 25%, transparent 0% 50%) 50%/20px 20px}'}},[514,"wtp-print-area-editor",{productImage:[1,"product-image"],width:[2],height:[2],printArea:[1040],getPrintArea:[64],setPrintArea:[64]},void 0,{productImage:[{onProductImageChange:0}],width:[{onSizeChange:0}],height:[{onSizeChange:0}],printArea:[{onPrintAreaChange:0}]}]);function u(){"undefined"!=typeof customElements&&["wtp-print-area-editor"].forEach((i=>{"wtp-print-area-editor"===i&&(customElements.get(t(i))||customElements.define(t(i),w))}))}u();const b=w,M=u;export{b as WtpPrintAreaEditor,M as defineCustomElement}
|