@arcgis/core 5.2.0-next.161 → 5.2.0-next.163
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/arcgisGlobal.d.ts +1 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/092e311cb7aea92a6a26.js +1 -0
- package/assets/esri/core/workers/chunks/17c6d66b47aa690df0d4.js +1 -0
- package/assets/esri/core/workers/chunks/1e1c45f75020d5e05dc3.js +1 -0
- package/assets/esri/core/workers/chunks/{4ed76fb5f6096a089f5b.js → 1f7f4f821d422b46cae7.js} +1 -1
- package/assets/esri/core/workers/chunks/1fe24ffcd88280d84fbe.js +1 -0
- package/assets/esri/core/workers/chunks/25a3bd8bede2d07d3a54.js +1 -0
- package/assets/esri/core/workers/chunks/2ad69cc496235702bbf2.js +1 -0
- package/assets/esri/core/workers/chunks/3f46acfda693c70abbdd.js +1 -0
- package/assets/esri/core/workers/chunks/434a8ba841a59e0deab9.js +1 -0
- package/assets/esri/core/workers/chunks/45fd2b456a6997584ca1.js +1 -0
- package/assets/esri/core/workers/chunks/{8480fe6b4372dbbfa7cc.js → 46c5371c7a627537098c.js} +10 -10
- package/assets/esri/core/workers/chunks/53ff68d4f9e365fc15cd.js +1 -0
- package/assets/esri/core/workers/chunks/542e5640ea1b80ef801a.js +1 -0
- package/assets/esri/core/workers/chunks/5a9b7eb26f936f03d02e.js +1 -0
- package/assets/esri/core/workers/chunks/5d76f4d97beee494bbbf.js +1 -0
- package/assets/esri/core/workers/chunks/5dc604e3691f36f03959.js +1 -0
- package/assets/esri/core/workers/chunks/5f07f52bb8b7721f08d3.js +1 -0
- package/assets/esri/core/workers/chunks/{32b351b047ce1eb58146.js → 60c79934799927114074.js} +1 -1
- package/assets/esri/core/workers/chunks/67f54efc817b241f8746.js +1 -0
- package/assets/esri/core/workers/chunks/7159d9c36869cd82599e.js +29 -0
- package/assets/esri/core/workers/chunks/771dd92cb3e6a3427f66.js +1 -0
- package/assets/esri/core/workers/chunks/792d2b62356a1d953c88.js +1 -0
- package/assets/esri/core/workers/chunks/89c8b0f684c1f27d149e.js +1 -0
- package/assets/esri/core/workers/chunks/{9401cc22373566e1171e.js → 8a7b02037151767542f1.js} +1 -1
- package/assets/esri/core/workers/chunks/8ab57cb1bfd3dc8d3c2a.js +1 -0
- package/assets/esri/core/workers/chunks/95b82cbbe355266c65d7.js +1 -0
- package/assets/esri/core/workers/chunks/97b5f4302fb867c829f4.js +1 -0
- package/assets/esri/core/workers/chunks/9de5ad77bc37ec142218.js +1 -0
- package/assets/esri/core/workers/chunks/a65951f1d5702cfd996e.js +1 -0
- package/assets/esri/core/workers/chunks/a6f969851d4278865cc5.js +1 -0
- package/assets/esri/core/workers/chunks/aa4f3751f0d830113bed.js +1 -0
- package/assets/esri/core/workers/chunks/b1d989b72203113a06fe.js +1 -0
- package/assets/esri/core/workers/chunks/{fc73737b41e086f0ce0b.js → b59aaf30c7fe2c8d1aaa.js} +1 -1
- package/assets/esri/core/workers/chunks/b6d71a4ab788a09714f3.js +1 -0
- package/assets/esri/core/workers/chunks/b704f489d0f072a0bfcd.js +1 -0
- package/assets/esri/core/workers/chunks/{28b74bc77f7c13080074.js → be97a629e2ae4d13ceb3.js} +1 -1
- package/assets/esri/core/workers/chunks/{d33360c4f85203edafff.js → bf4d913e523eae2fda28.js} +1 -1
- package/assets/esri/core/workers/chunks/{d6cd0039d6e9c40961e3.js → d1f98c5249c487eb96f1.js} +1 -1
- package/assets/esri/core/workers/chunks/e077e321a3109c2fbbe2.js +1 -0
- package/assets/esri/core/workers/chunks/e251921bc5367258c4d2.js +1 -0
- package/assets/esri/core/workers/chunks/ee08ae5b73439a1ff666.js +1 -0
- package/assets/esri/core/workers/chunks/fcaf9450642fcef83286.js +1 -0
- package/assets/esri/core/workers/chunks/feb41abc03d677df6f73.js +1 -0
- package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +2 -5
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/DefaultMaterial.glsl.js +1 -1
- package/chunks/RealisticTree.glsl.js +1 -1
- package/chunks/RibbonLine.glsl.js +70 -64
- package/config.d.ts +11 -30
- package/config.js +1 -1
- package/core/workers/workerFactory.js +1 -1
- package/core/workers.d.ts +17 -0
- package/kernel.js +1 -1
- package/layers/FeatureLayer.d.ts +39 -19
- package/layers/FeatureLayer.js +1 -1
- package/layers/MapImageLayer.d.ts +10 -3
- package/layers/MapNotesLayer.d.ts +2 -2
- package/layers/SubtypeGroupLayer.d.ts +64 -1
- package/layers/SubtypeGroupLayer.js +1 -1
- package/layers/geospatialPDF/GeospatialPDFLayerWorker.js +1 -1
- package/layers/graphics/sources/FeatureLayerSource.js +1 -1
- package/layers/graphics/sources/support/QueryTask.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphSublayer.d.ts +16 -16
- package/layers/mixins/ArcGISMapService.js +1 -1
- package/layers/ogc/ogcFeatureUtils.js +1 -1
- package/layers/support/LabelClass.d.ts +20 -2
- package/layers/support/Sublayer.d.ts +61 -17
- package/layers/support/Sublayer.js +1 -1
- package/layers/support/TimeInformation.js +2 -0
- package/package.json +2 -2
- package/rest/layerSources/DynamicDataLayer.d.ts +4 -2
- package/rest/layerSources/DynamicDataLayer.js +1 -1
- package/rest/layerSources/DynamicMapLayer.d.ts +1 -1
- package/rest/layerSources/DynamicWorkspaceLayer.d.ts +49 -0
- package/rest/layerSources/DynamicWorkspaceLayer.js +2 -0
- package/rest/layerSources/typeUtils.js +2 -0
- package/rest/query/operations/queryRelatedRecords.js +1 -1
- package/rest/query/operations/queryUtils.js +1 -1
- package/rest/support/Query.js +1 -1
- package/rest/support/RelationshipQuery.js +1 -1
- package/rest/support/timeUtils.js +2 -0
- package/symbols/LineSymbol3D.d.ts +5 -3
- package/symbols/TextSymbol.d.ts +27 -2
- package/views/2d/analysis/AreaMeasurement/AreaMeasurementTool.js +1 -1
- package/views/2d/analysis/AreaMeasurementAnalysisView2D.js +1 -1
- package/views/2d/analysis/DistanceMeasurement/DistanceMeasurementTool.js +1 -1
- package/views/2d/analysis/DistanceMeasurementAnalysisView2D.js +1 -1
- package/views/2d/analysis/ElevationProfileAnalysisView2D.d.ts +6 -0
- package/views/2d/analysis/ElevationProfileAnalysisView2D.js +1 -1
- package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/SubtypeGroupLayerAdapter.js +1 -1
- package/views/3d/GroundView3D.js +1 -1
- package/views/3d/analysis/Dimension/DimensionVisualization.js +1 -1
- package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
- package/views/3d/analysis/Dimension/lengthDimensionManipulatorUtils.js +1 -1
- package/views/3d/analysis/ElevationProfileAnalysisView3D.d.ts +6 -0
- package/views/3d/analysis/ElevationProfileAnalysisView3D.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightObserverPlugin.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightTargetPlugin.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedFieldOfViewManipulation.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedPlacementPointPlugin.js +1 -1
- package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
- package/views/3d/environment/SunLighting.d.ts +17 -1
- package/views/3d/environment/SunLighting.js +1 -1
- package/views/3d/environment/VirtualLighting.d.ts +17 -1
- package/views/3d/environment/VirtualLighting.js +1 -1
- package/views/3d/interactive/editingTools/move/MoveTool3D.js +1 -1
- package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
- package/views/3d/interactive/manipulators/ResizeManipulator.js +1 -1
- package/views/3d/interactive/manipulators/RotateManipulator.js +1 -1
- package/views/3d/interactive/manipulators/ShiftManipulator.js +1 -1
- package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
- package/views/3d/layers/FlowSubView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
- package/views/3d/support/elevationUpdateUtils.js +1 -1
- package/views/3d/terrain/TerrainData.js +1 -1
- package/views/3d/terrain/terrainUtils.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentData.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/SymbolColor.glsl.js +3 -3
- package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialExternalColor.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/output/getEmissions.glsl.js +2 -2
- package/views/3d/webgl-engine/lib/GridLocalOriginFactory.js +1 -1
- package/views/3d/webgl-engine/lib/RenderFeature.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/3d/webgl-engine/shaders/RibbonLineTechniqueConfiguration.js +1 -1
- package/views/BasemapView.js +1 -1
- package/views/BreakpointsOwner.d.ts +6 -0
- package/views/GroundView.d.ts +1 -1
- package/views/GroundView.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileTool.js +1 -1
- package/views/support/ScheduledQueueProcessor.js +1 -1
- package/views/types.d.ts +3 -0
- package/views/webgl/ShaderBuilder.js +1 -1
- package/widgets/Daylight/DaylightViewModel.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/Sketch/SketchViewModel.d.ts +61 -2
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/TimeSlider/TimeSliderViewModel.d.ts +3 -2
- package/widgets/TimeSlider.d.ts +5 -4
- package/assets/esri/core/workers/chunks/0a5a9885ee6f5b5f99f0.js +0 -1
- package/assets/esri/core/workers/chunks/0bd5012da287469b17d5.js +0 -1
- package/assets/esri/core/workers/chunks/112befb3b5b406f29298.js +0 -1
- package/assets/esri/core/workers/chunks/172cfeb5f415e4662432.js +0 -1
- package/assets/esri/core/workers/chunks/2d13a22f7b2427927fdc.js +0 -1
- package/assets/esri/core/workers/chunks/3e3e076fa5e8d5d5f33f.js +0 -1
- package/assets/esri/core/workers/chunks/42fd2a7b22b03dacc6a7.js +0 -1
- package/assets/esri/core/workers/chunks/43cf862577bf37344ff4.js +0 -1
- package/assets/esri/core/workers/chunks/4be559c53fe5ac0d0d2e.js +0 -1
- package/assets/esri/core/workers/chunks/4e350d6c76957f5beb70.js +0 -1
- package/assets/esri/core/workers/chunks/4fe34da1c5d63e66ce98.js +0 -1
- package/assets/esri/core/workers/chunks/510502a4c9a2ba8d3f7b.js +0 -1
- package/assets/esri/core/workers/chunks/612104dff305ff062dfa.js +0 -29
- package/assets/esri/core/workers/chunks/6c9266120d46e8c69dbf.js +0 -1
- package/assets/esri/core/workers/chunks/6c9acd9e4e201dc380e9.js +0 -1
- package/assets/esri/core/workers/chunks/74c866e0b66e61751861.js +0 -1
- package/assets/esri/core/workers/chunks/830ab9b8d000169da675.js +0 -1
- package/assets/esri/core/workers/chunks/8ff23ac0abeea0073b47.js +0 -1
- package/assets/esri/core/workers/chunks/939942b00ba380e2957e.js +0 -1
- package/assets/esri/core/workers/chunks/95dbbddac6581b9d671f.js +0 -1
- package/assets/esri/core/workers/chunks/a40b6d8b5c73e06e14d4.js +0 -1
- package/assets/esri/core/workers/chunks/aa1ac7954e4f0fefe15b.js +0 -1
- package/assets/esri/core/workers/chunks/b5df193c93e9c19f9700.js +0 -1
- package/assets/esri/core/workers/chunks/befa32b9e7b3fbdd431e.js +0 -1
- package/assets/esri/core/workers/chunks/c2c1f51a4668055c2838.js +0 -1
- package/assets/esri/core/workers/chunks/d0f5bee9db1ad51ae687.js +0 -1
- package/assets/esri/core/workers/chunks/d95d63e8d51244d71afb.js +0 -1
- package/assets/esri/core/workers/chunks/dfd2dc5cdc97ffba8926.js +0 -1
- package/assets/esri/core/workers/chunks/e1b7806ab3e1967b15f0.js +0 -1
- package/assets/esri/core/workers/chunks/e1f5d00878f27e1d413e.js +0 -1
- package/assets/esri/core/workers/chunks/e8bf653376a607f00897.js +0 -1
- package/assets/esri/core/workers/chunks/f4a7aa3cdbc0c429c359.js +0 -1
- package/assets/esri/core/workers/chunks/ffbcb816b611049a6276.js +0 -1
|
@@ -54,4 +54,4 @@ this.workerSrc)).WorkerMessageHandler})())}}class Zn{downloadInfoCapability=Prom
|
|
|
54
54
|
`)}`;this.#l();let u=new Range,d=Math.sumPrecise(c.map(e=>e.length));for(let{firstChild:e}of this.editorDiv.childNodes)if(e.nodeType===Node.TEXT_NODE){let t=e.nodeValue.length;if(d<=t){u.setStart(e,d);u.setEnd(e,d);break}d-=t}i.removeAllRanges();i.addRange(u)}#l(){this.editorDiv.replaceChildren();if(this.#e)for(let e of this.#e.split(`
|
|
55
55
|
`)){let t=document.createElement(`div`);t.append(e?document.createTextNode(e):document.createElement(`br`));this.editorDiv.append(t)}}#u(){return this.#e.replaceAll(`\xA0`,` `)}static#d(e){return e.replaceAll(` `,`\xA0`)}get contentDiv(){return this.editorDiv}getPDFRect(){let e=X._internalPadding*this.parentScale;return this.getRect(e,e)}static async deserialize(e,t,n){let r=null;if(e instanceof dr){let{data:{defaultAppearanceData:{fontSize:t,fontColor:n},rect:i,rotation:a,id:o,popupRef:s,richText:c,contentsObj:l,creationDate:u,modificationDate:d},textContent:f,textPosition:p,parent:{page:{pageNumber:m}}}=e;if(!f||f.length===0)return null;r=e={annotationType:_.FREETEXT,color:Array.from(n),fontSize:t,value:f.join(`
|
|
56
56
|
`),position:p,pageIndex:m-1,rect:i.slice(0),rotation:a,annotationElementId:o,id:o,deleted:!1,popupRef:s,comment:l?.str||null,richText:c,creationDate:u,modificationDate:d}}let i=await super.deserialize(e,t,n);i.#r=e.fontSize;i.color=P.makeHexColor(...e.color);i.#e=X.#d(e.value);i._initialData=r;e.comment&&i.setCommentData(e);return i}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let t=H._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),n=Object.assign(super.serialize(e),{color:t,fontSize:this.#r,value:this.#u()});this.addComment(n);if(e){n.isCopy=!0;return n}if(this.annotationElementId&&!this.#f(n))return null;n.id=this.annotationElementId;return n}#f(e){let{value:t,fontSize:n,color:r,pageIndex:i}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||e.value!==t||e.fontSize!==n||e.color.some((e,t)=>e!==r[t])||e.pageIndex!==i}renderAnnotationElement(e){let t=super.renderAnnotationElement(e);if(!t)return null;let{style:n}=t;n.fontSize=`calc(${this.#r}px * var(--total-scale-factor))`;n.color=this.color;t.replaceChildren();for(let e of this.#e.split(`
|
|
57
|
-
`)){let n=document.createElement(`div`);n.append(e?document.createTextNode(e):document.createElement(`br`));t.append(n)}e.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:this.#e}});return t}resetAnnotationElement(e){super.resetAnnotationElement(e);e.resetEdited()}}class Z{static PRECISION=1e-4;toSVGPath(){D("Abstract method `toSVGPath` must be implemented.")}get box(){D("Abstract getter `box` must be implemented.")}serialize(e,t){D("Abstract method `serialize` must be implemented.")}static _rescale(e,t,n,r,i,a){a||=new Float32Array(e.length);for(let o=0,s=e.length;o<s;o+=2){a[o]=t+e[o]*r;a[o+1]=n+e[o+1]*i}return a}static _rescaleAndSwap(e,t,n,r,i,a){a||=new Float32Array(e.length);for(let o=0,s=e.length;o<s;o+=2){a[o]=t+e[o+1]*r;a[o+1]=n+e[o]*i}return a}static _translate(e,t,n,r){r||=new Float32Array(e.length);for(let i=0,a=e.length;i<a;i+=2){r[i]=t+e[i];r[i+1]=n+e[i+1]}return r}static svgRound(e){return Math.round(1e4*e)}static _normalizePoint(e,t,n,r,i){switch(i){case 90:return[1-t/n,e/r];case 180:return[1-e/n,1-t/r];case 270:return[t/n,1-e/r];default:return[e/n,t/r]}}static _normalizePagePoint(e,t,n){switch(n){case 90:return[1-t,e];case 180:return[1-e,1-t];case 270:return[t,1-e];default:return[e,t]}}static createBezierPoints(e,t,n,r,i,a){return[(e+5*n)/6,(t+5*r)/6,(5*n+i)/6,(5*r+a)/6,(n+i)/2,(r+a)/2]}}class gr{#e;#t=[];#n;#r;#i=[];#a=new Float32Array(18);#o;#s;#c;#l;#u;#d;#f=[];static#p=8;static#m=2;static#h=gr.#p+gr.#m;constructor({x:e,y:t},n,r,i,a,o=0){this.#e=n;this.#d=i*r;this.#r=a;this.#a.set([NaN,NaN,NaN,NaN,e,t],6);this.#n=o;this.#l=gr.#p*r;this.#c=gr.#h*r;this.#u=r;this.#f.push(e,t)}isEmpty(){return isNaN(this.#a[8])}#g(){let e=this.#a.subarray(4,6),t=this.#a.subarray(16,18),[n,r,i,a]=this.#e;return[(this.#o+(e[0]-t[0])/2-n)/i,(this.#s+(e[1]-t[1])/2-r)/a,(this.#o+(t[0]-e[0])/2-n)/i,(this.#s+(t[1]-e[1])/2-r)/a]}add({x:e,y:t}){this.#o=e;this.#s=t;let[n,r,i,a]=this.#e,[o,s,c,l]=this.#a.subarray(8,12),u=e-c,d=t-l,f=Math.hypot(u,d);if(f<this.#c)return!1;let p=f-this.#l,m=p/f,h=m*u,g=m*d,_=o,v=s;o=c;s=l;c+=h;l+=g;this.#f?.push(e,t);let y=h/p,b=-g/p*this.#d,x=y*this.#d;this.#a.set(this.#a.subarray(2,8),0);this.#a.set([c+b,l+x],4);this.#a.set(this.#a.subarray(14,18),12);this.#a.set([c-b,l-x],16);if(isNaN(this.#a[6])){if(this.#i.length===0){this.#a.set([o+b,s+x],2);this.#i.push(NaN,NaN,NaN,NaN,(o+b-n)/i,(s+x-r)/a);this.#a.set([o-b,s-x],14);this.#t.push(NaN,NaN,NaN,NaN,(o-b-n)/i,(s-x-r)/a)}this.#a.set([_,v,o,s,c,l],6);return!this.isEmpty()}this.#a.set([_,v,o,s,c,l],6);if(Math.abs(Math.atan2(v-s,_-o)-Math.atan2(g,h))<Math.PI/2){[o,s,c,l]=this.#a.subarray(2,6);this.#i.push(NaN,NaN,NaN,NaN,((o+c)/2-n)/i,((s+l)/2-r)/a);[o,s,_,v]=this.#a.subarray(14,18);this.#t.push(NaN,NaN,NaN,NaN,((_+o)/2-n)/i,((v+s)/2-r)/a);return!0}[_,v,o,s,c,l]=this.#a.subarray(0,6);this.#i.push(((_+5*o)/6-n)/i,((v+5*s)/6-r)/a,((5*o+c)/6-n)/i,((5*s+l)/6-r)/a,((o+c)/2-n)/i,((s+l)/2-r)/a);[c,l,o,s,_,v]=this.#a.subarray(12,18);this.#t.push(((_+5*o)/6-n)/i,((v+5*s)/6-r)/a,((5*o+c)/6-n)/i,((5*s+l)/6-r)/a,((o+c)/2-n)/i,((s+l)/2-r)/a);return!0}toSVGPath(){if(this.isEmpty())return``;let e=this.#i,t=this.#t;if(isNaN(this.#a[6])&&!this.isEmpty())return this.#_();let n=[];n.push(`M${e[4]} ${e[5]}`);for(let t=6;t<e.length;t+=6)isNaN(e[t])?n.push(`L${e[t+4]} ${e[t+5]}`):n.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);this.#y(n);for(let e=t.length-6;e>=6;e-=6)isNaN(t[e])?n.push(`L${t[e+4]} ${t[e+5]}`):n.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);this.#v(n);return n.join(` `)}#_(){let[e,t,n,r]=this.#e,[i,a,o,s]=this.#g();return`M${(this.#a[2]-e)/n} ${(this.#a[3]-t)/r} L${(this.#a[4]-e)/n} ${(this.#a[5]-t)/r} L${i} ${a} L${o} ${s} L${(this.#a[16]-e)/n} ${(this.#a[17]-t)/r} L${(this.#a[14]-e)/n} ${(this.#a[15]-t)/r} Z`}#v(e){let t=this.#t;e.push(`L${t[4]} ${t[5]} Z`)}#y(e){let[t,n,r,i]=this.#e,a=this.#a.subarray(4,6),o=this.#a.subarray(16,18),[s,c,l,u]=this.#g();e.push(`L${(a[0]-t)/r} ${(a[1]-n)/i} L${s} ${c} L${l} ${u} L${(o[0]-t)/r} ${(o[1]-n)/i}`)}newFreeDrawOutline(e,t,n,r,i,a){return new _r(e,t,n,r,i,a)}getOutlines(){let e=this.#i,t=this.#t,n=this.#a,[r,i,a,o]=this.#e,s=new Float32Array((this.#f?.length??0)+2);for(let e=0,t=s.length-2;e<t;e+=2){s[e]=(this.#f[e]-r)/a;s[e+1]=(this.#f[e+1]-i)/o}s[s.length-2]=(this.#o-r)/a;s[s.length-1]=(this.#s-i)/o;if(isNaN(n[6])&&!this.isEmpty())return this.#b(s);let c=new Float32Array(this.#i.length+24+this.#t.length),l=e.length;for(let t=0;t<l;t+=2)if(isNaN(e[t]))c[t]=c[t+1]=NaN;else{c[t]=e[t];c[t+1]=e[t+1]}l=this.#S(c,l);for(let e=t.length-6;e>=6;e-=6)for(let n=0;n<6;n+=2)if(isNaN(t[e+n])){c[l]=c[l+1]=NaN;l+=2}else{c[l]=t[e+n];c[l+1]=t[e+n+1];l+=2}this.#x(c,l);return this.newFreeDrawOutline(c,s,this.#e,this.#u,this.#n,this.#r)}#b(e){let t=this.#a,[n,r,i,a]=this.#e,[o,s,c,l]=this.#g(),u=new Float32Array(36);u.set([NaN,NaN,NaN,NaN,(t[2]-n)/i,(t[3]-r)/a,NaN,NaN,NaN,NaN,(t[4]-n)/i,(t[5]-r)/a,NaN,NaN,NaN,NaN,o,s,NaN,NaN,NaN,NaN,c,l,NaN,NaN,NaN,NaN,(t[16]-n)/i,(t[17]-r)/a,NaN,NaN,NaN,NaN,(t[14]-n)/i,(t[15]-r)/a],0);return this.newFreeDrawOutline(u,e,this.#e,this.#u,this.#n,this.#r)}#x(e,t){let n=this.#t;e.set([NaN,NaN,NaN,NaN,n[4],n[5]],t);return t+6}#S(e,t){let n=this.#a.subarray(4,6),r=this.#a.subarray(16,18),[i,a,o,s]=this.#e,[c,l,u,d]=this.#g();e.set([NaN,NaN,NaN,NaN,(n[0]-i)/o,(n[1]-a)/s,NaN,NaN,NaN,NaN,c,l,NaN,NaN,NaN,NaN,u,d,NaN,NaN,NaN,NaN,(r[0]-i)/o,(r[1]-a)/s],t);return t+24}}class _r extends Z{#e;#t=new Float32Array(4);#n;#r;#i;#a;#o;constructor(e,t,n,r,i,a){super();this.#o=e;this.#i=t;this.#e=n;this.#a=r;this.#n=i;this.#r=a;this.firstPoint=[NaN,NaN];this.lastPoint=[NaN,NaN];this.#s(a);let[o,s,c,l]=this.#t;for(let t=0,n=e.length;t<n;t+=2){e[t]=(e[t]-o)/c;e[t+1]=(e[t+1]-s)/l}for(let e=0,n=t.length;e<n;e+=2){t[e]=(t[e]-o)/c;t[e+1]=(t[e+1]-s)/l}}toSVGPath(){let e=[`M${this.#o[4]} ${this.#o[5]}`];for(let t=6,n=this.#o.length;t<n;t+=6)isNaN(this.#o[t])?e.push(`L${this.#o[t+4]} ${this.#o[t+5]}`):e.push(`C${this.#o[t]} ${this.#o[t+1]} ${this.#o[t+2]} ${this.#o[t+3]} ${this.#o[t+4]} ${this.#o[t+5]}`);e.push(`Z`);return e.join(` `)}serialize([e,t,n,r],i){let a=n-e,o=r-t,s,c;switch(i){case 0:s=Z._rescale(this.#o,e,r,a,-o);c=Z._rescale(this.#i,e,r,a,-o);break;case 90:s=Z._rescaleAndSwap(this.#o,e,t,a,o);c=Z._rescaleAndSwap(this.#i,e,t,a,o);break;case 180:s=Z._rescale(this.#o,n,t,-a,o);c=Z._rescale(this.#i,n,t,-a,o);break;case 270:s=Z._rescaleAndSwap(this.#o,n,r,-a,-o);c=Z._rescaleAndSwap(this.#i,n,r,-a,-o)}return{outline:Array.from(s),points:[Array.from(c)]}}#s(e){let t=this.#o,n=t[4],r=t[5],i=[n,r,n,r],a=n,o=r,s=n,c=r,l=e?Math.max:Math.min,d=new Float32Array(4);for(let e=6,f=t.length;e<f;e+=6){let f=t[e+4],p=t[e+5];if(isNaN(t[e])){P.pointBoundingBox(f,p,i);if(o>p){a=f;o=p}else o===p&&(a=l(a,f));if(c<p){s=f;c=p}else c===p&&(s=l(s,f))}else{d.set(u,0);P.bezierBoundingBox(n,r,...t.slice(e,e+6),d);P.rectBoundingBox(...d,i);if(o>d[1]){a=d[0];o=d[1]}else o===d[1]&&(a=l(a,d[0]));if(c<d[3]){s=d[2];c=d[3]}else c===d[3]&&(s=l(s,d[2]))}n=f;r=p}let f=this.#t;f[0]=i[0]-this.#n;f[1]=i[1]-this.#n;f[2]=i[2]-i[0]+2*this.#n;f[3]=i[3]-i[1]+2*this.#n;this.firstPoint=[a,o];this.lastPoint=[s,c]}get box(){return this.#t}newOutliner(e,t,n,r,i,a=0){return new gr(e,t,n,r,i,a)}getNewOutline(e,t){let[n,r,i,a]=this.#t,[o,s,c,l]=this.#e,u=i*c,d=a*l,f=n*c+o,p=r*l+s,m=this.newOutliner({x:this.#i[0]*u+f,y:this.#i[1]*d+p},this.#e,this.#a,e,this.#r,t??this.#n);for(let e=2;e<this.#i.length;e+=2)m.add({x:this.#i[e]*u+f,y:this.#i[e+1]*d+p});return m.getOutlines()}}class vr{#e;#t;#n;#r=[];#i=[];constructor(e,t=0,n=0,r=!0){let i=u.slice(),a=1e-4;for(let{x:n,y:r,width:o,height:s}of e){let e=Math.floor((n-t)/a)*a,c=Math.ceil((n+o+t)/a)*a,l=Math.floor((r-t)/a)*a,u=Math.ceil((r+s+t)/a)*a,d=[e,l,u,!0],f=[c,l,u,!1];this.#r.push(d,f);P.rectBoundingBox(e,l,c,u,i)}let o=i[2]-i[0]+2*n,s=i[3]-i[1]+2*n,c=i[0]-n,l=i[1]-n,d=r?-1/0:1/0,f=1/0,p=this.#r.at(r?-1:-2),m=[p[0],p[2]];for(let e of this.#r){let[t,n,i,a]=e;if(!a&&r){if(n<f){f=n;d=t}else n===f&&(d=Math.max(d,t))}else if(a&&!r){if(n<f){f=n;d=t}else n===f&&(d=Math.min(d,t))}e[0]=(t-c)/o;e[1]=(n-l)/s;e[2]=(i-l)/s}this.#e=new Float32Array([c,l,o,s]);this.#t=[d,f];this.#n=m}getOutlines(){this.#r.sort((e,t)=>e[0]-t[0]||e[1]-t[1]||e[2]-t[2]);let e=[];for(let t of this.#r)if(t[3]){e.push(...this.#l(t));this.#s(t)}else{this.#c(t);e.push(...this.#l(t))}return this.#a(e)}#a(e){let t=[],n=new Set;for(let n of e){let[e,r,i]=n;t.push([e,r,n],[e,i,n])}t.sort((e,t)=>e[1]-t[1]||e[0]-t[0]);for(let e=0,r=t.length;e<r;e+=2){let r=t[e][2],i=t[e+1][2];r.push(i);i.push(r);n.add(r);n.add(i)}let r=[],i;for(;n.size>0;){let e=n.values().next().value,[t,a,o,s,c]=e;n.delete(e);let l=t,u=a;i=[t,o];r.push(i);for(;;){let e;if(n.has(s))e=s;else{if(!n.has(c))break;e=c}n.delete(e);[t,a,o,s,c]=e;if(l!==t){i.push(l,u,t,u===a?a:o);l=t}u=u===a?o:a}i.push(l,u)}return new yr(r,this.#e,this.#t,this.#n)}#o(e){let t=this.#i,n=0,r=t.length-1;for(;n<=r;){let i=n+r>>1,a=t[i][0];if(a===e)return i;a<e?n=i+1:r=i-1}return r+1}#s([,e,t]){let n=this.#o(e);this.#i.splice(n,0,[e,t])}#c([,e,t]){let n=this.#o(e);for(let r=n;r<this.#i.length;r++){let[n,i]=this.#i[r];if(n!==e)break;if(n===e&&i===t){this.#i.splice(r,1);return}}for(let r=n-1;r>=0;r--){let[n,i]=this.#i[r];if(n!==e)break;if(n===e&&i===t){this.#i.splice(r,1);return}}}#l(e){let[t,n,r]=e,i=[[t,n,r]],a=this.#o(r);for(let e=0;e<a;e++){let[n,r]=this.#i[e];for(let e=0,a=i.length;e<a;e++){let[,o,s]=i[e];if(!(r<=o||s<=n)){if(o>=n){if(s>r)i[e][1]=r;else{if(a===1)return[];i.splice(e,1);e--;a--}}else{i[e][2]=n;s>r&&i.push([t,r,s])}}}}return i}}class yr extends Z{#e;#t;constructor(e,t,n,r){super();this.#t=e;this.#e=t;this.firstPoint=n;this.lastPoint=r}toSVGPath(){let e=[];for(let t of this.#t){let[n,r]=t;e.push(`M${n} ${r}`);for(let i=2;i<t.length;i+=2){let a=t[i],o=t[i+1];if(a===n){e.push(`V${o}`);r=o}else if(o===r){e.push(`H${a}`);n=a}}e.push(`Z`)}return e.join(` `)}serialize([e,t,n,r],i){let a=[],o=n-e,s=r-t;for(let t of this.#t){let n=Array(t.length);for(let i=0;i<t.length;i+=2){n[i]=e+t[i]*o;n[i+1]=r-t[i+1]*s}a.push(n)}return a}get box(){return this.#e}get classNamesForOutlining(){return[`highlightOutline`]}}class br extends gr{newFreeDrawOutline(e,t,n,r,i,a){return new xr(e,t,n,r,i,a)}}class xr extends _r{newOutliner(e,t,n,r,i,a=0){return new br(e,t,n,r,i,a)}}class Q extends H{#e=null;#t=0;#n;#r=null;#i=null;#a=null;#o=null;#s=0;#c=null;#l=null;#u=null;#d=!1;#f=null;#p=null;#m=null;#h=``;#g;#_=``;static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type=`highlight`;static _editorType=_.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId=``;static get _keyboardManager(){let e=Q.prototype;return j(this,`_keyboardManager`,new Ie([[[`ArrowLeft`,`mac+ArrowLeft`],e._moveCaret,{args:[0]}],[[`ArrowRight`,`mac+ArrowRight`],e._moveCaret,{args:[1]}],[[`ArrowUp`,`mac+ArrowUp`],e._moveCaret,{args:[2]}],[[`ArrowDown`,`mac+ArrowDown`],e._moveCaret,{args:[3]}]]))}constructor(e){super({...e,name:`highlightEditor`});this.color=e.color||Q._defaultColor;this.#g=e.thickness||Q._defaultThickness;this.opacity=e.opacity||Q._defaultOpacity;this.#n=e.boxes||null;this.#_=e.methodOfCreation||``;this.#h=e.text||``;this._isDraggable=!1;this.defaultL10nId=`pdfjs-editor-highlight-editor`;if(e.highlightId>-1){this.#d=!0;this.#y(e);this.#w()}else if(this.#n){this.#e=e.anchorNode;this.#t=e.anchorOffset;this.#o=e.focusNode;this.#s=e.focusOffset;this.#v();this.#w();this.rotate(this.rotation)}this.annotationElementId||this._uiManager.a11yAlert(H._l10nAlert.highlight)}get telemetryInitialData(){return{action:`added`,type:this.#d?`free_highlight`:`highlight`,color:this._uiManager.getNonHCMColorName(this.color),thickness:this.#g,methodOfCreation:this.#_}}get telemetryFinalData(){return{type:`highlight`,color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get(`color`).size}}#v(){let e=new vr(this.#n,.001);this.#l=e.getOutlines();[this.x,this.y,this.width,this.height]=this.#l.box;let t=new vr(this.#n,.0025,.001,this._uiManager.direction===`ltr`);this.#a=t.getOutlines();let{firstPoint:n}=this.#l;this.#f=[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height];let{lastPoint:r}=this.#a;this.#p=[(r[0]-this.x)/this.width,(r[1]-this.y)/this.height]}#y({highlightOutlines:e,highlightId:t,clipPathId:n}){this.#l=e;this.#a=e.getNewOutline(this.#g/2+1.5,.0025);if(t>=0){this.#u=t;this.#r=n;this.parent.drawLayer.finalizeDraw(t,{bbox:e.box,path:{d:e.toSVGPath()}});this.#m=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#a.box,path:{d:this.#a.toSVGPath()}},!0)}else if(this.parent){let t=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#u,{bbox:Q.#T(this.#l.box,(t-this.rotation+360)%360),path:{d:e.toSVGPath()}});this.parent.drawLayer.updateProperties(this.#m,{bbox:Q.#T(this.#a.box,t),path:{d:this.#a.toSVGPath()}})}let[r,i,a,o]=e.box;switch(this.rotation){case 0:this.x=r;this.y=i;this.width=a;this.height=o;break;case 90:{let[e,t]=this.parentDimensions;this.x=i;this.y=1-r;this.width=a*t/e;this.height=o*e/t;break}case 180:this.x=1-r;this.y=1-i;this.width=a;this.height=o;break;case 270:{let[e,t]=this.parentDimensions;this.x=1-i;this.y=r;this.width=a*t/e;this.height=o*e/t;break}}let{firstPoint:s}=e;this.#f=[(s[0]-r)/a,(s[1]-i)/o];let{lastPoint:c}=this.#a;this.#p=[(c[0]-r)/a,(c[1]-i)/o]}static initialize(e,t){H.initialize(e,t);Q._defaultColor||=t.highlightColors?.values().next().value||`#fff066`}static updateDefaultParams(e,t){switch(e){case v.HIGHLIGHT_COLOR:Q._defaultColor=t;break;case v.HIGHLIGHT_THICKNESS:Q._defaultThickness=t}}translateInPage(e,t){}get toolbarPosition(){return this.#p}get commentButtonPosition(){return this.#f}updateParams(e,t){switch(e){case v.HIGHLIGHT_COLOR:this.#b(t);break;case v.HIGHLIGHT_THICKNESS:this.#x(t)}}static get defaultPropertiesToUpdate(){return[[v.HIGHLIGHT_COLOR,Q._defaultColor],[v.HIGHLIGHT_THICKNESS,Q._defaultThickness]]}get propertiesToUpdate(){return[[v.HIGHLIGHT_COLOR,this.color||Q._defaultColor],[v.HIGHLIGHT_THICKNESS,this.#g||Q._defaultThickness],[v.HIGHLIGHT_FREE,this.#d]]}onUpdatedColor(){this.parent?.drawLayer.updateProperties(this.#u,{root:{fill:this.color,"fill-opacity":this.opacity}});this.#i?.updateColor(this.color);super.onUpdatedColor()}#b(e){let t=(e,t)=>{this.color=e;this.opacity=t;this.onUpdatedColor()},n=this.color,r=this.opacity;this.addCommands({cmd:t.bind(this,e,Q._defaultOpacity),undo:t.bind(this,n,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:v.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0});this._reportTelemetry({action:`color_changed`,color:this._uiManager.getNonHCMColorName(e)},!0)}#x(e){let t=this.#g,n=e=>{this.#g=e;this.#S(e)};this.addCommands({cmd:n.bind(this,e),undo:n.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:v.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0});this._reportTelemetry({action:`thickness_changed`,thickness:e},!0)}get toolbarButtons(){if(this._uiManager.highlightColors)return[[`colorPicker`,this.#i=new Y({editor:this})]];return super.toolbarButtons}disableEditing(){super.disableEditing();this.div.classList.toggle(`disabled`,!0)}enableEditing(){super.enableEditing();this.div.classList.toggle(`disabled`,!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#O())}getBaseTranslation(){return[0,0]}getRect(e,t){return super.getRect(e,t,this.#O())}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this);e&&this.div.focus()}remove(){this.#C();this._reportTelemetry({action:`deleted`});super.remove()}rebuild(){if(this.parent){super.rebuild();if(this.div!==null){this.#w();this.isAttachedToDOM||this.parent.add(this)}}}setParent(e){let t=!1;if(this.parent&&!e)this.#C();else if(e){this.#w(e);t=!this.parent&&this.div?.classList.contains(`selectedEditor`)}super.setParent(e);this.show(this._isVisible);t&&this.select()}#S(e){if(this.#d){this.#y({highlightOutlines:this.#l.getNewOutline(e/2)});this.fixAndSetPosition();this.setDims()}}#C(){if(this.#u!==null&&this.parent){this.parent.drawLayer.remove(this.#u);this.#u=null;this.parent.drawLayer.remove(this.#m);this.#m=null}}#w(e=this.parent){if(this.#u===null){({id:this.#u,clipPathId:this.#r}=e.drawLayer.draw({bbox:this.#l.box,root:{viewBox:`0 0 1 1`,fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:this.#d},path:{d:this.#l.toSVGPath()}},!1,!0));this.#m=e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#d},bbox:this.#a.box,path:{d:this.#a.toSVGPath()}},this.#d);this.#c&&(this.#c.style.clipPath=this.#r)}}static#T([e,t,n,r],i){switch(i){case 90:return[1-t-r,e,r,n];case 180:return[1-e-n,1-t-r,n,r];case 270:return[t,1-e-n,r,n]}return[e,t,n,r]}rotate(e){let{drawLayer:t}=this.parent,n;if(this.#d){e=(e-this.rotation+360)%360;n=Q.#T(this.#l.box,e)}else n=Q.#T([this.x,this.y,this.width,this.height],e);t.updateProperties(this.#u,{bbox:n,root:{"data-main-rotation":e}});t.updateProperties(this.#m,{bbox:Q.#T(this.#a.box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;let e=super.render();if(this.#h){e.setAttribute(`aria-label`,this.#h);e.setAttribute(`role`,`mark`)}this.#d?e.classList.add(`free`):this.div.addEventListener(`keydown`,this.#E.bind(this),{signal:this._uiManager._signal});let t=this.#c=document.createElement(`div`);e.append(t);t.setAttribute(`aria-hidden`,`true`);t.className=`internal`;t.style.clipPath=this.#r;this.setDims();Me(this,this.#c,[`pointerover`,`pointerleave`]);this.enableEditing();return e}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#m,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#m,{rootClass:{hovered:!1}})}#E(e){Q._keyboardManager.exec(this,e)}_moveCaret(e){this.parent.unselect(this);switch(e){case 0:case 2:this.#D(!0);break;case 1:case 3:this.#D(!1)}}#D(e){if(!this.#e)return;let t=window.getSelection();e?t.setPosition(this.#e,this.#t):t.setPosition(this.#o,this.#s)}select(){super.select();this.#m&&this.parent?.drawLayer.updateProperties(this.#m,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect();if(this.#m){this.parent?.drawLayer.updateProperties(this.#m,{rootClass:{selected:!1}});this.#d||this.#D(!1)}}get _mustFixPosition(){return!this.#d}show(e=this._isVisible){super.show(e);if(this.parent){this.parent.drawLayer.updateProperties(this.#u,{rootClass:{hidden:!e}});this.parent.drawLayer.updateProperties(this.#m,{rootClass:{hidden:!e}})}}#O(){return this.#d?this.rotation:0}#k(){if(this.#d)return null;let[e,t]=this.pageDimensions,[n,r]=this.pageTranslation,i=this.#n,a=new Float32Array(8*i.length),o=0;for(let{x:s,y:c,width:l,height:u}of i){let i=s*e+n,d=(1-c)*t+r;a[o]=a[o+4]=i;a[o+1]=a[o+3]=d;a[o+2]=a[o+6]=i+l*e;a[o+5]=a[o+7]=d-u*t;o+=8}return a}#A(e){return this.#l.serialize(e,this.#O())}static startHighlighting(e,t,{target:n,x:r,y:i}){let{x:a,y:o,width:s,height:c}=n.getBoundingClientRect(),l=new AbortController,u=e.combinedSignal(l),d=t=>{l.abort();this.#M(e,t)};window.addEventListener(`blur`,d,{signal:u});window.addEventListener(`pointerup`,d,{signal:u});window.addEventListener(`pointerdown`,R,{capture:!0,passive:!1,signal:u});window.addEventListener(`contextmenu`,L,{signal:u});n.addEventListener(`pointermove`,this.#j.bind(this,e),{signal:u});this._freeHighlight=new br({x:r,y:i},[a,o,s,c],e.scale,this._defaultThickness/2,t,.001);({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:`0 0 1 1`,fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0))}static#j(e,t){this._freeHighlight.add(t)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#M(e,t){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(t,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:`main_toolbar`});this._freeHighlightId=-1;this._freeHighlight=null;this._freeHighlightClipId=``}static async deserialize(e,t,n){let r=null;if(e instanceof pr){let{data:{quadPoints:t,rect:n,rotation:i,id:a,color:o,opacity:s,popupRef:c,richText:l,contentsObj:u,creationDate:d,modificationDate:f},parent:{page:{pageNumber:p}}}=e;r=e={annotationType:_.HIGHLIGHT,color:Array.from(o),opacity:s,quadPoints:t,boxes:null,pageIndex:p-1,rect:n.slice(0),rotation:i,annotationElementId:a,id:a,deleted:!1,popupRef:c,richText:l,comment:u?.str||null,creationDate:d,modificationDate:f}}else if(e instanceof fr){let{data:{inkLists:t,rect:n,rotation:i,id:a,color:o,borderStyle:{rawWidth:s},popupRef:c,richText:l,contentsObj:u,creationDate:d,modificationDate:f},parent:{page:{pageNumber:p}}}=e;r=e={annotationType:_.HIGHLIGHT,color:Array.from(o),thickness:s,inkLists:t,boxes:null,pageIndex:p-1,rect:n.slice(0),rotation:i,annotationElementId:a,id:a,deleted:!1,popupRef:c,richText:l,comment:u?.str||null,creationDate:d,modificationDate:f}}let{color:i,quadPoints:a,inkLists:o,outlines:s,opacity:c}=e,l=await super.deserialize(e,t,n);l.color=P.makeHexColor(...i);l.opacity=c||1;o&&(l.#g=e.thickness);l._initialData=r;e.comment&&l.setCommentData(e);let[u,d]=l.pageDimensions,[f,p]=l.pageTranslation;if(a){let e=l.#n=[];for(let t=0;t<a.length;t+=8)e.push({x:(a[t]-f)/u,y:1-(a[t+1]-p)/d,width:(a[t+2]-a[t])/u,height:(a[t+1]-a[t+5])/d});l.#v();l.#w();l.rotate(l.rotation)}else if(o||s){l.#d=!0;let e=(o||s.points)[0],n={x:e[0]-f,y:d-(e[1]-p)},r=new br(n,[0,0,u,d],1,l.#g/2,!0,.001);for(let t=0,i=e.length;t<i;t+=2){n.x=e[t]-f;n.y=d-(e[t+1]-p);r.add(n)}let{id:i,clipPathId:a}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:`0 0 1 1`,fill:l.color,"fill-opacity":l._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:r.toSVGPath()}},!0,!0);l.#y({highlightOutlines:r.getOutlines(),highlightId:i,clipPathId:a});l.#w();l.rotate(l.parentRotation)}return l}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();let t=H._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),n=super.serialize(e);Object.assign(n,{color:t,opacity:this.opacity,thickness:this.#g,quadPoints:this.#k(),outlines:this.#A(n.rect)});this.addComment(n);if(this.annotationElementId&&!this.#N(n))return null;n.id=this.annotationElementId;return n}#N(e){let{color:t}=this._initialData;return this.hasEditedComment||e.color.some((e,n)=>e!==t[n])}renderAnnotationElement(e){if(this.deleted){e.hide();return null}e.updateEdited({rect:this.getPDFRect(),popup:this.comment});return null}static canCreateNewEmptyEditor(){return!1}}class Sr{#e=Object.create(null);updateProperty(e,t){this[e]=t;this.updateSVGProperty(e,t)}updateProperties(e){if(e)for(let[t,n]of Object.entries(e))t.startsWith(`_`)||this.updateProperty(t,n)}updateSVGProperty(e,t){this.#e[e]=t}toSVGProperties(){let e=this.#e;this.#e=Object.create(null);return{root:e}}reset(){this.#e=Object.create(null)}updateAll(e=this){this.updateProperties(e)}clone(){D(`Not implemented`)}}class $ extends H{#e=null;#t;_colorPicker=null;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#n=null;static#r=null;static#i=null;static _INNER_MARGIN=3;constructor(e){super(e);this.#t=e.mustBeCommitted||!1;this._addOutlines(e)}onUpdatedColor(){this._colorPicker?.update(this.color);super.onUpdatedColor()}onUpdatedOpacity(){this._colorPicker?.updateOpacity?.(this.opacity)}_addOutlines(e){if(e.drawOutlines){this.#a(e);this.#c()}}#a({drawOutlines:e,drawId:t,drawingOptions:n}){this.#e=e;this._drawingOptions||=n;this.annotationElementId||this._uiManager.a11yAlert(H._l10nAlert[this.editorType]);if(t>=0){this._drawId=t;this.parent.drawLayer.finalizeDraw(t,e.defaultProperties)}else this._drawId=this.#o(e,this.parent);this.#d(e.box)}#o(e,t){let{id:n}=t.drawLayer.draw($._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return n}static _mergeSVGProperties(e,t){let n=new Set(Object.keys(e));for(let[r,i]of Object.entries(t))n.has(r)?Object.assign(e[r],i):e[r]=i;return e}static getDefaultDrawingOptions(e){D(`Not implemented`)}static get typesMap(){D(`Not implemented`)}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,t){let n=this.typesMap.get(e);n&&this._defaultDrawingOptions.updateProperty(n,t);if(this._currentParent){$.#n.updateProperty(n,t);this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties())}}updateParams(e,t){let n=this.constructor.typesMap.get(e);n&&this._updateProperty(e,n,t)}static get defaultPropertiesToUpdate(){let e=[],t=this._defaultDrawingOptions;for(let[n,r]of this.typesMap)e.push([n,t[r]]);return e}get propertiesToUpdate(){let e=[],{_drawingOptions:t}=this;for(let[n,r]of this.constructor.typesMap)e.push([n,t[r]]);return e}_updateProperty(e,t,n){let r=this._drawingOptions,i=r[t],a=n=>{r.updateProperty(t,n);let i=this.#e.updateProperty(t,n);i&&this.#d(i);this.parent?.drawLayer.updateProperties(this._drawId,r.toSVGProperties());e===this.colorType?this.onUpdatedColor():e===this.opacityType&&this.onUpdatedOpacity()};this.addCommands({cmd:a.bind(this,n),undo:a.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(e,t){let n=this.constructor.typesMap.get(this.colorType),r=this.constructor.typesMap.get(this.opacityType),i=this._drawingOptions,a=i[n],o=i[r],s=(e,t)=>{i.updateProperty(n,e);i.updateProperty(r,t);this.#e.updateProperty(n,e);this.#e.updateProperty(r,t);this.parent?.drawLayer.updateProperties(this._drawId,i.toSVGProperties());this.onUpdatedColor();this.onUpdatedOpacity()};this.addCommands({cmd:s.bind(this,e,t),undo:s.bind(this,a,o),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:v.INK_COLOR_AND_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,$._mergeSVGProperties(this.#e.getPathResizingSVGProperties(this.#u()),{bbox:this.#f()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,$._mergeSVGProperties(this.#e.getPathResizedSVGProperties(this.#u()),{bbox:this.#f()}))}_onTranslating(e,t){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#f()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,$._mergeSVGProperties(this.#e.getPathTranslatedSVGProperties(this.#u(),this.parentDimensions),{bbox:this.#f()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit();this.disableEditMode();this.disableEditing()}disableEditing(){super.disableEditing();this.div.classList.toggle(`disabled`,!0)}enableEditing(){super.enableEditing();this.div.classList.toggle(`disabled`,!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this);this._isDraggable=!0;if(this.#t){this.#t=!1;this.commit();this.parent.setSelected(this);e&&this.isOnScreen&&this.div.focus()}}remove(){this.#s();super.remove()}rebuild(){if(this.parent){super.rebuild();if(this.div!==null){this.#c();this.#d(this.#e.box);this.isAttachedToDOM||this.parent.add(this)}}}setParent(e){let t=!1;if(this.parent&&!e){this._uiManager.removeShouldRescale(this);this.#s()}else if(e){this._uiManager.addShouldRescale(this);this.#c(e);t=!this.parent&&this.div?.classList.contains(`selectedEditor`)}super.setParent(e);t&&this.select()}#s(){if(this._drawId!==null&&this.parent){this.parent.drawLayer.remove(this._drawId);this._drawId=null;this._drawingOptions.reset()}}#c(e=this.parent){if(this._drawId===null||this.parent!==e){if(this._drawId===null){this._drawingOptions.updateAll();this._drawId=this.#o(this.#e,e)}else this.parent.drawLayer.updateParent(this._drawId,e.drawLayer)}}#l([e,t,n,r]){let{parentDimensions:[i,a],rotation:o}=this;switch(o){case 90:return[t,1-e,a/i*n,i/a*r];case 180:return[1-e,1-t,n,r];case 270:return[1-t,e,a/i*n,i/a*r];default:return[e,t,n,r]}}#u(){let{x:e,y:t,width:n,height:r,parentDimensions:[i,a],rotation:o}=this;switch(o){case 90:return[1-t,e,i/a*n,a/i*r];case 180:return[1-e,1-t,n,r];case 270:return[t,1-e,i/a*n,a/i*r];default:return[e,t,n,r]}}#d(e){[this.x,this.y,this.width,this.height]=this.#l(e);if(this.div){this.fixAndSetPosition();this.setDims()}this._onResized()}#f(){let{x:e,y:t,width:n,height:r,rotation:i,parentRotation:a,parentDimensions:[o,s]}=this;switch((4*i+a)/90){case 1:return[1-t-r,e,r,n];case 2:return[1-e-n,1-t-r,n,r];case 3:return[t,1-e-n,r,n];case 4:return[e,t-o/s*n,s/o*r,o/s*n];case 5:return[1-t,e,o/s*n,s/o*r];case 6:return[1-e-s/o*r,1-t,s/o*r,o/s*n];case 7:return[t-o/s*n,1-e-s/o*r,o/s*n,s/o*r];case 8:return[e-n,t-r,n,r];case 9:return[1-t,e-n,r,n];case 10:return[1-e,1-t,n,r];case 11:return[t-r,1-e,r,n];case 12:return[e-s/o*r,t,s/o*r,o/s*n];case 13:return[1-t-o/s*n,e-s/o*r,o/s*n,s/o*r];case 14:return[1-e,1-t-o/s*n,s/o*r,o/s*n];case 15:return[t,1-e,o/s*n,s/o*r];default:return[e,t,n,r]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,$._mergeSVGProperties({bbox:this.#f()},this.#e.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#d(this.#e.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let e,t;if(this._isCopy){e=this.x;t=this.y}let n=super.render();n.classList.add(`draw`);let r=document.createElement(`div`);n.append(r);r.setAttribute(`aria-hidden`,`true`);r.className=`internal`;this.setDims();this._uiManager.addShouldRescale(this);this.disableEditing();this._isCopy&&this._moveAfterPaste(e,t);return n}static createDrawerInstance(e,t,n,r,i){D(`Not implemented`)}static startDrawing(e,t,n,r){let{target:i,offsetX:a,offsetY:o,pointerId:s,pointerType:c}=r;if(V.isInitializedAndDifferentPointerType(c))return;let{viewport:{rotation:l}}=e,{width:u,height:d}=i.getBoundingClientRect(),f=$.#r=new AbortController,p=e.combinedSignal(f);V.setPointer(c,s);window.addEventListener(`pointerup`,e=>{V.isSamePointerIdOrRemove(e.pointerId)&&this._endDraw(e)},{signal:p});window.addEventListener(`pointercancel`,e=>{V.isSamePointerIdOrRemove(e.pointerId)&&this._currentParent.endDrawingSession()},{signal:p});window.addEventListener(`pointerdown`,e=>{if(V.isSamePointerType(e.pointerType)){V.initializeAndAddPointerId(e.pointerId);if($.#n.isCancellable()){$.#n.removeLastElement();$.#n.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)}}},{capture:!0,passive:!1,signal:p});window.addEventListener(`contextmenu`,L,{signal:p});i.addEventListener(`pointermove`,this._drawMove.bind(this),{signal:p});i.addEventListener(`touchmove`,e=>{V.isSameTimeStamp(e.timeStamp)&&R(e)},{signal:p});e.toggleDrawing();t._editorUndoBar?.hide();if($.#n)e.drawLayer.updateProperties(this._currentDrawId,$.#n.startNew(a,o,u,d,l));else{t.updateUIForDefaultProperties(this);$.#n=this.createDrawerInstance(a,o,u,d,l);$.#i=this.getDefaultDrawingOptions();this._currentParent=e;({id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties($.#i.toSVGProperties(),$.#n.defaultSVGProperties),!0,!1))}}static _drawMove(e){V.isSameTimeStamp(e.timeStamp);if(!$.#n)return;let{offsetX:t,offsetY:n,pointerId:r}=e;if(V.isSamePointerId(r)){if(V.isUsingMultiplePointers())this._endDraw(e);else{this._currentParent.drawLayer.updateProperties(this._currentDrawId,$.#n.add(t,n));V.setTimeStamp(e.timeStamp);R(e)}}}static _cleanup(e){if(e){this._currentDrawId=-1;this._currentParent=null;$.#n=null;$.#i=null;V.clearTimeStamp()}if($.#r){$.#r.abort();$.#r=null;V.clearPointerIds()}}static _endDraw(e){let t=this._currentParent;if(t){t.toggleDrawing(!0);this._cleanup(!1);e?.target===t.div&&t.drawLayer.updateProperties(this._currentDrawId,$.#n.end(e.offsetX,e.offsetY));if(this.supportMultipleDrawings){let e=$.#n,n=this._currentDrawId,r=e.getLastElement();t.addCommands({cmd:()=>{t.drawLayer.updateProperties(n,e.setLastElement(r))},undo:()=>{t.drawLayer.updateProperties(n,e.removeLastElement())},mustExec:!1,type:v.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){let t=this._currentParent;if(!t)return null;t.toggleDrawing(!0);t.cleanUndoStack(v.DRAW_STEP);if(!$.#n.isEmpty()){let{pageDimensions:[n,r],scale:i}=t,a=t.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:$.#n.getOutlines(n*i,r*i,i,this._INNER_MARGIN),drawingOptions:$.#i,mustBeCommitted:!e});this._cleanup(!0);return a}t.drawLayer.remove(this._currentDrawId);this._cleanup(!0);return null}createDrawingOptions(e){}static deserializeDraw(e,t,n,r,i,a){D(`Not implemented`)}static async deserialize(e,t,n){let{rawDims:{pageWidth:r,pageHeight:i,pageX:a,pageY:o}}=t.viewport,s=this.deserializeDraw(a,o,r,i,this._INNER_MARGIN,e),c=await super.deserialize(e,t,n);c.createDrawingOptions(e);c.#a({drawOutlines:s});c.#c();c.onScaleChanging();c.rotate();return c}serializeDraw(e){let[t,n]=this.pageTranslation,[r,i]=this.pageDimensions;return this.#e.serialize([t,n,r,i],e)}renderAnnotationElement(e){e.updateEdited({rect:this.getPDFRect()});return null}static canCreateNewEmptyEditor(){return!1}}class Cr{#e=new Float64Array(6);#t;#n;#r;#i;#a;#o=``;#s=0;#c=new wr;#l;#u;constructor(e,t,n,r,i,a){this.#l=n;this.#u=r;this.#r=i;this.#i=a;[e,t]=this.#d(e,t);let o=this.#t=[NaN,NaN,NaN,NaN,e,t];this.#a=[e,t];this.#n=[{line:o,points:this.#a}];this.#e.set(o,0)}updateProperty(e,t){e===`stroke-width`&&(this.#i=t)}#d(e,t){return Z._normalizePoint(e,t,this.#l,this.#u,this.#r)}isEmpty(){return!this.#n||this.#n.length===0}isCancellable(){return this.#a.length<=10}add(e,t){[e,t]=this.#d(e,t);let[n,r,i,a]=this.#e.subarray(2,6),o=e-i,s=t-a;if(Math.hypot(this.#l*o,this.#u*s)<=2)return null;this.#a.push(e,t);if(isNaN(n)){this.#e.set([i,a,e,t],2);this.#t.push(NaN,NaN,NaN,NaN,e,t);return{path:{d:this.toSVGPath()}}}isNaN(this.#e[0])&&this.#t.splice(6,6);this.#e.set([n,r,i,a,e,t],0);this.#t.push(...Z.createBezierPoints(n,r,i,a,e,t));return{path:{d:this.toSVGPath()}}}end(e,t){return this.add(e,t)||(this.#a.length===2?{path:{d:this.toSVGPath()}}:null)}startNew(e,t,n,r,i){this.#l=n;this.#u=r;this.#r=i;[e,t]=this.#d(e,t);let a=this.#t=[NaN,NaN,NaN,NaN,e,t];this.#a=[e,t];let o=this.#n.at(-1);if(o){o.line=new Float32Array(o.line);o.points=new Float32Array(o.points)}this.#n.push({line:a,points:this.#a});this.#e.set(a,0);this.#s=0;this.toSVGPath();return null}getLastElement(){return this.#n.at(-1)}setLastElement(e){if(!this.#n)return this.#c.setLastElement(e);this.#n.push(e);this.#t=e.line;this.#a=e.points;this.#s=0;return{path:{d:this.toSVGPath()}}}removeLastElement(){if(!this.#n)return this.#c.removeLastElement();this.#n.pop();this.#o=``;for(let e=0,t=this.#n.length;e<t;e++){let{line:t,points:n}=this.#n[e];this.#t=t;this.#a=n;this.#s=0;this.toSVGPath()}return{path:{d:this.#o}}}toSVGPath(){let e=Z.svgRound(this.#t[4]),t=Z.svgRound(this.#t[5]);if(this.#a.length===2){this.#o=`${this.#o} M ${e} ${t} Z`;return this.#o}if(this.#a.length<=6){let n=this.#o.lastIndexOf(`M`);this.#o=`${this.#o.slice(0,n)} M ${e} ${t}`;this.#s=6}if(this.#a.length===4){let e=Z.svgRound(this.#t[10]),t=Z.svgRound(this.#t[11]);this.#o=`${this.#o} L ${e} ${t}`;this.#s=12;return this.#o}let n=[];if(this.#s===0){n.push(`M ${e} ${t}`);this.#s=6}for(let e=this.#s,t=this.#t.length;e<t;e+=6){let[t,r,i,a,o,s]=this.#t.slice(e,e+6).map(Z.svgRound);n.push(`C${t} ${r} ${i} ${a} ${o} ${s}`)}this.#o+=n.join(` `);this.#s=this.#t.length;return this.#o}getOutlines(e,t,n,r){let i=this.#n.at(-1);i.line=new Float32Array(i.line);i.points=new Float32Array(i.points);this.#c.build(this.#n,e,t,n,this.#r,this.#i,r);this.#e=null;this.#t=null;this.#n=null;this.#o=null;return this.#c}get defaultSVGProperties(){return{root:{viewBox:`0 0 10000 10000`},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class wr extends Z{#e;#t=0;#n;#r;#i;#a;#o;#s;#c;build(e,t,n,r,i,a,o){this.#i=t;this.#a=n;this.#o=r;this.#s=i;this.#c=a;this.#n=o??0;this.#r=e;this.#d()}get thickness(){return this.#c}setLastElement(e){this.#r.push(e);return{path:{d:this.toSVGPath()}}}removeLastElement(){this.#r.pop();return{path:{d:this.toSVGPath()}}}toSVGPath(){let e=[];for(let{line:t}of this.#r){e.push(`M${Z.svgRound(t[4])} ${Z.svgRound(t[5])}`);if(t.length!==6){if(t.length===12&&isNaN(t[6]))e.push(`L${Z.svgRound(t[10])} ${Z.svgRound(t[11])}`);else for(let n=6,r=t.length;n<r;n+=6){let[r,i,a,o,s,c]=t.subarray(n,n+6).map(Z.svgRound);e.push(`C${r} ${i} ${a} ${o} ${s} ${c}`)}}else e.push(`Z`)}return e.join(``)}serialize([e,t,n,r],i){let a=[],o=[],[s,c,l,u]=this.#u(),d,f,p,m,h,g,_,v,y;switch(this.#s){case 0:y=Z._rescale;d=e;f=t+r;p=n;m=-r;h=e+s*n;g=t+(1-c-u)*r;_=e+(s+l)*n;v=t+(1-c)*r;break;case 90:y=Z._rescaleAndSwap;d=e;f=t;p=n;m=r;h=e+c*n;g=t+s*r;_=e+(c+u)*n;v=t+(s+l)*r;break;case 180:y=Z._rescale;d=e+n;f=t;p=-n;m=r;h=e+(1-s-l)*n;g=t+c*r;_=e+(1-s)*n;v=t+(c+u)*r;break;case 270:y=Z._rescaleAndSwap;d=e+n;f=t+r;p=-n;m=-r;h=e+(1-c-u)*n;g=t+(1-s-l)*r;_=e+(1-c)*n;v=t+(1-s)*r}for(let{line:e,points:t}of this.#r){a.push(y(e,d,f,p,m,i?Array(e.length):null));o.push(y(t,d,f,p,m,i?Array(t.length):null))}return{lines:a,points:o,rect:[h,g,_,v]}}static deserialize(e,t,n,r,i,{paths:{lines:a,points:o},rotation:s,thickness:c}){let l=[],u,d,f,p,m;switch(s){case 0:m=Z._rescale;u=-e/n;d=t/r+1;f=1/n;p=-1/r;break;case 90:m=Z._rescaleAndSwap;u=-t/r;d=-e/n;f=1/r;p=1/n;break;case 180:m=Z._rescale;u=e/n+1;d=-t/r;f=-1/n;p=1/r;break;case 270:m=Z._rescaleAndSwap;u=t/r+1;d=e/n+1;f=-1/r;p=-1/n}if(!a){a=[];for(let e of o){let t=e.length;if(t===2){a.push(new Float32Array([NaN,NaN,NaN,NaN,e[0],e[1]]));continue}if(t===4){a.push(new Float32Array([NaN,NaN,NaN,NaN,e[0],e[1],NaN,NaN,NaN,NaN,e[2],e[3]]));continue}let n=new Float32Array(3*(t-2));a.push(n);let[r,i,o,s]=e.subarray(0,4);n.set([NaN,NaN,NaN,NaN,r,i],0);for(let a=4;a<t;a+=2){let t=e[a],c=e[a+1];n.set(Z.createBezierPoints(r,i,o,s,t,c),3*(a-2));[r,i,o,s]=[o,s,t,c]}}}for(let e=0,t=a.length;e<t;e++)l.push({line:m(a[e].map(e=>e??NaN),u,d,f,p),points:m(o[e].map(e=>e??NaN),u,d,f,p)});let h=new this.prototype.constructor;h.build(l,n,r,1,s,c,i);return h}#l(e=this.#c){let t=this.#n+e/2*this.#o;return this.#s%180==0?[t/this.#i,t/this.#a]:[t/this.#a,t/this.#i]}#u(){let[e,t,n,r]=this.#e,[i,a]=this.#l(0);return[e+i,t+a,n-2*i,r-2*a]}#d(){let e=this.#e=d.slice();for(let{line:t}of this.#r){if(t.length<=12){for(let n=4,r=t.length;n<r;n+=6)P.pointBoundingBox(t[n],t[n+1],e);continue}let n=t[4],r=t[5];for(let i=6,a=t.length;i<a;i+=6){let[a,o,s,c,l,u]=t.subarray(i,i+6);P.bezierBoundingBox(n,r,a,o,s,c,l,u,e);n=l;r=u}}let[t,n]=this.#l();e[0]=F(e[0]-t,0,1);e[1]=F(e[1]-n,0,1);e[2]=F(e[2]+t,0,1);e[3]=F(e[3]+n,0,1);e[2]-=e[0];e[3]-=e[1]}get box(){return this.#e}updateProperty(e,t){return e===`stroke-width`?this.#f(t):null}#f(e){let[t,n]=this.#l();this.#c=e;let[r,i]=this.#l(),[a,o]=[r-t,i-n],s=this.#e;s[0]-=a;s[1]-=o;s[2]+=2*a;s[3]+=2*o;return s}updateParentDimensions([e,t],n){let[r,i]=this.#l();this.#i=e;this.#a=t;this.#o=n;let[a,o]=this.#l(),s=a-r,c=o-i,l=this.#e;l[0]-=s;l[1]-=c;l[2]+=2*s;l[3]+=2*c;return l}updateRotation(e){this.#t=e;return{path:{transform:this.rotationTransform}}}get viewBox(){return this.#e.map(Z.svgRound).join(` `)}get defaultProperties(){let[e,t]=this.#e;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Z.svgRound(e)} ${Z.svgRound(t)}`}}}get rotationTransform(){let[,,e,t]=this.#e,n=0,r=0,i=0,a=0,o=0,s=0;switch(this.#t){case 90:r=t/e;i=-e/t;o=e;break;case 180:n=-1;a=-1;o=e;s=t;break;case 270:r=-t/e;i=e/t;s=t;break;default:return``}return`matrix(${n} ${r} ${i} ${a} ${Z.svgRound(o)} ${Z.svgRound(s)})`}getPathResizingSVGProperties([e,t,n,r]){let[i,a]=this.#l(),[o,s,c,l]=this.#e;if(Math.abs(c-i)<=Z.PRECISION||Math.abs(l-a)<=Z.PRECISION){let i=e+n/2-(o+c/2),a=t+r/2-(s+l/2);return{path:{"transform-origin":`${Z.svgRound(e)} ${Z.svgRound(t)}`,transform:`${this.rotationTransform} translate(${i} ${a})`}}}let u=(n-2*i)/(c-2*i),d=(r-2*a)/(l-2*a),f=c/n,p=l/r;return{path:{"transform-origin":`${Z.svgRound(o)} ${Z.svgRound(s)}`,transform:`${this.rotationTransform} scale(${f} ${p}) translate(${Z.svgRound(i)} ${Z.svgRound(a)}) scale(${u} ${d}) translate(${Z.svgRound(-i)} ${Z.svgRound(-a)})`}}}getPathResizedSVGProperties([e,t,n,r]){let[i,a]=this.#l(),o=this.#e,[s,c,l,u]=o;o[0]=e;o[1]=t;o[2]=n;o[3]=r;if(Math.abs(l-i)<=Z.PRECISION||Math.abs(u-a)<=Z.PRECISION){let i=e+n/2-(s+l/2),a=t+r/2-(c+u/2);for(let{line:e,points:t}of this.#r){Z._translate(e,i,a,e);Z._translate(t,i,a,t)}return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Z.svgRound(e)} ${Z.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let d=(n-2*i)/(l-2*i),f=(r-2*a)/(u-2*a),p=-d*(s+i)+e+i,m=-f*(c+a)+t+a;if(d!==1||f!==1||p!==0||m!==0)for(let{line:e,points:t}of this.#r){Z._rescale(e,p,m,d,f,e);Z._rescale(t,p,m,d,f,t)}return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Z.svgRound(e)} ${Z.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,t],n){let[r,i]=n,a=this.#e,o=e-a[0],s=t-a[1];if(this.#i===r&&this.#a===i)for(let{line:e,points:t}of this.#r){Z._translate(e,o,s,e);Z._translate(t,o,s,t)}else{let e=this.#i/r,t=this.#a/i;this.#i=r;this.#a=i;for(let{line:n,points:r}of this.#r){Z._rescale(n,o,s,e,t,n);Z._rescale(r,o,s,e,t,r)}a[2]*=e;a[3]*=t}a[0]=e;a[1]=t;return{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${Z.svgRound(e)} ${Z.svgRound(t)}`}}}get defaultSVGProperties(){let e=this.#e;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Z.svgRound(e[0])} ${Z.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}}class Tr extends Sr{constructor(e){super();this._viewParameters=e;super.updateProperties({fill:`none`,stroke:H._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-miterlimit":10})}updateSVGProperty(e,t){if(e===`stroke-width`){t??=this[`stroke-width`];t*=this._viewParameters.realScale}super.updateSVGProperty(e,t)}clone(){let e=new Tr(this._viewParameters);e.updateAll(this);return e}}class Er extends ${static _type=`ink`;static _editorType=_.INK;static _defaultDrawingOptions=null;constructor(e){super({...e,name:`inkEditor`});this._willKeepAspectRatio=!0;this.defaultL10nId=`pdfjs-editor-ink-editor`}static initialize(e,t){H.initialize(e,t);this._defaultDrawingOptions=new Tr(t.viewParameters)}static getDefaultDrawingOptions(e){let t=this._defaultDrawingOptions.clone();t.updateProperties(e);return t}static get supportMultipleDrawings(){return!0}static get typesMap(){return j(this,`typesMap`,new Map([[v.INK_THICKNESS,`stroke-width`],[v.INK_COLOR,`stroke`],[v.INK_OPACITY,`stroke-opacity`]]))}static createDrawerInstance(e,t,n,r,i){return new Cr(e,t,n,r,i,this._defaultDrawingOptions[`stroke-width`])}static deserializeDraw(e,t,n,r,i,a){return wr.deserialize(e,t,n,r,i,a)}static async deserialize(e,t,n){let r=null;if(e instanceof fr){let{data:{inkLists:t,rect:n,rotation:i,id:a,color:o,opacity:s,borderStyle:{rawWidth:c},popupRef:l,richText:u,contentsObj:d,creationDate:f,modificationDate:p},parent:{page:{pageNumber:m}}}=e;r=e={annotationType:_.INK,color:Array.from(o),thickness:c,opacity:s,paths:{points:t},boxes:null,pageIndex:m-1,rect:n.slice(0),rotation:i,annotationElementId:a,id:a,deleted:!1,popupRef:l,richText:u,comment:d?.str||null,creationDate:f,modificationDate:p}}let i=await super.deserialize(e,t,n);i._initialData=r;e.comment&&i.setCommentData(e);return i}get toolbarButtons(){this._colorPicker||=new er(this);return[[`colorPicker`,this._colorPicker]]}get colorType(){return v.INK_COLOR}get colorAndOpacityType(){return v.INK_COLOR_AND_OPACITY}get opacityType(){return v.INK_OPACITY}updateParams(e,t){e===v.INK_COLOR_AND_OPACITY?this._updateColorAndOpacity(t.color,t.opacity):super.updateParams(e,t)}static updateDefaultParams(e,t){if(e!==v.INK_COLOR_AND_OPACITY)super.updateDefaultParams(e,t);else{super.updateDefaultParams(v.INK_COLOR,t.color);super.updateDefaultParams(v.INK_OPACITY,t.opacity)}}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions[`stroke-opacity`]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();let{_drawId:e,_drawingOptions:t,parent:n}=this;t.updateSVGProperty(`stroke-width`);n.drawLayer.updateProperties(e,t.toSVGProperties())}static onScaleChangingWhenDrawing(){let e=this._currentParent;if(e){super.onScaleChangingWhenDrawing();this._defaultDrawingOptions.updateSVGProperty(`stroke-width`);e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties())}}createDrawingOptions({color:e,thickness:t,opacity:n}){this._drawingOptions=Er.getDefaultDrawingOptions({stroke:P.makeHexColor(...e),"stroke-width":t,"stroke-opacity":n})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:t,points:n}=this.serializeDraw(e),{_drawingOptions:{stroke:r,"stroke-opacity":i,"stroke-width":a}}=this,o=Object.assign(super.serialize(e),{color:H._colorManager.convert(r),opacity:i,thickness:a,paths:{lines:t,points:n}});this.addComment(o);if(e){o.isCopy=!0;return o}if(this.annotationElementId&&!this.#e(o))return null;o.id=this.annotationElementId;return o}#e(e){let{color:t,thickness:n,opacity:r,pageIndex:i}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||e.color.some((e,n)=>e!==t[n])||e.thickness!==n||e.opacity!==r||e.pageIndex!==i}renderAnnotationElement(e){if(this.deleted){e.hide();return null}let{points:t,rect:n}=this.serializeDraw(!1);e.updateEdited({rect:n,thickness:this._drawingOptions[`stroke-width`],points:t,popup:this.comment});return null}}class Dr extends wr{toSVGPath(){let e=super.toSVGPath();e.endsWith(`Z`)||(e+=`Z`);return e}}class Or{static#e={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};static#t(e,t,n,r){r-=t;return(n-=e)===0?r>0?0:4:n===1?r+6:2-r}static#n=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#r(e,t,n,r,i,a,o){let s=this.#t(n,r,i,a);for(let i=0;i<8;i++){let a=(-i+s-o+16)%8;if(e[(n+this.#n[2*a])*t+(r+this.#n[2*a+1])]!==0)return a}return-1}static#i(e,t,n,r,i,a,o){let s=this.#t(n,r,i,a);for(let i=0;i<8;i++){let a=(i+s+o+16)%8;if(e[(n+this.#n[2*a])*t+(r+this.#n[2*a+1])]!==0)return a}return-1}static#a(e,t,n,r){let i=e.length,a=new Int32Array(i);for(let t=0;t<i;t++)a[t]=+(e[t]<=r);for(let e=1;e<n-1;e++)a[e*t]=a[e*t+t-1]=0;for(let e=0;e<t;e++)a[e]=a[t*n-1-e]=0;let o,s=1,c=[];for(let e=1;e<n-1;e++){o=1;for(let n=1;n<t-1;n++){let r=e*t+n,i=a[r];if(i===0)continue;let l=e,u=n;if(i===1&&a[r-1]===0){s+=1;--u}else{if(!(i>=1&&a[r+1]===0)){i!==1&&(o=Math.abs(i));continue}s+=1;u+=1;i>1&&(o=i)}let d=[n,e],f=u===n+1,p={isHole:f,points:d,id:s,parent:0};c.push(p);let m;for(let e of c)if(e.id===o){m=e;break}p.parent=m?m.isHole?f?m.parent:o:f?o:m.parent:f?o:0;let h=this.#r(a,t,e,n,l,u,0);if(h===-1){a[r]=-s;a[r]!==1&&(o=Math.abs(a[r]));continue}let g=this.#n[2*h],_=this.#n[2*h+1],v=e+g,y=n+_;l=v;u=y;let b=e,x=n;for(;;){let i=this.#i(a,t,b,x,l,u,1);g=this.#n[2*i];_=this.#n[2*i+1];let c=b+g,f=x+_;d.push(f,c);let p=b*t+x;a[p+1]===0?a[p]=-s:a[p]===1&&(a[p]=s);if(c===e&&f===n&&b===v&&x===y){a[r]!==1&&(o=Math.abs(a[r]));break}l=b;u=x;b=c;x=f}}}return c}static#o(e,t,n,r){if(n-t<=4){for(let i=t;i<n-2;i+=2)r.push(e[i],e[i+1]);return}let i=e[t],a=e[t+1],o=e[n-4]-i,s=e[n-3]-a,c=Math.hypot(o,s),l=o/c,u=s/c,d=l*a-u*i,f=s/o,p=1/c,m=Math.atan(f),h=Math.cos(m),g=Math.sin(m),_=p*(Math.abs(h)+Math.abs(g)),v=p*(1-_+_**2),y=Math.max(Math.atan(Math.abs(g+h)*v),Math.atan(Math.abs(g-h)*v)),b=0,x=t;for(let r=t+2;r<n-2;r+=2){let t=Math.abs(d-l*e[r+1]+u*e[r]);if(t>b){x=r;b=t}}if(b>(c*y)**2){this.#o(e,t,x+2,r);this.#o(e,x,n,r)}else r.push(i,a)}static#s(e){let t=[],n=e.length;this.#o(e,0,n,t);t.push(e[n-2],e[n-1]);return t.length<=4?null:t}static#c(e,t,n,r,i,a){let o=new Float32Array(a**2),s=-2*r**2,c=a>>1;for(let e=0;e<a;e++){let t=(e-c)**2;for(let n=0;n<a;n++)o[e*a+n]=Math.exp((t+(n-c)**2)/s)}let l=new Float32Array(256),u=-2*i**2;for(let e=0;e<256;e++)l[e]=Math.exp(e**2/u);let d=e.length,f=new Uint8Array(d),p=new Uint32Array(256);for(let r=0;r<n;r++)for(let i=0;i<t;i++){let s=r*t+i,u=e[s],d=0,m=0;for(let s=0;s<a;s++){let f=r+s-c;if(!(f<0||f>=n))for(let n=0;n<a;n++){let r=i+n-c;if(r<0||r>=t)continue;let p=e[f*t+r],h=o[s*a+n]*l[Math.abs(p-u)];d+=p*h;m+=h}}p[f[s]=Math.round(d/m)]++}return[f,p]}static#l(e){let t=new Uint32Array(256);for(let n of e)t[n]++;return t}static#u(e){let t=e.length,n=new Uint8ClampedArray(t>>2),r=-1/0,i=1/0;for(let t=0,a=n.length;t<a;t++){let a=n[t]=e[t<<2];r=Math.max(r,a);i=Math.min(i,a)}let a=255/(r-i);for(let e=0,t=n.length;e<t;e++)n[e]=(n[e]-i)*a;return n}static#d(e){let t,n=-1/0,r=-1/0,i=e.findIndex(e=>e!==0),a=i,o=i;for(t=i;t<256;t++){let i=e[t];if(i>n){if(t-a>r){r=t-a;o=t-1}n=i;a=t}}for(t=o-1;t>=0&&!(e[t]>e[t+1]);t--);return t}static#f(e){let t=e,{width:n,height:r}=e,{maxDim:i}=this.#e,a=n,o=r;if(n>i||r>i){let s=n,c=r,l=Math.log2(Math.max(n,r)/i),u=Math.floor(l);l=l===u?u-1:u;for(let n=0;n<l;n++){a=Math.ceil(s/2);o=Math.ceil(c/2);let n=new OffscreenCanvas(a,o);n.getContext(`2d`).drawImage(e,0,0,s,c,0,0,a,o);s=a;c=o;e!==t&&e.close();e=n.transferToImageBitmap()}let d=Math.min(i/a,i/o);a=Math.round(a*d);o=Math.round(o*d)}let s=new OffscreenCanvas(a,o).getContext(`2d`,{willReadFrequently:!0});s.fillStyle=`white`;s.fillRect(0,0,a,o);s.filter=`grayscale(1)`;s.drawImage(e,0,0,e.width,e.height,0,0,a,o);let c=s.getImageData(0,0,a,o).data;return[this.#u(c),a,o]}static extractContoursFromText(e,{fontFamily:t,fontStyle:n,fontWeight:r},i,a,o,s){let c=new OffscreenCanvas(1,1),l=c.getContext(`2d`,{alpha:!1}),u=l.font=`${n} ${r} 200px ${t}`,{actualBoundingBoxLeft:d,actualBoundingBoxRight:f,actualBoundingBoxAscent:p,actualBoundingBoxDescent:m,fontBoundingBoxAscent:h,fontBoundingBoxDescent:g,width:_}=l.measureText(e),v=1.5,y=Math.ceil(Math.max(Math.abs(d)+Math.abs(f)||0,_)*v),b=Math.ceil(Math.max(Math.abs(p)+Math.abs(m)||200,Math.abs(h)+Math.abs(g)||200)*v);c=new OffscreenCanvas(y,b);l=c.getContext(`2d`,{alpha:!0,willReadFrequently:!0});l.font=u;l.filter=`grayscale(1)`;l.fillStyle=`white`;l.fillRect(0,0,y,b);l.fillStyle=`black`;l.fillText(e,.5*y/2,1.5*b/2);let x=this.#u(l.getImageData(0,0,y,b).data),S=this.#l(x),C=this.#d(S),w=this.#a(x,y,b,C);return this.processDrawnLines({lines:{curves:w,width:y,height:b},pageWidth:i,pageHeight:a,rotation:o,innerMargin:s,mustSmooth:!0,areContours:!0})}static process(e,t,n,r,i){let[a,o,s]=this.#f(e),[c,l]=this.#c(a,o,s,Math.hypot(o,s)*this.#e.sigmaSFactor,this.#e.sigmaR,this.#e.kernelSize),u=this.#d(l),d=this.#a(c,o,s,u);return this.processDrawnLines({lines:{curves:d,width:o,height:s},pageWidth:t,pageHeight:n,rotation:r,innerMargin:i,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:e,pageWidth:t,pageHeight:n,rotation:r,innerMargin:i,mustSmooth:a,areContours:o}){r%180!=0&&([t,n]=[n,t]);let{curves:s,width:c,height:l}=e,u=e.thickness??0,d=[],f=Math.min(t/c,n/l),p=f/t,m=f/n,h=[];for(let{points:e}of s){let t=a?this.#s(e):e;if(!t)continue;h.push(t);let n=t.length,r=new Float32Array(n),i=new Float32Array(3*(n===2?2:n-2));d.push({line:i,points:r});if(n===2){r[0]=t[0]*p;r[1]=t[1]*m;i.set([NaN,NaN,NaN,NaN,r[0],r[1]],0);continue}let[o,s,c,l]=t;o*=p;s*=m;c*=p;l*=m;r.set([o,s,c,l],0);i.set([NaN,NaN,NaN,NaN,o,s],0);for(let e=4;e<n;e+=2){let n=r[e]=t[e]*p,a=r[e+1]=t[e+1]*m;i.set(Z.createBezierPoints(o,s,c,l,n,a),3*(e-2));[o,s,c,l]=[c,l,n,a]}}if(d.length===0)return null;let g=o?new Dr:new wr;g.build(d,t,n,1,r,o?0:u,i);return{outline:g,newCurves:h,areContours:o,thickness:u,width:c,height:l}}static async compressSignature({outlines:e,areContours:t,thickness:n,width:r,height:i}){let a,o=1/0,s=-1/0,c=0;for(let t of e){c+=t.length;for(let e=2,n=t.length;e<n;e++){let n=t[e]-t[e-2];o=Math.min(o,n);s=Math.max(s,n)}}a=o>=-128&&s<=127?Int8Array:o>=-32768&&s<=32767?Int16Array:Int32Array;let l=e.length,u=8+3*l,d=new Uint32Array(u),f=0;d[f++]=u*Uint32Array.BYTES_PER_ELEMENT+(c-2*l)*a.BYTES_PER_ELEMENT;d[f++]=0;d[f++]=r;d[f++]=i;d[f++]=+!t;d[f++]=Math.max(0,Math.floor(n??0));d[f++]=l;d[f++]=a.BYTES_PER_ELEMENT;for(let t of e){d[f++]=t.length-2;d[f++]=t[0];d[f++]=t[1]}let p=new CompressionStream(`deflate-raw`),m=p.writable.getWriter();await m.ready;m.write(d);let h=a.prototype.constructor;for(let t of e){let e=new h(t.length-2);for(let n=2,r=t.length;n<r;n++)e[n-2]=t[n]-t[n-2];m.write(e)}m.close();return(await new Response(p.readable).bytes()).toBase64()}static async decompressSignature(e){try{let t=Uint8Array.fromBase64(e),{readable:n,writable:r}=new DecompressionStream(`deflate-raw`),i=r.getWriter();await i.ready;i.write(t).then(async()=>{await i.ready;await i.close()}).catch(()=>{});let a=null,o=0;for await(let e of n){a||=new Uint8Array(new Uint32Array(e.buffer,0,4)[0]);a.set(e,o);o+=e.length}let s=new Uint32Array(a.buffer,0,a.length>>2),c=s[1];if(c!==0)throw Error(`Invalid version: ${c}`);let l=s[2],u=s[3],d=s[4]===0,f=s[5],p=s[6],m=s[7],h=[],g=(8+3*p)*Uint32Array.BYTES_PER_ELEMENT,_;switch(m){case Int8Array.BYTES_PER_ELEMENT:_=new Int8Array(a.buffer,g);break;case Int16Array.BYTES_PER_ELEMENT:_=new Int16Array(a.buffer,g);break;case Int32Array.BYTES_PER_ELEMENT:_=new Int32Array(a.buffer,g)}o=0;for(let e=0;e<p;e++){let t=s[3*e+8],n=new Float32Array(t+2);h.push(n);for(let t=0;t<2;t++)n[t]=s[3*e+8+t+1];for(let e=0;e<t;e++)n[e+2]=n[e]+_[o++]}return{areContours:d,thickness:f,outlines:h,width:l,height:u}}catch(e){E(`decompressSignature: ${e}`);return null}}}class kr extends Sr{constructor(){super();super.updateProperties({fill:H._defaultLineColor,"stroke-width":0})}clone(){let e=new kr;e.updateAll(this);return e}}class Ar extends Tr{constructor(e){super(e);super.updateProperties({stroke:H._defaultLineColor,"stroke-width":1})}clone(){let e=new Ar(this._viewParameters);e.updateAll(this);return e}}class jr extends ${#e=!1;#t=null;#n=null;#r=null;static _type=`signature`;static _editorType=_.SIGNATURE;static _defaultDrawingOptions=null;constructor(e){super({...e,mustBeCommitted:!0,name:`signatureEditor`});this._willKeepAspectRatio=!0;this.#n=e.signatureData||null;this.#t=null;this.defaultL10nId=`pdfjs-editor-signature-editor1`}static initialize(e,t){H.initialize(e,t);this._defaultDrawingOptions=new kr;this._defaultDrawnSignatureOptions=new Ar(t.viewParameters)}static getDefaultDrawingOptions(e){let t=this._defaultDrawingOptions.clone();t.updateProperties(e);return t}static get supportMultipleDrawings(){return!1}static get typesMap(){return j(this,`typesMap`,new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:`signature`,hasDescription:!!this.#t}}static computeTelemetryFinalData(e){let t=e.get(`hasDescription`);return{hasAltText:t.get(!0)??0,hasNoAltText:t.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let e,t,{_isCopy:n}=this;if(n){this._isCopy=!1;e=this.x;t=this.y}super.render();if(this._drawId===null){if(this.#n){let{lines:e,mustSmooth:t,areContours:n,description:r,uuid:i,heightInPage:a}=this.#n,{rawDims:{pageWidth:o,pageHeight:s},rotation:c}=this.parent.viewport,l=Or.processDrawnLines({lines:e,pageWidth:o,pageHeight:s,rotation:c,innerMargin:jr._INNER_MARGIN,mustSmooth:t,areContours:n});this.addSignature(l,a,r,i)}else{this.div.setAttribute(`data-l10n-args`,JSON.stringify({description:``}));this.div.hidden=!0;this._uiManager.getSignature(this)}}else this.div.setAttribute(`data-l10n-args`,JSON.stringify({description:this.#t||``}));if(n){this._isCopy=!0;this._moveAfterPaste(e,t)}return this.div}setUuid(e){this.#r=e;this.addEditToolbar()}getUuid(){return this.#r}get description(){return this.#t}set description(e){this.#t=e;if(this.div){this.div.setAttribute(`data-l10n-args`,JSON.stringify({description:e}));super.addEditToolbar().then(t=>{t?.updateEditSignatureButton(e)})}}getSignaturePreview(){let{newCurves:e,areContours:t,thickness:n,width:r,height:i}=this.#n,a=Math.max(r,i);return{areContours:t,outline:Or.processDrawnLines({lines:{curves:e.map(e=>({points:e})),thickness:n,width:r,height:i},pageWidth:a,pageHeight:a,rotation:0,innerMargin:0,mustSmooth:!1,areContours:t}).outline}}get toolbarButtons(){return this._uiManager.signatureManager?[[`editSignature`,this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(e,t,n,r){let{x:i,y:a}=this,{outline:o}=this.#n=e;this.#e=o instanceof Dr;this.description=n;let s;if(this.#e)s=jr.getDefaultDrawingOptions();else{s=jr._defaultDrawnSignatureOptions.clone();s.updateProperties({"stroke-width":o.thickness})}this._addOutlines({drawOutlines:o,drawingOptions:s});let[,c]=this.pageDimensions,l=t/c;l=l>=1?.5:l;this.width*=l/this.height;if(this.width>=1){l*=.9/this.width;this.width=.9}this.height=l;this.setDims();this.x=i;this.y=a;this.center();this._onResized();this.onScaleChanging();this.rotate();this._uiManager.addToAnnotationStorage(this);this.setUuid(r);this._reportTelemetry({action:`pdfjs.signature.inserted`,data:{hasBeenSaved:!!r,hasDescription:!!n}});this.div.hidden=!1}getFromImage(e){let{rawDims:{pageWidth:t,pageHeight:n},rotation:r}=this.parent.viewport;return Or.process(e,t,n,r,jr._INNER_MARGIN)}getFromText(e,t){let{rawDims:{pageWidth:n,pageHeight:r},rotation:i}=this.parent.viewport;return Or.extractContoursFromText(e,t,n,r,i,jr._INNER_MARGIN)}getDrawnSignature(e){let{rawDims:{pageWidth:t,pageHeight:n},rotation:r}=this.parent.viewport;return Or.processDrawnLines({lines:e,pageWidth:t,pageHeight:n,rotation:r,innerMargin:jr._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:t}){if(e)this._drawingOptions=jr.getDefaultDrawingOptions();else{this._drawingOptions=jr._defaultDrawnSignatureOptions.clone();this._drawingOptions.updateProperties({"stroke-width":t})}}serialize(e=!1){if(this.isEmpty())return null;let{lines:t,points:n}=this.serializeDraw(e),{_drawingOptions:{"stroke-width":r}}=this,i=Object.assign(super.serialize(e),{isSignature:!0,areContours:this.#e,color:[0,0,0],thickness:this.#e?0:r});this.addComment(i);if(e){i.paths={lines:t,points:n};i.uuid=this.#r;i.isCopy=!0}else i.lines=t;this.#t&&(i.accessibilityData={type:`Figure`,alt:this.#t});return i}static deserializeDraw(e,t,n,r,i,a){return a.areContours?Dr.deserialize(e,t,n,r,i,a):wr.deserialize(e,t,n,r,i,a)}static async deserialize(e,t,n){let r=await super.deserialize(e,t,n);r.#e=e.areContours;r.description=e.accessibilityData?.alt||``;r.#r=e.uuid;return r}}class Mr extends H{#e=null;#t=null;#n=null;#r=null;#i=null;#a=``;#o=null;#s=!1;#c=null;#l=!1;#u=!1;static _type=`stamp`;static _editorType=_.STAMP;constructor(e){super({...e,name:`stampEditor`});this.#r=e.bitmapUrl;this.#i=e.bitmapFile;this.defaultL10nId=`pdfjs-editor-stamp-editor`}static initialize(e,t){H.initialize(e,t)}static isHandlingMimeForPasting(e){return Ee.includes(e)}static paste(e,t){t.pasteEditor({mode:_.STAMP},{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1);super.altTextFinish()}get telemetryFinalData(){return{type:`stamp`,hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(e){let t=e.get(`hasAltText`);return{hasAltText:t.get(!0)??0,hasNoAltText:t.get(!1)??0}}#d(e,t=!1){if(e){this.#e=e.bitmap;if(!t){this.#t=e.id;this.#l=e.isSvg}e.file&&(this.#a=e.file.name);this.#m()}else this.remove()}#f(){this.#n=null;this._uiManager.enableWaiting(!1);if(this.#o){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#e)this.addEditToolbar().then(()=>{this._editToolbar.hide();this._uiManager.editAltText(this,!0)});else{if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#e){this._reportTelemetry({action:`pdfjs.image.image_added`,data:{alt_text_modal:!1,alt_text_type:`empty`}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}}async mlGuessAltText(e=null,t=!0){if(this.hasAltTextData())return null;let{mlManager:n}=this._uiManager;if(!n)throw Error(`No ML.`);if(!await n.isEnabledFor(`altText`))throw Error(`ML isn't enabled for alt text.`);let{data:r,width:i,height:a}=e||this.copyCanvas(null,null,!0).imageData,o=await n.guess({name:`altText`,request:{data:r,width:i,height:a,channels:r.length/(i*a)}});if(!o)throw Error(`No response from the AI service.`);if(o.error)throw Error(`Error from the AI service.`);if(o.cancel)return null;if(!o.output)throw Error(`No valid response from the AI service.`);let s=o.output;await this.setGuessedAltText(s);t&&!this.hasAltTextData()&&(this.altTextData={alt:s,decorative:!1});return s}#p(){if(this.#t){this._uiManager.enableWaiting(!0);this._uiManager.imageManager.getFromId(this.#t).then(e=>this.#d(e,!0)).finally(()=>this.#f());return}if(this.#r){let e=this.#r;this.#r=null;this._uiManager.enableWaiting(!0);this.#n=this._uiManager.imageManager.getFromUrl(e).then(e=>this.#d(e)).finally(()=>this.#f());return}if(this.#i){let e=this.#i;this.#i=null;this._uiManager.enableWaiting(!0);this.#n=this._uiManager.imageManager.getFromFile(e).then(e=>this.#d(e)).finally(()=>this.#f());return}let e=document.createElement(`input`);e.type=`file`;e.accept=Ee.join(`,`);let t=this._uiManager._signal;this.#n=new Promise(n=>{e.addEventListener(`change`,async()=>{if(e.files&&e.files.length!==0){this._uiManager.enableWaiting(!0);let t=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:`pdfjs.image.image_selected`,data:{alt_text_modal:this._uiManager.useNewAltTextFlow}});this.#d(t)}else this.remove();n()},{signal:t});e.addEventListener(`cancel`,()=>{this.remove();n()},{signal:t})}).finally(()=>this.#f());e.click()}remove(){if(this.#t){this.#e=null;this._uiManager.imageManager.deleteId(this.#t);this.#o?.remove();this.#o=null;if(this.#c){clearTimeout(this.#c);this.#c=null}}super.remove()}rebuild(){if(this.parent){super.rebuild();if(this.div!==null){this.#t&&this.#o===null&&this.#p();this.isAttachedToDOM||this.parent.add(this)}}else this.#t&&this.#p()}onceAdded(e){this._isDraggable=!0;e&&this.div.focus()}isEmpty(){return!(this.#n||this.#e||this.#r||this.#i||this.#t||this.#s)}get toolbarButtons(){return[[`altText`,this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let e,t;if(this._isCopy){e=this.x;t=this.y}super.render();this.div.hidden=!0;this.createAltText();this.#s||(this.#e?this.#m():this.#p());this._isCopy&&this._moveAfterPaste(e,t);this._uiManager.addShouldRescale(this);return this.div}setCanvas(e,t){let{id:n,bitmap:r}=this._uiManager.imageManager.getFromCanvas(e,t);t.remove();if(n&&this._uiManager.imageManager.isValidId(n)){this.#t=n;r&&(this.#e=r);this.#s=!1;this.#m()}}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;this.#c!==null&&clearTimeout(this.#c);this.#c=setTimeout(()=>{this.#c=null;this.#g()},200)}#m(){let{div:e}=this,{width:t,height:n}=this.#e,[r,i]=this.pageDimensions,a=.75;if(this.width){t=this.width*r;n=this.height*i}else if(t>a*r||n>a*i){let e=Math.min(a*r/t,a*i/n);t*=e;n*=e}this._uiManager.enableWaiting(!1);let o=this.#o=document.createElement(`canvas`);o.setAttribute(`role`,`img`);this.addContainer(o);this.width=t/r;this.height=n/i;this.setDims();this._initialOptions?.isCentered?this.center():this.fixAndSetPosition();this._initialOptions=null;this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(e.hidden=!1);this.#g();if(!this.#u){this.parent.addUndoableEditor(this);this.#u=!0}this._reportTelemetry({action:`inserted_image`});this.#a&&this.div.setAttribute(`aria-description`,this.#a);this.annotationElementId||this._uiManager.a11yAlert(H._l10nAlert.stamp)}copyCanvas(e,t,n=!1){e||=224;let{width:r,height:i}=this.#e,a=new Te,o=this.#e,s=r,c=i,l=null;if(t){if(r>t||i>t){let e=Math.min(t/r,t/i);s=Math.floor(r*e);c=Math.floor(i*e)}l=document.createElement(`canvas`);let e=l.width=Math.ceil(s*a.sx),n=l.height=Math.ceil(c*a.sy);this.#l||(o=this.#h(e,n));let u=l.getContext(`2d`);u.filter=this._uiManager.hcmFilter;let d=`white`,f=`#cfcfd8`;if(this._uiManager.hcmFilter!==`none`)f=`black`;else if(De.isDarkMode){d=`#8f8f9d`;f=`#42414d`}let p=15*a.sx,m=15*a.sy,h=new OffscreenCanvas(2*p,2*m),g=h.getContext(`2d`);g.fillStyle=d;g.fillRect(0,0,2*p,2*m);g.fillStyle=f;g.fillRect(0,0,p,m);g.fillRect(p,m,p,m);u.fillStyle=u.createPattern(h,`repeat`);u.fillRect(0,0,e,n);u.drawImage(o,0,0,o.width,o.height,0,0,e,n)}let u=null;if(n){let t,n;if(a.symmetric&&o.width<e&&o.height<e){t=o.width;n=o.height}else{o=this.#e;if(r>e||i>e){let a=Math.min(e/r,e/i);t=Math.floor(r*a);n=Math.floor(i*a);this.#l||(o=this.#h(t,n))}}let s=new OffscreenCanvas(t,n).getContext(`2d`,{willReadFrequently:!0});s.drawImage(o,0,0,o.width,o.height,0,0,t,n);u={width:t,height:n,data:s.getImageData(0,0,t,n).data}}return{canvas:l,width:s,height:c,imageData:u}}#h(e,t){let{width:n,height:r}=this.#e,i=n,a=r,o=this.#e;for(;i>2*e||a>2*t;){let n=i,r=a;i>2*e&&(i=Math.ceil(i/2));a>2*t&&(a=Math.ceil(a/2));let s=new OffscreenCanvas(i,a);s.getContext(`2d`).drawImage(o,0,0,n,r,0,0,i,a);o=s.transferToImageBitmap()}return o}#g(){let[e,t]=this.parentDimensions,{width:n,height:r}=this,i=new Te,a=Math.ceil(n*e*i.sx),o=Math.ceil(r*t*i.sy),s=this.#o;if(!s||s.width===a&&s.height===o)return;s.width=a;s.height=o;let c=this.#l?this.#e:this.#h(a,o),l=s.getContext(`2d`);l.filter=this._uiManager.hcmFilter;l.drawImage(c,0,0,c.width,c.height,0,0,a,o)}#_(e){if(e){if(this.#l){let e=this._uiManager.imageManager.getSvgUrl(this.#t);if(e)return e}let e=document.createElement(`canvas`);({width:e.width,height:e.height}=this.#e);e.getContext(`2d`).drawImage(this.#e,0,0);return e.toDataURL()}if(this.#l){let[e,t]=this.pageDimensions,n=Math.round(this.width*e*pe.PDF_TO_CSS_UNITS),r=Math.round(this.height*t*pe.PDF_TO_CSS_UNITS),i=new OffscreenCanvas(n,r);i.getContext(`2d`).drawImage(this.#e,0,0,this.#e.width,this.#e.height,0,0,n,r);return i.transferToImageBitmap()}return structuredClone(this.#e)}static async deserialize(e,t,n){let r=null,i=!1;if(e instanceof mr){let{data:{rect:a,rotation:o,id:s,structParent:c,popupRef:l,richText:u,contentsObj:d,creationDate:f,modificationDate:p},container:m,parent:{page:{pageNumber:g}},canvas:v}=e,y,b;if(v){delete e.canvas;({id:y,bitmap:b}=n.imageManager.getFromCanvas(m.id,v));v.remove()}else{i=!0;e._hasNoCanvas=!0}let x=(await t._structTree.getAriaAttributes(`${h}${s}`))?.get(`aria-label`)||``;r=e={annotationType:_.STAMP,bitmapId:y,bitmap:b,pageIndex:g-1,rect:a.slice(0),rotation:o,annotationElementId:s,id:s,deleted:!1,accessibilityData:{decorative:!1,altText:x},isSvg:!1,structParent:c,popupRef:l,richText:u,comment:d?.str||null,creationDate:f,modificationDate:p}}let a=await super.deserialize(e,t,n),{rect:o,bitmap:s,bitmapUrl:c,bitmapId:l,isSvg:u,accessibilityData:d}=e;if(i){n.addMissingCanvas(e.id,a);a.#s=!0}else if(l&&n.imageManager.isValidId(l)){a.#t=l;s&&(a.#e=s)}else a.#r=c;a.#l=u;let[f,p]=a.pageDimensions;a.width=(o[2]-o[0])/f;a.height=(o[3]-o[1])/p;d&&(a.altTextData=d);a._initialData=r;e.comment&&a.setCommentData(e);a.#u=!!r;return a}serialize(e=!1,t=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let n=Object.assign(super.serialize(e),{bitmapId:this.#t,isSvg:this.#l});this.addComment(n);if(e){n.bitmapUrl=this.#_(!0);n.accessibilityData=this.serializeAltText(!0);n.isCopy=!0;return n}let{decorative:r,altText:i}=this.serializeAltText(!1);!r&&i&&(n.accessibilityData={type:`Figure`,alt:i});if(this.annotationElementId){let e=this.#v(n);if(e.isSame)return null;e.isSameAltText?delete n.accessibilityData:n.accessibilityData.structParent=this._initialData.structParent??-1;n.id=this.annotationElementId;delete n.bitmapId;return n}if(t===null)return n;t.stamps||=new Map;let a=this.#l?(n.rect[2]-n.rect[0])*(n.rect[3]-n.rect[1]):null;if(t.stamps.has(this.#t)){if(this.#l){let e=t.stamps.get(this.#t);if(a>e.area){e.area=a;e.serialized.bitmap.close();e.serialized.bitmap=this.#_(!1)}}}else{t.stamps.set(this.#t,{area:a,serialized:n});n.bitmap=this.#_(!1)}return n}#v(e){let{pageIndex:t,accessibilityData:{altText:n}}=this._initialData,r=e.pageIndex===t,i=(e.accessibilityData?.alt||``)===n;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&r&&i,isSameAltText:i}}renderAnnotationElement(e){if(this.deleted){e.hide();return null}e.updateEdited({rect:this.getPDFRect(),popup:this.comment});return null}}class Nr{#e;#t=!1;#n=null;#r=null;#i=null;#a=new Map;#o=!1;#s=!1;#c=!1;#l=null;#u=null;#d=null;#f=null;#p=null;#m=-1;#h;static _initialized=!1;static#g=new Map([X,Er,Mr,Q,jr].map(e=>[e._editorType,e]));constructor({uiManager:e,pageIndex:t,div:n,structTreeLayer:r,accessibilityManager:i,annotationLayer:a,drawLayer:o,textLayer:s,viewport:c,l10n:l}){let u=[...Nr.#g.values()];if(!Nr._initialized){Nr._initialized=!0;for(let t of u)t.initialize(l,e)}e.registerEditorTypes(u);this.#h=e;this.pageIndex=t;this.div=n;this.#e=i;this.#n=a;this.viewport=c;this.#d=s;this.drawLayer=o;this._structTree=r;this.#h.addLayer(this)}get isEmpty(){return this.#a.size===0}get isInvisible(){return this.isEmpty&&this.#h.getMode()===_.NONE}updateToolbar(e){this.#h.updateToolbar(e)}updateMode(e=this.#h.getMode()){this.#S();switch(e){case _.NONE:this.div.classList.toggle(`nonEditing`,!0);this.disableTextSelection();this.togglePointerEvents(!1);this.toggleAnnotationLayerPointerEvents(!0);this.disableClick();return;case _.INK:this.disableTextSelection();this.togglePointerEvents(!0);this.enableClick();break;case _.HIGHLIGHT:this.enableTextSelection();this.togglePointerEvents(!1);this.disableClick();break;default:this.disableTextSelection();this.togglePointerEvents(!0);this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:t}=this.div;t.toggle(`nonEditing`,!1);if(e===_.POPUP)t.toggle(`commentEditing`,!0);else{t.toggle(`commentEditing`,!1);for(let n of Nr.#g.values())t.toggle(`${n._type}Editing`,e===n._editorType)}this.div.hidden=!1}hasTextLayer(e){return e===this.#d?.div}setEditingState(e){this.#h.setEditingState(e)}addCommands(e){this.#h.addCommands(e)}cleanUndoStack(e){this.#h.cleanUndoStack(e)}toggleDrawing(e=!1){this.div.classList.toggle(`drawing`,!e)}togglePointerEvents(e=!1){this.div.classList.toggle(`disabled`,!e)}toggleAnnotationLayerPointerEvents(e=!1){this.#n?.togglePointerEvents(e)}get#_(){return this.#a.size===0?this.#h.getEditors(this.pageIndex):this.#a.values()}async enable(){this.#c=!0;this.div.tabIndex=0;this.togglePointerEvents(!0);this.div.classList.toggle(`nonEditing`,!1);this.#p?.abort();this.#p=null;let e=new Set;for(let t of this.#_){t.enableEditing();t.show(!0);if(t.annotationElementId){this.#h.removeChangedExistingAnnotation(t);e.add(t.annotationElementId)}}let t=this.#n;if(t)for(let n of t.getEditableAnnotations()){n.hide();if(this.#h.isDeletedAnnotationElement(n.data.id))continue;if(e.has(n.data.id))continue;let t=await this.deserialize(n);if(t){this.addOrRebuild(t);t.enableEditing()}}this.#c=!1;this.#h._eventBus.dispatch(`editorsrendered`,{source:this,pageNumber:this.pageIndex+1})}disable(){this.#s=!0;this.div.tabIndex=-1;this.togglePointerEvents(!1);this.div.classList.toggle(`nonEditing`,!0);if(this.#d&&!this.#p){this.#p=new AbortController;let e=this.#h.combinedSignal(this.#p);this.#d.div.addEventListener(`pointerdown`,e=>{let{clientX:t,clientY:n,timeStamp:r}=e;if(r-this.#m>500){this.#m=r;return}this.#m=-1;let{classList:i}=this.div;i.toggle(`getElements`,!0);let a=document.elementsFromPoint(t,n);i.toggle(`getElements`,!1);if(!this.div.contains(a[0]))return;let o,s=RegExp(`^${g}[0-9]+$`);for(let e of a)if(s.test(e.id)){o=e.id;break}if(!o)return;let c=this.#a.get(o);if(c?.annotationElementId===null){R(e);c.dblclick(e)}},{signal:e,capture:!0})}let e=this.#n,t=[];if(e){let n=new Map,r=new Map;for(let e of this.#_){e.disableEditing();if(e.annotationElementId){if(e.serialize()===null){r.set(e.annotationElementId,e);this.getEditableAnnotation(e.annotationElementId)?.show();e.remove()}else n.set(e.annotationElementId,e)}else t.push(e)}for(let t of e.getEditableAnnotations()){let{id:e}=t.data;if(this.#h.isDeletedAnnotationElement(e)){t.updateEdited({deleted:!0});continue}let i=r.get(e);if(i){i.resetAnnotationElement(t);i.show(!1);t.show()}else{i=n.get(e);if(i){this.#h.addChangedExistingAnnotation(i);i.renderAnnotationElement(t)&&i.show(!1)}t.show()}}}this.#S();this.isEmpty&&(this.div.hidden=!0);let{classList:n}=this.div;for(let e of Nr.#g.values())n.remove(`${e._type}Editing`);this.disableTextSelection();this.toggleAnnotationLayerPointerEvents(!0);e?.updateFakeAnnotations(t);this.#s=!1}getEditableAnnotation(e){return this.#n?.getEditableAnnotation(e)||null}setActiveEditor(e){this.#h.getActive()!==e&&this.#h.setActiveEditor(e)}enableTextSelection(){this.div.tabIndex=-1;if(this.#d?.div&&!this.#f){this.#f=new AbortController;let e=this.#h.combinedSignal(this.#f);this.#d.div.addEventListener(`pointerdown`,this.#v.bind(this),{signal:e});this.#d.div.classList.add(`highlighting`)}}disableTextSelection(){this.div.tabIndex=0;if(this.#d?.div&&this.#f){this.#f.abort();this.#f=null;this.#d.div.classList.remove(`highlighting`)}}#v(e){this.#h.unselectAll();let{target:t}=e;if(t===this.#d.div||(t.getAttribute(`role`)===`img`||t.classList.contains(`endOfContent`)||t.classList.contains(`textLayerImages`)||t.classList.contains(`textLayerImagePlaceholder`))&&this.#d.div.contains(t)){let{isMac:t}=N.platform;if(e.button!==0||e.ctrlKey&&t)return;this.#h.showAllEditors(`highlight`,!0,!0);this.#d.div.classList.add(`free`);this.toggleDrawing();Q.startHighlighting(this,this.#h.direction===`ltr`,{target:this.#d.div,x:e.x,y:e.y});this.#d.div.addEventListener(`pointerup`,()=>{this.#d.div.classList.remove(`free`);this.toggleDrawing(!0)},{once:!0,signal:this.#h._signal});e.preventDefault()}}enableClick(){if(this.#r)return;this.#r=new AbortController;let e=this.#h.combinedSignal(this.#r);this.div.addEventListener(`pointerdown`,this.pointerdown.bind(this),{signal:e});let t=this.pointerup.bind(this);this.div.addEventListener(`pointerup`,t,{signal:e});this.div.addEventListener(`pointercancel`,t,{signal:e})}disableClick(){this.#r?.abort();this.#r=null}attach(e){this.#a.set(e.id,e);let{annotationElementId:t}=e;t&&this.#h.isDeletedAnnotationElement(t)&&this.#h.removeDeletedAnnotationElement(e)}detach(e){this.#a.delete(e.id);this.#e?.removePointerInTextLayer(e.contentDiv);!this.#s&&e.annotationElementId&&this.#h.addDeletedAnnotationElement(e)}remove(e){this.detach(e);this.#h.removeEditor(e);e.div.remove();e.isAttachedToDOM=!1}changeParent(e){if(e.parent!==this){if(e.parent&&e.annotationElementId){this.#h.addDeletedAnnotationElement(e);H.deleteAnnotationElement(e);e.annotationElementId=null}this.attach(e);e.parent?.detach(e);e.setParent(this);if(e.div&&e.isAttachedToDOM){e.div.remove();this.div.append(e.div)}}}add(e){if(e.parent!==this||!e.isAttachedToDOM){this.changeParent(e);this.#h.addEditor(e);this.attach(e);if(!e.isAttachedToDOM){let t=e.render();this.div.append(t);e.isAttachedToDOM=!0}e.fixAndSetPosition();e.onceAdded(!this.#c);this.#h.addToAnnotationStorage(e);e._reportTelemetry(e.telemetryInitialData)}}moveEditorInDOM(e){if(!e.isAttachedToDOM)return;let{activeElement:t}=document;if(e.div.contains(t)&&!this.#i){e._focusEventsAllowed=!1;this.#i=setTimeout(()=>{this.#i=null;if(e.div.contains(document.activeElement))e._focusEventsAllowed=!0;else{e.div.addEventListener(`focusin`,()=>{e._focusEventsAllowed=!0},{once:!0,signal:this.#h._signal});t.focus()}},0)}e._structTreeParentId=this.#e?.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){if(e.needsToBeRebuilt()){e.parent||=this;e.rebuild();e.show()}else this.add(e)}addUndoableEditor(e){this.addCommands({cmd:()=>e._uiManager.rebuild(e),undo:()=>{e.remove()},mustExec:!1})}getEditorByUID(e){for(let t of this.#a.values())if(t.uid===e)return t;return null}get#y(){return Nr.#g.get(this.#h.getMode())}combinedSignal(e){return this.#h.combinedSignal(e)}#b(e){let t=this.#y;return t?new t.prototype.constructor(e):null}canCreateNewEmptyEditor(){return this.#y?.canCreateNewEmptyEditor()}async pasteEditor(e,t){this.updateToolbar(e);await this.#h.updateMode(e.mode);let{offsetX:n,offsetY:r}=this.#x(),i=this.#h.getId(),a=this.#b({parent:this,id:i,x:n,y:r,uiManager:this.#h,isCentered:!0,...t});a&&this.add(a)}async deserialize(e){return await Nr.#g.get(e.annotationType??e.annotationEditorType)?.deserialize(e,this,this.#h)||null}createAndAddNewEditor(e,t,n={}){let r=this.#h.getId(),i=this.#b({parent:this,id:r,x:e.offsetX,y:e.offsetY,uiManager:this.#h,isCentered:t,...n});i&&this.add(i);return i}get boundingClientRect(){return this.div.getBoundingClientRect()}#x(){let{x:e,y:t,width:n,height:r}=this.boundingClientRect,i=Math.max(0,e),a=Math.max(0,t),o=(i+Math.min(window.innerWidth,e+n))/2-e,s=(a+Math.min(window.innerHeight,t+r))/2-t,[c,l]=this.viewport.rotation%180==0?[o,s]:[s,o];return{offsetX:c,offsetY:l}}addNewEditor(e={}){this.createAndAddNewEditor(this.#x(),!0,e)}setSelected(e){this.#h.setSelected(e)}toggleSelected(e){this.#h.toggleSelected(e)}unselect(e){this.#h.unselect(e)}pointerup(e){let{isMac:t}=N.platform;if(e.button!==0||e.ctrlKey&&t)return;if(e.target!==this.div)return;if(!this.#o)return;this.#o=!1;if(this.#y?.isDrawer&&this.#y.supportMultipleDrawings)return;if(!this.#t){this.#t=!0;return}let n=this.#h.getMode();n!==_.STAMP&&n!==_.POPUP&&n!==_.SIGNATURE?this.createAndAddNewEditor(e,!1):this.#h.unselectAll()}pointerdown(e){this.#h.getMode()===_.HIGHLIGHT&&this.enableTextSelection();if(this.#o){this.#o=!1;return}let{isMac:t}=N.platform;if(e.button!==0||e.ctrlKey&&t)return;if(e.target!==this.div)return;this.#o=!0;if(this.#y?.isDrawer){this.startDrawingSession(e);return}let n=this.#h.getActive();this.#t=!n||n.isEmpty()}startDrawingSession(e){this.div.focus({preventScroll:!0});if(this.#l){this.#y.startDrawing(this,this.#h,!1,e);return}this.#h.setCurrentDrawingSession(this);this.#l=new AbortController;let t=this.#h.combinedSignal(this.#l);this.div.addEventListener(`blur`,({relatedTarget:e})=>{if(e&&!this.div.contains(e)){this.#u=null;this.commitOrRemove()}},{signal:t});this.#y.startDrawing(this,this.#h,!1,e)}pause(e){if(e){let{activeElement:e}=document;this.div.contains(e)&&(this.#u=e);return}this.#u&&setTimeout(()=>{this.#u?.focus();this.#u=null},0)}endDrawingSession(e=!1){if(!this.#l)return null;this.#h.setCurrentDrawingSession(null);this.#l.abort();this.#l=null;this.#u=null;return this.#y.endDrawing(e)}findNewParent(e,t,n){let r=this.#h.findParent(t,n);if(r===null||r===this)return!1;r.changeParent(e);return!0}commitOrRemove(){if(this.#l){this.endDrawingSession();return!0}return!1}onScaleChanging(){this.#l&&this.#y.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove();if(this.#h.getActive()?.parent===this){this.#h.commitOrRemove();this.#h.setActiveEditor(null)}if(this.#i){clearTimeout(this.#i);this.#i=null}for(let e of this.#a.values()){this.#e?.removePointerInTextLayer(e.contentDiv);e.setParent(null);e.isAttachedToDOM=!1;e.div.remove()}this.div=null;this.#a.clear();this.#h.removeLayer(this)}#S(){for(let e of this.#a.values())e.isEmpty()&&e.remove()}async render({viewport:e}){this.viewport=e;we(this.div,e);for(let e of this.#h.getEditors(this.pageIndex)){this.add(e);e.rebuild()}await this.#h.findClonesForPage(this);this.div.hidden=this.isEmpty;this.updateMode()}update({viewport:e}){this.#h.commitOrRemove();this.#S();let t=this.viewport.rotation,n=e.rotation;this.viewport=e;we(this.div,{rotation:n});if(t!==n)for(let e of this.#a.values())e.rotate(n)}get pageDimensions(){let{pageWidth:e,pageHeight:t}=this.viewport.rawDims;return[e,t]}get scale(){return this.#h.viewParameters.realScale}}globalThis._pdfjsTestingUtils={HighlightOutliner:vr};const Pr={fonts:globalThis.fonts,createElement(e){if(e.toLowerCase()===`canvas`)return new OffscreenCanvas(1,1);return null}};class Fr{constructor(){this._pdfDocument=null;this._page=null;this._geospatialMetadata=null;this._baseViewport=null;this._inverseBaseViewport=null;this._pdfWorker=null;this._pdfWorkerBlobUrl=null}async loadPDF(n,s={}){let[{data:c},l]=await Promise.all([t(n.url,{responseType:`array-buffer`,signal:s?.signal}),this._getPDFWorker(s)]),u=Kn({data:c,wasmUrl:e(`esri/libs/pdfjs/wasm/`),ownerDocument:Pr,enableHWA:!0,useWorkerFetch:!0,worker:l,useWasm:!0,verbosity:0});this._pdfDocument=await u.promise;r(s);this._page=await this._pdfDocument.getPage(n.page);r(s);this._geospatialMetadata=await this._page.getGeospatialPDFMetadata();r(s);this._baseViewport=this._page.getViewport({scale:1});this._inverseBaseViewport=i();o(this._inverseBaseViewport,a(...this._baseViewport.transform));return{geospatialMetadata:this._geospatialMetadata}}destroy(){this._page?.cleanup?.();this._page=null;this._pdfDocument?.cleanup();this._pdfDocument=null;this._geospatialMetadata=null;this._baseViewport=null;this._inverseBaseViewport=null;this._pdfWorker?.destroy();this._pdfWorker=null;if(this._pdfWorkerBlobUrl){URL.revokeObjectURL(this._pdfWorkerBlobUrl);this._pdfWorkerBlobUrl=null}}async renderPDF(e,t={}){if(!this._page||!this._baseViewport||!this._inverseBaseViewport)throw new n(`geospatial-pdf-layer-worker:not-loaded`,`PDF not loaded`);r(t);let{width:i,height:a,sourceExtentAsJSON:o,currentRing:l,ctm:u}=e,d=s.fromJSON(o),f=await c(d,i,a,u,this._page,this._baseViewport,this._inverseBaseViewport,l,t);r(t);return Ir(f,i,a)}async _getPDFWorker(n={}){if(this._pdfWorker)return this._pdfWorker;let r=e(`esri/libs/pdfjs/pdf.worker.mjs`),i=(await t(r,{responseType:`blob`,authMode:`anonymous`,signal:n.signal})).data,a=i.type===`application/javascript`||i.type===`text/javascript`?i:new Blob([i],{type:`application/javascript`}),o=URL.createObjectURL(a);try{let e=new Worker(o,{type:`module`,name:`geospatial-pdf-pdfjs-worker`}),t=new J({port:e,verbosity:0});await t.promise;this._pdfWorker=t;this._pdfWorkerBlobUrl=o;return t}catch(e){URL.revokeObjectURL(o);throw e}}}function Ir(e,t,r){let i=e.getContext(`2d`);if(!i)throw new n(`geospatial-pdf-raster:canvas`,`Failed to create canvas context.`);let a=i.getImageData(0,0,t,r).data,o=t*r,s=new Uint8Array(o),c=new Uint8Array(o),l=new Uint8Array(o),u=new Uint8Array(o);for(let e=0,t=0;e<o;e++,t+=4){s[e]=a[t];c[e]=a[t+1];l[e]=a[t+2];u[e]=a[t+3]}return{width:t,height:r,red:s,green:c,blue:l,mask:u}}export{Fr as default};
|
|
57
|
+
`)){let n=document.createElement(`div`);n.append(e?document.createTextNode(e):document.createElement(`br`));t.append(n)}e.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:this.#e}});return t}resetAnnotationElement(e){super.resetAnnotationElement(e);e.resetEdited()}}class Z{static PRECISION=1e-4;toSVGPath(){D("Abstract method `toSVGPath` must be implemented.")}get box(){D("Abstract getter `box` must be implemented.")}serialize(e,t){D("Abstract method `serialize` must be implemented.")}static _rescale(e,t,n,r,i,a){a||=new Float32Array(e.length);for(let o=0,s=e.length;o<s;o+=2){a[o]=t+e[o]*r;a[o+1]=n+e[o+1]*i}return a}static _rescaleAndSwap(e,t,n,r,i,a){a||=new Float32Array(e.length);for(let o=0,s=e.length;o<s;o+=2){a[o]=t+e[o+1]*r;a[o+1]=n+e[o]*i}return a}static _translate(e,t,n,r){r||=new Float32Array(e.length);for(let i=0,a=e.length;i<a;i+=2){r[i]=t+e[i];r[i+1]=n+e[i+1]}return r}static svgRound(e){return Math.round(1e4*e)}static _normalizePoint(e,t,n,r,i){switch(i){case 90:return[1-t/n,e/r];case 180:return[1-e/n,1-t/r];case 270:return[t/n,1-e/r];default:return[e/n,t/r]}}static _normalizePagePoint(e,t,n){switch(n){case 90:return[1-t,e];case 180:return[1-e,1-t];case 270:return[t,1-e];default:return[e,t]}}static createBezierPoints(e,t,n,r,i,a){return[(e+5*n)/6,(t+5*r)/6,(5*n+i)/6,(5*r+a)/6,(n+i)/2,(r+a)/2]}}class gr{#e;#t=[];#n;#r;#i=[];#a=new Float32Array(18);#o;#s;#c;#l;#u;#d;#f=[];static#p=8;static#m=2;static#h=gr.#p+gr.#m;constructor({x:e,y:t},n,r,i,a,o=0){this.#e=n;this.#d=i*r;this.#r=a;this.#a.set([NaN,NaN,NaN,NaN,e,t],6);this.#n=o;this.#l=gr.#p*r;this.#c=gr.#h*r;this.#u=r;this.#f.push(e,t)}isEmpty(){return isNaN(this.#a[8])}#g(){let e=this.#a.subarray(4,6),t=this.#a.subarray(16,18),[n,r,i,a]=this.#e;return[(this.#o+(e[0]-t[0])/2-n)/i,(this.#s+(e[1]-t[1])/2-r)/a,(this.#o+(t[0]-e[0])/2-n)/i,(this.#s+(t[1]-e[1])/2-r)/a]}add({x:e,y:t}){this.#o=e;this.#s=t;let[n,r,i,a]=this.#e,[o,s,c,l]=this.#a.subarray(8,12),u=e-c,d=t-l,f=Math.hypot(u,d);if(f<this.#c)return!1;let p=f-this.#l,m=p/f,h=m*u,g=m*d,_=o,v=s;o=c;s=l;c+=h;l+=g;this.#f?.push(e,t);let y=h/p,b=-g/p*this.#d,x=y*this.#d;this.#a.set(this.#a.subarray(2,8),0);this.#a.set([c+b,l+x],4);this.#a.set(this.#a.subarray(14,18),12);this.#a.set([c-b,l-x],16);if(isNaN(this.#a[6])){if(this.#i.length===0){this.#a.set([o+b,s+x],2);this.#i.push(NaN,NaN,NaN,NaN,(o+b-n)/i,(s+x-r)/a);this.#a.set([o-b,s-x],14);this.#t.push(NaN,NaN,NaN,NaN,(o-b-n)/i,(s-x-r)/a)}this.#a.set([_,v,o,s,c,l],6);return!this.isEmpty()}this.#a.set([_,v,o,s,c,l],6);if(Math.abs(Math.atan2(v-s,_-o)-Math.atan2(g,h))<Math.PI/2){[o,s,c,l]=this.#a.subarray(2,6);this.#i.push(NaN,NaN,NaN,NaN,((o+c)/2-n)/i,((s+l)/2-r)/a);[o,s,_,v]=this.#a.subarray(14,18);this.#t.push(NaN,NaN,NaN,NaN,((_+o)/2-n)/i,((v+s)/2-r)/a);return!0}[_,v,o,s,c,l]=this.#a.subarray(0,6);this.#i.push(((_+5*o)/6-n)/i,((v+5*s)/6-r)/a,((5*o+c)/6-n)/i,((5*s+l)/6-r)/a,((o+c)/2-n)/i,((s+l)/2-r)/a);[c,l,o,s,_,v]=this.#a.subarray(12,18);this.#t.push(((_+5*o)/6-n)/i,((v+5*s)/6-r)/a,((5*o+c)/6-n)/i,((5*s+l)/6-r)/a,((o+c)/2-n)/i,((s+l)/2-r)/a);return!0}toSVGPath(){if(this.isEmpty())return``;let e=this.#i,t=this.#t;if(isNaN(this.#a[6])&&!this.isEmpty())return this.#_();let n=[];n.push(`M${e[4]} ${e[5]}`);for(let t=6;t<e.length;t+=6)isNaN(e[t])?n.push(`L${e[t+4]} ${e[t+5]}`):n.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);this.#y(n);for(let e=t.length-6;e>=6;e-=6)isNaN(t[e])?n.push(`L${t[e+4]} ${t[e+5]}`):n.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);this.#v(n);return n.join(` `)}#_(){let[e,t,n,r]=this.#e,[i,a,o,s]=this.#g();return`M${(this.#a[2]-e)/n} ${(this.#a[3]-t)/r} L${(this.#a[4]-e)/n} ${(this.#a[5]-t)/r} L${i} ${a} L${o} ${s} L${(this.#a[16]-e)/n} ${(this.#a[17]-t)/r} L${(this.#a[14]-e)/n} ${(this.#a[15]-t)/r} Z`}#v(e){let t=this.#t;e.push(`L${t[4]} ${t[5]} Z`)}#y(e){let[t,n,r,i]=this.#e,a=this.#a.subarray(4,6),o=this.#a.subarray(16,18),[s,c,l,u]=this.#g();e.push(`L${(a[0]-t)/r} ${(a[1]-n)/i} L${s} ${c} L${l} ${u} L${(o[0]-t)/r} ${(o[1]-n)/i}`)}newFreeDrawOutline(e,t,n,r,i,a){return new _r(e,t,n,r,i,a)}getOutlines(){let e=this.#i,t=this.#t,n=this.#a,[r,i,a,o]=this.#e,s=new Float32Array((this.#f?.length??0)+2);for(let e=0,t=s.length-2;e<t;e+=2){s[e]=(this.#f[e]-r)/a;s[e+1]=(this.#f[e+1]-i)/o}s[s.length-2]=(this.#o-r)/a;s[s.length-1]=(this.#s-i)/o;if(isNaN(n[6])&&!this.isEmpty())return this.#b(s);let c=new Float32Array(this.#i.length+24+this.#t.length),l=e.length;for(let t=0;t<l;t+=2)if(isNaN(e[t]))c[t]=c[t+1]=NaN;else{c[t]=e[t];c[t+1]=e[t+1]}l=this.#S(c,l);for(let e=t.length-6;e>=6;e-=6)for(let n=0;n<6;n+=2)if(isNaN(t[e+n])){c[l]=c[l+1]=NaN;l+=2}else{c[l]=t[e+n];c[l+1]=t[e+n+1];l+=2}this.#x(c,l);return this.newFreeDrawOutline(c,s,this.#e,this.#u,this.#n,this.#r)}#b(e){let t=this.#a,[n,r,i,a]=this.#e,[o,s,c,l]=this.#g(),u=new Float32Array(36);u.set([NaN,NaN,NaN,NaN,(t[2]-n)/i,(t[3]-r)/a,NaN,NaN,NaN,NaN,(t[4]-n)/i,(t[5]-r)/a,NaN,NaN,NaN,NaN,o,s,NaN,NaN,NaN,NaN,c,l,NaN,NaN,NaN,NaN,(t[16]-n)/i,(t[17]-r)/a,NaN,NaN,NaN,NaN,(t[14]-n)/i,(t[15]-r)/a],0);return this.newFreeDrawOutline(u,e,this.#e,this.#u,this.#n,this.#r)}#x(e,t){let n=this.#t;e.set([NaN,NaN,NaN,NaN,n[4],n[5]],t);return t+6}#S(e,t){let n=this.#a.subarray(4,6),r=this.#a.subarray(16,18),[i,a,o,s]=this.#e,[c,l,u,d]=this.#g();e.set([NaN,NaN,NaN,NaN,(n[0]-i)/o,(n[1]-a)/s,NaN,NaN,NaN,NaN,c,l,NaN,NaN,NaN,NaN,u,d,NaN,NaN,NaN,NaN,(r[0]-i)/o,(r[1]-a)/s],t);return t+24}}class _r extends Z{#e;#t=new Float32Array(4);#n;#r;#i;#a;#o;constructor(e,t,n,r,i,a){super();this.#o=e;this.#i=t;this.#e=n;this.#a=r;this.#n=i;this.#r=a;this.firstPoint=[NaN,NaN];this.lastPoint=[NaN,NaN];this.#s(a);let[o,s,c,l]=this.#t;for(let t=0,n=e.length;t<n;t+=2){e[t]=(e[t]-o)/c;e[t+1]=(e[t+1]-s)/l}for(let e=0,n=t.length;e<n;e+=2){t[e]=(t[e]-o)/c;t[e+1]=(t[e+1]-s)/l}}toSVGPath(){let e=[`M${this.#o[4]} ${this.#o[5]}`];for(let t=6,n=this.#o.length;t<n;t+=6)isNaN(this.#o[t])?e.push(`L${this.#o[t+4]} ${this.#o[t+5]}`):e.push(`C${this.#o[t]} ${this.#o[t+1]} ${this.#o[t+2]} ${this.#o[t+3]} ${this.#o[t+4]} ${this.#o[t+5]}`);e.push(`Z`);return e.join(` `)}serialize([e,t,n,r],i){let a=n-e,o=r-t,s,c;switch(i){case 0:s=Z._rescale(this.#o,e,r,a,-o);c=Z._rescale(this.#i,e,r,a,-o);break;case 90:s=Z._rescaleAndSwap(this.#o,e,t,a,o);c=Z._rescaleAndSwap(this.#i,e,t,a,o);break;case 180:s=Z._rescale(this.#o,n,t,-a,o);c=Z._rescale(this.#i,n,t,-a,o);break;case 270:s=Z._rescaleAndSwap(this.#o,n,r,-a,-o);c=Z._rescaleAndSwap(this.#i,n,r,-a,-o)}return{outline:Array.from(s),points:[Array.from(c)]}}#s(e){let t=this.#o,n=t[4],r=t[5],i=[n,r,n,r],a=n,o=r,s=n,c=r,l=e?Math.max:Math.min,d=new Float32Array(4);for(let e=6,f=t.length;e<f;e+=6){let f=t[e+4],p=t[e+5];if(isNaN(t[e])){P.pointBoundingBox(f,p,i);if(o>p){a=f;o=p}else o===p&&(a=l(a,f));if(c<p){s=f;c=p}else c===p&&(s=l(s,f))}else{d.set(u,0);P.bezierBoundingBox(n,r,...t.slice(e,e+6),d);P.rectBoundingBox(...d,i);if(o>d[1]){a=d[0];o=d[1]}else o===d[1]&&(a=l(a,d[0]));if(c<d[3]){s=d[2];c=d[3]}else c===d[3]&&(s=l(s,d[2]))}n=f;r=p}let f=this.#t;f[0]=i[0]-this.#n;f[1]=i[1]-this.#n;f[2]=i[2]-i[0]+2*this.#n;f[3]=i[3]-i[1]+2*this.#n;this.firstPoint=[a,o];this.lastPoint=[s,c]}get box(){return this.#t}newOutliner(e,t,n,r,i,a=0){return new gr(e,t,n,r,i,a)}getNewOutline(e,t){let[n,r,i,a]=this.#t,[o,s,c,l]=this.#e,u=i*c,d=a*l,f=n*c+o,p=r*l+s,m=this.newOutliner({x:this.#i[0]*u+f,y:this.#i[1]*d+p},this.#e,this.#a,e,this.#r,t??this.#n);for(let e=2;e<this.#i.length;e+=2)m.add({x:this.#i[e]*u+f,y:this.#i[e+1]*d+p});return m.getOutlines()}}class vr{#e;#t;#n;#r=[];#i=[];constructor(e,t=0,n=0,r=!0){let i=u.slice(),a=1e-4;for(let{x:n,y:r,width:o,height:s}of e){let e=Math.floor((n-t)/a)*a,c=Math.ceil((n+o+t)/a)*a,l=Math.floor((r-t)/a)*a,u=Math.ceil((r+s+t)/a)*a,d=[e,l,u,!0],f=[c,l,u,!1];this.#r.push(d,f);P.rectBoundingBox(e,l,c,u,i)}let o=i[2]-i[0]+2*n,s=i[3]-i[1]+2*n,c=i[0]-n,l=i[1]-n,d=r?-1/0:1/0,f=1/0,p=this.#r.at(r?-1:-2),m=[p[0],p[2]];for(let e of this.#r){let[t,n,i,a]=e;if(!a&&r){if(n<f){f=n;d=t}else n===f&&(d=Math.max(d,t))}else if(a&&!r){if(n<f){f=n;d=t}else n===f&&(d=Math.min(d,t))}e[0]=(t-c)/o;e[1]=(n-l)/s;e[2]=(i-l)/s}this.#e=new Float32Array([c,l,o,s]);this.#t=[d,f];this.#n=m}getOutlines(){this.#r.sort((e,t)=>e[0]-t[0]||e[1]-t[1]||e[2]-t[2]);let e=[];for(let t of this.#r)if(t[3]){e.push(...this.#l(t));this.#s(t)}else{this.#c(t);e.push(...this.#l(t))}return this.#a(e)}#a(e){let t=[],n=new Set;for(let n of e){let[e,r,i]=n;t.push([e,r,n],[e,i,n])}t.sort((e,t)=>e[1]-t[1]||e[0]-t[0]);for(let e=0,r=t.length;e<r;e+=2){let r=t[e][2],i=t[e+1][2];r.push(i);i.push(r);n.add(r);n.add(i)}let r=[],i;for(;n.size>0;){let e=n.values().next().value,[t,a,o,s,c]=e;n.delete(e);let l=t,u=a;i=[t,o];r.push(i);for(;;){let e;if(n.has(s))e=s;else{if(!n.has(c))break;e=c}n.delete(e);[t,a,o,s,c]=e;if(l!==t){i.push(l,u,t,u===a?a:o);l=t}u=u===a?o:a}i.push(l,u)}return new yr(r,this.#e,this.#t,this.#n)}#o(e){let t=this.#i,n=0,r=t.length-1;for(;n<=r;){let i=n+r>>1,a=t[i][0];if(a===e)return i;a<e?n=i+1:r=i-1}return r+1}#s([,e,t]){let n=this.#o(e);this.#i.splice(n,0,[e,t])}#c([,e,t]){let n=this.#o(e);for(let r=n;r<this.#i.length;r++){let[n,i]=this.#i[r];if(n!==e)break;if(n===e&&i===t){this.#i.splice(r,1);return}}for(let r=n-1;r>=0;r--){let[n,i]=this.#i[r];if(n!==e)break;if(n===e&&i===t){this.#i.splice(r,1);return}}}#l(e){let[t,n,r]=e,i=[[t,n,r]],a=this.#o(r);for(let e=0;e<a;e++){let[n,r]=this.#i[e];for(let e=0,a=i.length;e<a;e++){let[,o,s]=i[e];if(!(r<=o||s<=n)){if(o>=n){if(s>r)i[e][1]=r;else{if(a===1)return[];i.splice(e,1);e--;a--}}else{i[e][2]=n;s>r&&i.push([t,r,s])}}}}return i}}class yr extends Z{#e;#t;constructor(e,t,n,r){super();this.#t=e;this.#e=t;this.firstPoint=n;this.lastPoint=r}toSVGPath(){let e=[];for(let t of this.#t){let[n,r]=t;e.push(`M${n} ${r}`);for(let i=2;i<t.length;i+=2){let a=t[i],o=t[i+1];if(a===n){e.push(`V${o}`);r=o}else if(o===r){e.push(`H${a}`);n=a}}e.push(`Z`)}return e.join(` `)}serialize([e,t,n,r],i){let a=[],o=n-e,s=r-t;for(let t of this.#t){let n=Array(t.length);for(let i=0;i<t.length;i+=2){n[i]=e+t[i]*o;n[i+1]=r-t[i+1]*s}a.push(n)}return a}get box(){return this.#e}get classNamesForOutlining(){return[`highlightOutline`]}}class br extends gr{newFreeDrawOutline(e,t,n,r,i,a){return new xr(e,t,n,r,i,a)}}class xr extends _r{newOutliner(e,t,n,r,i,a=0){return new br(e,t,n,r,i,a)}}class Q extends H{#e=null;#t=0;#n;#r=null;#i=null;#a=null;#o=null;#s=0;#c=null;#l=null;#u=null;#d=!1;#f=null;#p=null;#m=null;#h=``;#g;#_=``;static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type=`highlight`;static _editorType=_.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId=``;static get _keyboardManager(){let e=Q.prototype;return j(this,`_keyboardManager`,new Ie([[[`ArrowLeft`,`mac+ArrowLeft`],e._moveCaret,{args:[0]}],[[`ArrowRight`,`mac+ArrowRight`],e._moveCaret,{args:[1]}],[[`ArrowUp`,`mac+ArrowUp`],e._moveCaret,{args:[2]}],[[`ArrowDown`,`mac+ArrowDown`],e._moveCaret,{args:[3]}]]))}constructor(e){super({...e,name:`highlightEditor`});this.color=e.color||Q._defaultColor;this.#g=e.thickness||Q._defaultThickness;this.opacity=e.opacity||Q._defaultOpacity;this.#n=e.boxes||null;this.#_=e.methodOfCreation||``;this.#h=e.text||``;this._isDraggable=!1;this.defaultL10nId=`pdfjs-editor-highlight-editor`;if(e.highlightId>-1){this.#d=!0;this.#y(e);this.#w()}else if(this.#n){this.#e=e.anchorNode;this.#t=e.anchorOffset;this.#o=e.focusNode;this.#s=e.focusOffset;this.#v();this.#w();this.rotate(this.rotation)}this.annotationElementId||this._uiManager.a11yAlert(H._l10nAlert.highlight)}get telemetryInitialData(){return{action:`added`,type:this.#d?`free_highlight`:`highlight`,color:this._uiManager.getNonHCMColorName(this.color),thickness:this.#g,methodOfCreation:this.#_}}get telemetryFinalData(){return{type:`highlight`,color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get(`color`).size}}#v(){let e=new vr(this.#n,.001);this.#l=e.getOutlines();[this.x,this.y,this.width,this.height]=this.#l.box;let t=new vr(this.#n,.0025,.001,this._uiManager.direction===`ltr`);this.#a=t.getOutlines();let{firstPoint:n}=this.#l;this.#f=[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height];let{lastPoint:r}=this.#a;this.#p=[(r[0]-this.x)/this.width,(r[1]-this.y)/this.height]}#y({highlightOutlines:e,highlightId:t,clipPathId:n}){this.#l=e;this.#a=e.getNewOutline(this.#g/2+1.5,.0025);if(t>=0){this.#u=t;this.#r=n;this.parent.drawLayer.finalizeDraw(t,{bbox:e.box,path:{d:e.toSVGPath()}});this.#m=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#a.box,path:{d:this.#a.toSVGPath()}},!0)}else if(this.parent){let t=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#u,{bbox:Q.#T(this.#l.box,(t-this.rotation+360)%360),path:{d:e.toSVGPath()}});this.parent.drawLayer.updateProperties(this.#m,{bbox:Q.#T(this.#a.box,t),path:{d:this.#a.toSVGPath()}})}let[r,i,a,o]=e.box;switch(this.rotation){case 0:this.x=r;this.y=i;this.width=a;this.height=o;break;case 90:{let[e,t]=this.parentDimensions;this.x=i;this.y=1-r;this.width=a*t/e;this.height=o*e/t;break}case 180:this.x=1-r;this.y=1-i;this.width=a;this.height=o;break;case 270:{let[e,t]=this.parentDimensions;this.x=1-i;this.y=r;this.width=a*t/e;this.height=o*e/t;break}}let{firstPoint:s}=e;this.#f=[(s[0]-r)/a,(s[1]-i)/o];let{lastPoint:c}=this.#a;this.#p=[(c[0]-r)/a,(c[1]-i)/o]}static initialize(e,t){H.initialize(e,t);Q._defaultColor||=t.highlightColors?.values().next().value||`#fff066`}static updateDefaultParams(e,t){switch(e){case v.HIGHLIGHT_COLOR:Q._defaultColor=t;break;case v.HIGHLIGHT_THICKNESS:Q._defaultThickness=t}}translateInPage(e,t){}get toolbarPosition(){return this.#p}get commentButtonPosition(){return this.#f}updateParams(e,t){switch(e){case v.HIGHLIGHT_COLOR:this.#b(t);break;case v.HIGHLIGHT_THICKNESS:this.#x(t)}}static get defaultPropertiesToUpdate(){return[[v.HIGHLIGHT_COLOR,Q._defaultColor],[v.HIGHLIGHT_THICKNESS,Q._defaultThickness]]}get propertiesToUpdate(){return[[v.HIGHLIGHT_COLOR,this.color||Q._defaultColor],[v.HIGHLIGHT_THICKNESS,this.#g||Q._defaultThickness],[v.HIGHLIGHT_FREE,this.#d]]}onUpdatedColor(){this.parent?.drawLayer.updateProperties(this.#u,{root:{fill:this.color,"fill-opacity":this.opacity}});this.#i?.updateColor(this.color);super.onUpdatedColor()}#b(e){let t=(e,t)=>{this.color=e;this.opacity=t;this.onUpdatedColor()},n=this.color,r=this.opacity;this.addCommands({cmd:t.bind(this,e,Q._defaultOpacity),undo:t.bind(this,n,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:v.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0});this._reportTelemetry({action:`color_changed`,color:this._uiManager.getNonHCMColorName(e)},!0)}#x(e){let t=this.#g,n=e=>{this.#g=e;this.#S(e)};this.addCommands({cmd:n.bind(this,e),undo:n.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:v.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0});this._reportTelemetry({action:`thickness_changed`,thickness:e},!0)}get toolbarButtons(){if(this._uiManager.highlightColors)return[[`colorPicker`,this.#i=new Y({editor:this})]];return super.toolbarButtons}disableEditing(){super.disableEditing();this.div.classList.toggle(`disabled`,!0)}enableEditing(){super.enableEditing();this.div.classList.toggle(`disabled`,!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#O())}getBaseTranslation(){return[0,0]}getRect(e,t){return super.getRect(e,t,this.#O())}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this);e&&this.div.focus()}remove(){this.#C();this._reportTelemetry({action:`deleted`});super.remove()}rebuild(){if(this.parent){super.rebuild();if(this.div!==null){this.#w();this.isAttachedToDOM||this.parent.add(this)}}}setParent(e){let t=!1;if(this.parent&&!e)this.#C();else if(e){this.#w(e);t=!this.parent&&this.div?.classList.contains(`selectedEditor`)}super.setParent(e);this.show(this._isVisible);t&&this.select()}#S(e){if(this.#d){this.#y({highlightOutlines:this.#l.getNewOutline(e/2)});this.fixAndSetPosition();this.setDims()}}#C(){if(this.#u!==null&&this.parent){this.parent.drawLayer.remove(this.#u);this.#u=null;this.parent.drawLayer.remove(this.#m);this.#m=null}}#w(e=this.parent){if(this.#u===null){({id:this.#u,clipPathId:this.#r}=e.drawLayer.draw({bbox:this.#l.box,root:{viewBox:`0 0 1 1`,fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:this.#d},path:{d:this.#l.toSVGPath()}},!1,!0));this.#m=e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#d},bbox:this.#a.box,path:{d:this.#a.toSVGPath()}},this.#d);this.#c&&(this.#c.style.clipPath=this.#r)}}static#T([e,t,n,r],i){switch(i){case 90:return[1-t-r,e,r,n];case 180:return[1-e-n,1-t-r,n,r];case 270:return[t,1-e-n,r,n]}return[e,t,n,r]}rotate(e){let{drawLayer:t}=this.parent,n;if(this.#d){e=(e-this.rotation+360)%360;n=Q.#T(this.#l.box,e)}else n=Q.#T([this.x,this.y,this.width,this.height],e);t.updateProperties(this.#u,{bbox:n,root:{"data-main-rotation":e}});t.updateProperties(this.#m,{bbox:Q.#T(this.#a.box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;let e=super.render();if(this.#h){e.setAttribute(`aria-label`,this.#h);e.setAttribute(`role`,`mark`)}this.#d?e.classList.add(`free`):this.div.addEventListener(`keydown`,this.#E.bind(this),{signal:this._uiManager._signal});let t=this.#c=document.createElement(`div`);e.append(t);t.setAttribute(`aria-hidden`,`true`);t.className=`internal`;t.style.clipPath=this.#r;this.setDims();Me(this,this.#c,[`pointerover`,`pointerleave`]);this.enableEditing();return e}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#m,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#m,{rootClass:{hovered:!1}})}#E(e){Q._keyboardManager.exec(this,e)}_moveCaret(e){this.parent.unselect(this);switch(e){case 0:case 2:this.#D(!0);break;case 1:case 3:this.#D(!1)}}#D(e){if(!this.#e)return;let t=window.getSelection();e?t.setPosition(this.#e,this.#t):t.setPosition(this.#o,this.#s)}select(){super.select();this.#m&&this.parent?.drawLayer.updateProperties(this.#m,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect();if(this.#m){this.parent?.drawLayer.updateProperties(this.#m,{rootClass:{selected:!1}});this.#d||this.#D(!1)}}get _mustFixPosition(){return!this.#d}show(e=this._isVisible){super.show(e);if(this.parent){this.parent.drawLayer.updateProperties(this.#u,{rootClass:{hidden:!e}});this.parent.drawLayer.updateProperties(this.#m,{rootClass:{hidden:!e}})}}#O(){return this.#d?this.rotation:0}#k(){if(this.#d)return null;let[e,t]=this.pageDimensions,[n,r]=this.pageTranslation,i=this.#n,a=new Float32Array(8*i.length),o=0;for(let{x:s,y:c,width:l,height:u}of i){let i=s*e+n,d=(1-c)*t+r;a[o]=a[o+4]=i;a[o+1]=a[o+3]=d;a[o+2]=a[o+6]=i+l*e;a[o+5]=a[o+7]=d-u*t;o+=8}return a}#A(e){return this.#l.serialize(e,this.#O())}static startHighlighting(e,t,{target:n,x:r,y:i}){let{x:a,y:o,width:s,height:c}=n.getBoundingClientRect(),l=new AbortController,u=e.combinedSignal(l),d=t=>{l.abort();this.#M(e,t)};window.addEventListener(`blur`,d,{signal:u});window.addEventListener(`pointerup`,d,{signal:u});window.addEventListener(`pointerdown`,R,{capture:!0,passive:!1,signal:u});window.addEventListener(`contextmenu`,L,{signal:u});n.addEventListener(`pointermove`,this.#j.bind(this,e),{signal:u});this._freeHighlight=new br({x:r,y:i},[a,o,s,c],e.scale,this._defaultThickness/2,t,.001);({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:`0 0 1 1`,fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0))}static#j(e,t){this._freeHighlight.add(t)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#M(e,t){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(t,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:`main_toolbar`});this._freeHighlightId=-1;this._freeHighlight=null;this._freeHighlightClipId=``}static async deserialize(e,t,n){let r=null;if(e instanceof pr){let{data:{quadPoints:t,rect:n,rotation:i,id:a,color:o,opacity:s,popupRef:c,richText:l,contentsObj:u,creationDate:d,modificationDate:f},parent:{page:{pageNumber:p}}}=e;r=e={annotationType:_.HIGHLIGHT,color:Array.from(o),opacity:s,quadPoints:t,boxes:null,pageIndex:p-1,rect:n.slice(0),rotation:i,annotationElementId:a,id:a,deleted:!1,popupRef:c,richText:l,comment:u?.str||null,creationDate:d,modificationDate:f}}else if(e instanceof fr){let{data:{inkLists:t,rect:n,rotation:i,id:a,color:o,borderStyle:{rawWidth:s},popupRef:c,richText:l,contentsObj:u,creationDate:d,modificationDate:f},parent:{page:{pageNumber:p}}}=e;r=e={annotationType:_.HIGHLIGHT,color:Array.from(o),thickness:s,inkLists:t,boxes:null,pageIndex:p-1,rect:n.slice(0),rotation:i,annotationElementId:a,id:a,deleted:!1,popupRef:c,richText:l,comment:u?.str||null,creationDate:d,modificationDate:f}}let{color:i,quadPoints:a,inkLists:o,outlines:s,opacity:c}=e,l=await super.deserialize(e,t,n);l.color=P.makeHexColor(...i);l.opacity=c||1;o&&(l.#g=e.thickness);l._initialData=r;e.comment&&l.setCommentData(e);let[u,d]=l.pageDimensions,[f,p]=l.pageTranslation;if(a){let e=l.#n=[];for(let t=0;t<a.length;t+=8)e.push({x:(a[t]-f)/u,y:1-(a[t+1]-p)/d,width:(a[t+2]-a[t])/u,height:(a[t+1]-a[t+5])/d});l.#v();l.#w();l.rotate(l.rotation)}else if(o||s){l.#d=!0;let e=(o||s.points)[0],n={x:e[0]-f,y:d-(e[1]-p)},r=new br(n,[0,0,u,d],1,l.#g/2,!0,.001);for(let t=0,i=e.length;t<i;t+=2){n.x=e[t]-f;n.y=d-(e[t+1]-p);r.add(n)}let{id:i,clipPathId:a}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:`0 0 1 1`,fill:l.color,"fill-opacity":l._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:r.toSVGPath()}},!0,!0);l.#y({highlightOutlines:r.getOutlines(),highlightId:i,clipPathId:a});l.#w();l.rotate(l.parentRotation)}return l}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();let t=H._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),n=super.serialize(e);Object.assign(n,{color:t,opacity:this.opacity,thickness:this.#g,quadPoints:this.#k(),outlines:this.#A(n.rect)});this.addComment(n);if(this.annotationElementId&&!this.#N(n))return null;n.id=this.annotationElementId;return n}#N(e){let{color:t}=this._initialData;return this.hasEditedComment||e.color.some((e,n)=>e!==t[n])}renderAnnotationElement(e){if(this.deleted){e.hide();return null}e.updateEdited({rect:this.getPDFRect(),popup:this.comment});return null}static canCreateNewEmptyEditor(){return!1}}class Sr{#e=Object.create(null);updateProperty(e,t){this[e]=t;this.updateSVGProperty(e,t)}updateProperties(e){if(e)for(let[t,n]of Object.entries(e))t.startsWith(`_`)||this.updateProperty(t,n)}updateSVGProperty(e,t){this.#e[e]=t}toSVGProperties(){let e=this.#e;this.#e=Object.create(null);return{root:e}}reset(){this.#e=Object.create(null)}updateAll(e=this){this.updateProperties(e)}clone(){D(`Not implemented`)}}class $ extends H{#e=null;#t;_colorPicker=null;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#n=null;static#r=null;static#i=null;static _INNER_MARGIN=3;constructor(e){super(e);this.#t=e.mustBeCommitted||!1;this._addOutlines(e)}onUpdatedColor(){this._colorPicker?.update(this.color);super.onUpdatedColor()}onUpdatedOpacity(){this._colorPicker?.updateOpacity?.(this.opacity)}_addOutlines(e){if(e.drawOutlines){this.#a(e);this.#c()}}#a({drawOutlines:e,drawId:t,drawingOptions:n}){this.#e=e;this._drawingOptions||=n;this.annotationElementId||this._uiManager.a11yAlert(H._l10nAlert[this.editorType]);if(t>=0){this._drawId=t;this.parent.drawLayer.finalizeDraw(t,e.defaultProperties)}else this._drawId=this.#o(e,this.parent);this.#d(e.box)}#o(e,t){let{id:n}=t.drawLayer.draw($._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return n}static _mergeSVGProperties(e,t){let n=new Set(Object.keys(e));for(let[r,i]of Object.entries(t))n.has(r)?Object.assign(e[r],i):e[r]=i;return e}static getDefaultDrawingOptions(e){D(`Not implemented`)}static get typesMap(){D(`Not implemented`)}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,t){let n=this.typesMap.get(e);n&&this._defaultDrawingOptions.updateProperty(n,t);if(this._currentParent){$.#n.updateProperty(n,t);this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties())}}updateParams(e,t){let n=this.constructor.typesMap.get(e);n&&this._updateProperty(e,n,t)}static get defaultPropertiesToUpdate(){let e=[],t=this._defaultDrawingOptions;for(let[n,r]of this.typesMap)e.push([n,t[r]]);return e}get propertiesToUpdate(){let e=[],{_drawingOptions:t}=this;for(let[n,r]of this.constructor.typesMap)e.push([n,t[r]]);return e}_updateProperty(e,t,n){let r=this._drawingOptions,i=r[t],a=n=>{r.updateProperty(t,n);let i=this.#e.updateProperty(t,n);i&&this.#d(i);this.parent?.drawLayer.updateProperties(this._drawId,r.toSVGProperties());e===this.colorType?this.onUpdatedColor():e===this.opacityType&&this.onUpdatedOpacity()};this.addCommands({cmd:a.bind(this,n),undo:a.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(e,t){let n=this.constructor.typesMap.get(this.colorType),r=this.constructor.typesMap.get(this.opacityType),i=this._drawingOptions,a=i[n],o=i[r],s=(e,t)=>{i.updateProperty(n,e);i.updateProperty(r,t);this.#e.updateProperty(n,e);this.#e.updateProperty(r,t);this.parent?.drawLayer.updateProperties(this._drawId,i.toSVGProperties());this.onUpdatedColor();this.onUpdatedOpacity()};this.addCommands({cmd:s.bind(this,e,t),undo:s.bind(this,a,o),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:v.INK_COLOR_AND_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,$._mergeSVGProperties(this.#e.getPathResizingSVGProperties(this.#u()),{bbox:this.#f()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,$._mergeSVGProperties(this.#e.getPathResizedSVGProperties(this.#u()),{bbox:this.#f()}))}_onTranslating(e,t){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#f()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,$._mergeSVGProperties(this.#e.getPathTranslatedSVGProperties(this.#u(),this.parentDimensions),{bbox:this.#f()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit();this.disableEditMode();this.disableEditing()}disableEditing(){super.disableEditing();this.div.classList.toggle(`disabled`,!0)}enableEditing(){super.enableEditing();this.div.classList.toggle(`disabled`,!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this);this._isDraggable=!0;if(this.#t){this.#t=!1;this.commit();this.parent.setSelected(this);e&&this.isOnScreen&&this.div.focus()}}remove(){this.#s();super.remove()}rebuild(){if(this.parent){super.rebuild();if(this.div!==null){this.#c();this.#d(this.#e.box);this.isAttachedToDOM||this.parent.add(this)}}}setParent(e){let t=!1;if(this.parent&&!e){this._uiManager.removeShouldRescale(this);this.#s()}else if(e){this._uiManager.addShouldRescale(this);this.#c(e);t=!this.parent&&this.div?.classList.contains(`selectedEditor`)}super.setParent(e);t&&this.select()}#s(){if(this._drawId!==null&&this.parent){this.parent.drawLayer.remove(this._drawId);this._drawId=null;this._drawingOptions.reset()}}#c(e=this.parent){if(this._drawId===null||this.parent!==e){if(this._drawId===null){this._drawingOptions.updateAll();this._drawId=this.#o(this.#e,e)}else this.parent.drawLayer.updateParent(this._drawId,e.drawLayer)}}#l([e,t,n,r]){let{parentDimensions:[i,a],rotation:o}=this;switch(o){case 90:return[t,1-e,a/i*n,i/a*r];case 180:return[1-e,1-t,n,r];case 270:return[1-t,e,a/i*n,i/a*r];default:return[e,t,n,r]}}#u(){let{x:e,y:t,width:n,height:r,parentDimensions:[i,a],rotation:o}=this;switch(o){case 90:return[1-t,e,i/a*n,a/i*r];case 180:return[1-e,1-t,n,r];case 270:return[t,1-e,i/a*n,a/i*r];default:return[e,t,n,r]}}#d(e){[this.x,this.y,this.width,this.height]=this.#l(e);if(this.div){this.fixAndSetPosition();this.setDims()}this._onResized()}#f(){let{x:e,y:t,width:n,height:r,rotation:i,parentRotation:a,parentDimensions:[o,s]}=this;switch((4*i+a)/90){case 1:return[1-t-r,e,r,n];case 2:return[1-e-n,1-t-r,n,r];case 3:return[t,1-e-n,r,n];case 4:return[e,t-o/s*n,s/o*r,o/s*n];case 5:return[1-t,e,o/s*n,s/o*r];case 6:return[1-e-s/o*r,1-t,s/o*r,o/s*n];case 7:return[t-o/s*n,1-e-s/o*r,o/s*n,s/o*r];case 8:return[e-n,t-r,n,r];case 9:return[1-t,e-n,r,n];case 10:return[1-e,1-t,n,r];case 11:return[t-r,1-e,r,n];case 12:return[e-s/o*r,t,s/o*r,o/s*n];case 13:return[1-t-o/s*n,e-s/o*r,o/s*n,s/o*r];case 14:return[1-e,1-t-o/s*n,s/o*r,o/s*n];case 15:return[t,1-e,o/s*n,s/o*r];default:return[e,t,n,r]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,$._mergeSVGProperties({bbox:this.#f()},this.#e.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#d(this.#e.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let e,t;if(this._isCopy){e=this.x;t=this.y}let n=super.render();n.classList.add(`draw`);let r=document.createElement(`div`);n.append(r);r.setAttribute(`aria-hidden`,`true`);r.className=`internal`;this.setDims();this._uiManager.addShouldRescale(this);this.disableEditing();this._isCopy&&this._moveAfterPaste(e,t);return n}static createDrawerInstance(e,t,n,r,i){D(`Not implemented`)}static startDrawing(e,t,n,r){let{target:i,offsetX:a,offsetY:o,pointerId:s,pointerType:c}=r;if(V.isInitializedAndDifferentPointerType(c))return;let{viewport:{rotation:l}}=e,{width:u,height:d}=i.getBoundingClientRect(),f=$.#r=new AbortController,p=e.combinedSignal(f);V.setPointer(c,s);window.addEventListener(`pointerup`,e=>{V.isSamePointerIdOrRemove(e.pointerId)&&this._endDraw(e)},{signal:p});window.addEventListener(`pointercancel`,e=>{V.isSamePointerIdOrRemove(e.pointerId)&&this._currentParent.endDrawingSession()},{signal:p});window.addEventListener(`pointerdown`,e=>{if(V.isSamePointerType(e.pointerType)){V.initializeAndAddPointerId(e.pointerId);if($.#n.isCancellable()){$.#n.removeLastElement();$.#n.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)}}},{capture:!0,passive:!1,signal:p});window.addEventListener(`contextmenu`,L,{signal:p});i.addEventListener(`pointermove`,this._drawMove.bind(this),{signal:p});i.addEventListener(`touchmove`,e=>{V.isSameTimeStamp(e.timeStamp)&&R(e)},{signal:p});e.toggleDrawing();t._editorUndoBar?.hide();if($.#n)e.drawLayer.updateProperties(this._currentDrawId,$.#n.startNew(a,o,u,d,l));else{t.updateUIForDefaultProperties(this);$.#n=this.createDrawerInstance(a,o,u,d,l);$.#i=this.getDefaultDrawingOptions();this._currentParent=e;({id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties($.#i.toSVGProperties(),$.#n.defaultSVGProperties),!0,!1))}}static _drawMove(e){V.isSameTimeStamp(e.timeStamp);if(!$.#n)return;let{offsetX:t,offsetY:n,pointerId:r}=e;if(V.isSamePointerId(r)){if(V.isUsingMultiplePointers())this._endDraw(e);else{this._currentParent.drawLayer.updateProperties(this._currentDrawId,$.#n.add(t,n));V.setTimeStamp(e.timeStamp);R(e)}}}static _cleanup(e){if(e){this._currentDrawId=-1;this._currentParent=null;$.#n=null;$.#i=null;V.clearTimeStamp()}if($.#r){$.#r.abort();$.#r=null;V.clearPointerIds()}}static _endDraw(e){let t=this._currentParent;if(t){t.toggleDrawing(!0);this._cleanup(!1);e?.target===t.div&&t.drawLayer.updateProperties(this._currentDrawId,$.#n.end(e.offsetX,e.offsetY));if(this.supportMultipleDrawings){let e=$.#n,n=this._currentDrawId,r=e.getLastElement();t.addCommands({cmd:()=>{t.drawLayer.updateProperties(n,e.setLastElement(r))},undo:()=>{t.drawLayer.updateProperties(n,e.removeLastElement())},mustExec:!1,type:v.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){let t=this._currentParent;if(!t)return null;t.toggleDrawing(!0);t.cleanUndoStack(v.DRAW_STEP);if(!$.#n.isEmpty()){let{pageDimensions:[n,r],scale:i}=t,a=t.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:$.#n.getOutlines(n*i,r*i,i,this._INNER_MARGIN),drawingOptions:$.#i,mustBeCommitted:!e});this._cleanup(!0);return a}t.drawLayer.remove(this._currentDrawId);this._cleanup(!0);return null}createDrawingOptions(e){}static deserializeDraw(e,t,n,r,i,a){D(`Not implemented`)}static async deserialize(e,t,n){let{rawDims:{pageWidth:r,pageHeight:i,pageX:a,pageY:o}}=t.viewport,s=this.deserializeDraw(a,o,r,i,this._INNER_MARGIN,e),c=await super.deserialize(e,t,n);c.createDrawingOptions(e);c.#a({drawOutlines:s});c.#c();c.onScaleChanging();c.rotate();return c}serializeDraw(e){let[t,n]=this.pageTranslation,[r,i]=this.pageDimensions;return this.#e.serialize([t,n,r,i],e)}renderAnnotationElement(e){e.updateEdited({rect:this.getPDFRect()});return null}static canCreateNewEmptyEditor(){return!1}}class Cr{#e=new Float64Array(6);#t;#n;#r;#i;#a;#o=``;#s=0;#c=new wr;#l;#u;constructor(e,t,n,r,i,a){this.#l=n;this.#u=r;this.#r=i;this.#i=a;[e,t]=this.#d(e,t);let o=this.#t=[NaN,NaN,NaN,NaN,e,t];this.#a=[e,t];this.#n=[{line:o,points:this.#a}];this.#e.set(o,0)}updateProperty(e,t){e===`stroke-width`&&(this.#i=t)}#d(e,t){return Z._normalizePoint(e,t,this.#l,this.#u,this.#r)}isEmpty(){return!this.#n||this.#n.length===0}isCancellable(){return this.#a.length<=10}add(e,t){[e,t]=this.#d(e,t);let[n,r,i,a]=this.#e.subarray(2,6),o=e-i,s=t-a;if(Math.hypot(this.#l*o,this.#u*s)<=2)return null;this.#a.push(e,t);if(isNaN(n)){this.#e.set([i,a,e,t],2);this.#t.push(NaN,NaN,NaN,NaN,e,t);return{path:{d:this.toSVGPath()}}}isNaN(this.#e[0])&&this.#t.splice(6,6);this.#e.set([n,r,i,a,e,t],0);this.#t.push(...Z.createBezierPoints(n,r,i,a,e,t));return{path:{d:this.toSVGPath()}}}end(e,t){return this.add(e,t)||(this.#a.length===2?{path:{d:this.toSVGPath()}}:null)}startNew(e,t,n,r,i){this.#l=n;this.#u=r;this.#r=i;[e,t]=this.#d(e,t);let a=this.#t=[NaN,NaN,NaN,NaN,e,t];this.#a=[e,t];let o=this.#n.at(-1);if(o){o.line=new Float32Array(o.line);o.points=new Float32Array(o.points)}this.#n.push({line:a,points:this.#a});this.#e.set(a,0);this.#s=0;this.toSVGPath();return null}getLastElement(){return this.#n.at(-1)}setLastElement(e){if(!this.#n)return this.#c.setLastElement(e);this.#n.push(e);this.#t=e.line;this.#a=e.points;this.#s=0;return{path:{d:this.toSVGPath()}}}removeLastElement(){if(!this.#n)return this.#c.removeLastElement();this.#n.pop();this.#o=``;for(let e=0,t=this.#n.length;e<t;e++){let{line:t,points:n}=this.#n[e];this.#t=t;this.#a=n;this.#s=0;this.toSVGPath()}return{path:{d:this.#o}}}toSVGPath(){let e=Z.svgRound(this.#t[4]),t=Z.svgRound(this.#t[5]);if(this.#a.length===2){this.#o=`${this.#o} M ${e} ${t} Z`;return this.#o}if(this.#a.length<=6){let n=this.#o.lastIndexOf(`M`);this.#o=`${this.#o.slice(0,n)} M ${e} ${t}`;this.#s=6}if(this.#a.length===4){let e=Z.svgRound(this.#t[10]),t=Z.svgRound(this.#t[11]);this.#o=`${this.#o} L ${e} ${t}`;this.#s=12;return this.#o}let n=[];if(this.#s===0){n.push(`M ${e} ${t}`);this.#s=6}for(let e=this.#s,t=this.#t.length;e<t;e+=6){let[t,r,i,a,o,s]=this.#t.slice(e,e+6).map(Z.svgRound);n.push(`C${t} ${r} ${i} ${a} ${o} ${s}`)}this.#o+=n.join(` `);this.#s=this.#t.length;return this.#o}getOutlines(e,t,n,r){let i=this.#n.at(-1);i.line=new Float32Array(i.line);i.points=new Float32Array(i.points);this.#c.build(this.#n,e,t,n,this.#r,this.#i,r);this.#e=null;this.#t=null;this.#n=null;this.#o=null;return this.#c}get defaultSVGProperties(){return{root:{viewBox:`0 0 10000 10000`},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class wr extends Z{#e;#t=0;#n;#r;#i;#a;#o;#s;#c;build(e,t,n,r,i,a,o){this.#i=t;this.#a=n;this.#o=r;this.#s=i;this.#c=a;this.#n=o??0;this.#r=e;this.#d()}get thickness(){return this.#c}setLastElement(e){this.#r.push(e);return{path:{d:this.toSVGPath()}}}removeLastElement(){this.#r.pop();return{path:{d:this.toSVGPath()}}}toSVGPath(){let e=[];for(let{line:t}of this.#r){e.push(`M${Z.svgRound(t[4])} ${Z.svgRound(t[5])}`);if(t.length!==6){if(t.length===12&&isNaN(t[6]))e.push(`L${Z.svgRound(t[10])} ${Z.svgRound(t[11])}`);else for(let n=6,r=t.length;n<r;n+=6){let[r,i,a,o,s,c]=t.subarray(n,n+6).map(Z.svgRound);e.push(`C${r} ${i} ${a} ${o} ${s} ${c}`)}}else e.push(`Z`)}return e.join(``)}serialize([e,t,n,r],i){let a=[],o=[],[s,c,l,u]=this.#u(),d,f,p,m,h,g,_,v,y;switch(this.#s){case 0:y=Z._rescale;d=e;f=t+r;p=n;m=-r;h=e+s*n;g=t+(1-c-u)*r;_=e+(s+l)*n;v=t+(1-c)*r;break;case 90:y=Z._rescaleAndSwap;d=e;f=t;p=n;m=r;h=e+c*n;g=t+s*r;_=e+(c+u)*n;v=t+(s+l)*r;break;case 180:y=Z._rescale;d=e+n;f=t;p=-n;m=r;h=e+(1-s-l)*n;g=t+c*r;_=e+(1-s)*n;v=t+(c+u)*r;break;case 270:y=Z._rescaleAndSwap;d=e+n;f=t+r;p=-n;m=-r;h=e+(1-c-u)*n;g=t+(1-s-l)*r;_=e+(1-c)*n;v=t+(1-s)*r}for(let{line:e,points:t}of this.#r){a.push(y(e,d,f,p,m,i?Array(e.length):null));o.push(y(t,d,f,p,m,i?Array(t.length):null))}return{lines:a,points:o,rect:[h,g,_,v]}}static deserialize(e,t,n,r,i,{paths:{lines:a,points:o},rotation:s,thickness:c}){let l=[],u,d,f,p,m;switch(s){case 0:m=Z._rescale;u=-e/n;d=t/r+1;f=1/n;p=-1/r;break;case 90:m=Z._rescaleAndSwap;u=-t/r;d=-e/n;f=1/r;p=1/n;break;case 180:m=Z._rescale;u=e/n+1;d=-t/r;f=-1/n;p=1/r;break;case 270:m=Z._rescaleAndSwap;u=t/r+1;d=e/n+1;f=-1/r;p=-1/n}if(!a){a=[];for(let e of o){let t=e.length;if(t===2){a.push(new Float32Array([NaN,NaN,NaN,NaN,e[0],e[1]]));continue}if(t===4){a.push(new Float32Array([NaN,NaN,NaN,NaN,e[0],e[1],NaN,NaN,NaN,NaN,e[2],e[3]]));continue}let n=new Float32Array(3*(t-2));a.push(n);let[r,i,o,s]=e.subarray(0,4);n.set([NaN,NaN,NaN,NaN,r,i],0);for(let a=4;a<t;a+=2){let t=e[a],c=e[a+1];n.set(Z.createBezierPoints(r,i,o,s,t,c),3*(a-2));[r,i,o,s]=[o,s,t,c]}}}for(let e=0,t=a.length;e<t;e++)l.push({line:m(a[e].map(e=>e??NaN),u,d,f,p),points:m(o[e].map(e=>e??NaN),u,d,f,p)});let h=new this.prototype.constructor;h.build(l,n,r,1,s,c,i);return h}#l(e=this.#c){let t=this.#n+e/2*this.#o;return this.#s%180==0?[t/this.#i,t/this.#a]:[t/this.#a,t/this.#i]}#u(){let[e,t,n,r]=this.#e,[i,a]=this.#l(0);return[e+i,t+a,n-2*i,r-2*a]}#d(){let e=this.#e=d.slice();for(let{line:t}of this.#r){if(t.length<=12){for(let n=4,r=t.length;n<r;n+=6)P.pointBoundingBox(t[n],t[n+1],e);continue}let n=t[4],r=t[5];for(let i=6,a=t.length;i<a;i+=6){let[a,o,s,c,l,u]=t.subarray(i,i+6);P.bezierBoundingBox(n,r,a,o,s,c,l,u,e);n=l;r=u}}let[t,n]=this.#l();e[0]=F(e[0]-t,0,1);e[1]=F(e[1]-n,0,1);e[2]=F(e[2]+t,0,1);e[3]=F(e[3]+n,0,1);e[2]-=e[0];e[3]-=e[1]}get box(){return this.#e}updateProperty(e,t){return e===`stroke-width`?this.#f(t):null}#f(e){let[t,n]=this.#l();this.#c=e;let[r,i]=this.#l(),[a,o]=[r-t,i-n],s=this.#e;s[0]-=a;s[1]-=o;s[2]+=2*a;s[3]+=2*o;return s}updateParentDimensions([e,t],n){let[r,i]=this.#l();this.#i=e;this.#a=t;this.#o=n;let[a,o]=this.#l(),s=a-r,c=o-i,l=this.#e;l[0]-=s;l[1]-=c;l[2]+=2*s;l[3]+=2*c;return l}updateRotation(e){this.#t=e;return{path:{transform:this.rotationTransform}}}get viewBox(){return this.#e.map(Z.svgRound).join(` `)}get defaultProperties(){let[e,t]=this.#e;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Z.svgRound(e)} ${Z.svgRound(t)}`}}}get rotationTransform(){let[,,e,t]=this.#e,n=0,r=0,i=0,a=0,o=0,s=0;switch(this.#t){case 90:r=t/e;i=-e/t;o=e;break;case 180:n=-1;a=-1;o=e;s=t;break;case 270:r=-t/e;i=e/t;s=t;break;default:return``}return`matrix(${n} ${r} ${i} ${a} ${Z.svgRound(o)} ${Z.svgRound(s)})`}getPathResizingSVGProperties([e,t,n,r]){let[i,a]=this.#l(),[o,s,c,l]=this.#e;if(Math.abs(c-i)<=Z.PRECISION||Math.abs(l-a)<=Z.PRECISION){let i=e+n/2-(o+c/2),a=t+r/2-(s+l/2);return{path:{"transform-origin":`${Z.svgRound(e)} ${Z.svgRound(t)}`,transform:`${this.rotationTransform} translate(${i} ${a})`}}}let u=(n-2*i)/(c-2*i),d=(r-2*a)/(l-2*a),f=c/n,p=l/r;return{path:{"transform-origin":`${Z.svgRound(o)} ${Z.svgRound(s)}`,transform:`${this.rotationTransform} scale(${f} ${p}) translate(${Z.svgRound(i)} ${Z.svgRound(a)}) scale(${u} ${d}) translate(${Z.svgRound(-i)} ${Z.svgRound(-a)})`}}}getPathResizedSVGProperties([e,t,n,r]){let[i,a]=this.#l(),o=this.#e,[s,c,l,u]=o;o[0]=e;o[1]=t;o[2]=n;o[3]=r;if(Math.abs(l-i)<=Z.PRECISION||Math.abs(u-a)<=Z.PRECISION){let i=e+n/2-(s+l/2),a=t+r/2-(c+u/2);for(let{line:e,points:t}of this.#r){Z._translate(e,i,a,e);Z._translate(t,i,a,t)}return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Z.svgRound(e)} ${Z.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let d=(n-2*i)/(l-2*i),f=(r-2*a)/(u-2*a),p=-d*(s+i)+e+i,m=-f*(c+a)+t+a;if(d!==1||f!==1||p!==0||m!==0)for(let{line:e,points:t}of this.#r){Z._rescale(e,p,m,d,f,e);Z._rescale(t,p,m,d,f,t)}return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Z.svgRound(e)} ${Z.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,t],n){let[r,i]=n,a=this.#e,o=e-a[0],s=t-a[1];if(this.#i===r&&this.#a===i)for(let{line:e,points:t}of this.#r){Z._translate(e,o,s,e);Z._translate(t,o,s,t)}else{let e=this.#i/r,t=this.#a/i;this.#i=r;this.#a=i;for(let{line:n,points:r}of this.#r){Z._rescale(n,o,s,e,t,n);Z._rescale(r,o,s,e,t,r)}a[2]*=e;a[3]*=t}a[0]=e;a[1]=t;return{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${Z.svgRound(e)} ${Z.svgRound(t)}`}}}get defaultSVGProperties(){let e=this.#e;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Z.svgRound(e[0])} ${Z.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}}class Tr extends Sr{constructor(e){super();this._viewParameters=e;super.updateProperties({fill:`none`,stroke:H._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-miterlimit":10})}updateSVGProperty(e,t){if(e===`stroke-width`){t??=this[`stroke-width`];t*=this._viewParameters.realScale}super.updateSVGProperty(e,t)}clone(){let e=new Tr(this._viewParameters);e.updateAll(this);return e}}class Er extends ${static _type=`ink`;static _editorType=_.INK;static _defaultDrawingOptions=null;constructor(e){super({...e,name:`inkEditor`});this._willKeepAspectRatio=!0;this.defaultL10nId=`pdfjs-editor-ink-editor`}static initialize(e,t){H.initialize(e,t);this._defaultDrawingOptions=new Tr(t.viewParameters)}static getDefaultDrawingOptions(e){let t=this._defaultDrawingOptions.clone();t.updateProperties(e);return t}static get supportMultipleDrawings(){return!0}static get typesMap(){return j(this,`typesMap`,new Map([[v.INK_THICKNESS,`stroke-width`],[v.INK_COLOR,`stroke`],[v.INK_OPACITY,`stroke-opacity`]]))}static createDrawerInstance(e,t,n,r,i){return new Cr(e,t,n,r,i,this._defaultDrawingOptions[`stroke-width`])}static deserializeDraw(e,t,n,r,i,a){return wr.deserialize(e,t,n,r,i,a)}static async deserialize(e,t,n){let r=null;if(e instanceof fr){let{data:{inkLists:t,rect:n,rotation:i,id:a,color:o,opacity:s,borderStyle:{rawWidth:c},popupRef:l,richText:u,contentsObj:d,creationDate:f,modificationDate:p},parent:{page:{pageNumber:m}}}=e;r=e={annotationType:_.INK,color:Array.from(o),thickness:c,opacity:s,paths:{points:t},boxes:null,pageIndex:m-1,rect:n.slice(0),rotation:i,annotationElementId:a,id:a,deleted:!1,popupRef:l,richText:u,comment:d?.str||null,creationDate:f,modificationDate:p}}let i=await super.deserialize(e,t,n);i._initialData=r;e.comment&&i.setCommentData(e);return i}get toolbarButtons(){this._colorPicker||=new er(this);return[[`colorPicker`,this._colorPicker]]}get colorType(){return v.INK_COLOR}get colorAndOpacityType(){return v.INK_COLOR_AND_OPACITY}get opacityType(){return v.INK_OPACITY}updateParams(e,t){e===v.INK_COLOR_AND_OPACITY?this._updateColorAndOpacity(t.color,t.opacity):super.updateParams(e,t)}static updateDefaultParams(e,t){if(e!==v.INK_COLOR_AND_OPACITY)super.updateDefaultParams(e,t);else{super.updateDefaultParams(v.INK_COLOR,t.color);super.updateDefaultParams(v.INK_OPACITY,t.opacity)}}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions[`stroke-opacity`]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();let{_drawId:e,_drawingOptions:t,parent:n}=this;t.updateSVGProperty(`stroke-width`);n.drawLayer.updateProperties(e,t.toSVGProperties())}static onScaleChangingWhenDrawing(){let e=this._currentParent;if(e){super.onScaleChangingWhenDrawing();this._defaultDrawingOptions.updateSVGProperty(`stroke-width`);e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties())}}createDrawingOptions({color:e,thickness:t,opacity:n}){this._drawingOptions=Er.getDefaultDrawingOptions({stroke:P.makeHexColor(...e),"stroke-width":t,"stroke-opacity":n})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:t,points:n}=this.serializeDraw(e),{_drawingOptions:{stroke:r,"stroke-opacity":i,"stroke-width":a}}=this,o=Object.assign(super.serialize(e),{color:H._colorManager.convert(r),opacity:i,thickness:a,paths:{lines:t,points:n}});this.addComment(o);if(e){o.isCopy=!0;return o}if(this.annotationElementId&&!this.#e(o))return null;o.id=this.annotationElementId;return o}#e(e){let{color:t,thickness:n,opacity:r,pageIndex:i}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||e.color.some((e,n)=>e!==t[n])||e.thickness!==n||e.opacity!==r||e.pageIndex!==i}renderAnnotationElement(e){if(this.deleted){e.hide();return null}let{points:t,rect:n}=this.serializeDraw(!1);e.updateEdited({rect:n,thickness:this._drawingOptions[`stroke-width`],points:t,popup:this.comment});return null}}class Dr extends wr{toSVGPath(){let e=super.toSVGPath();e.endsWith(`Z`)||(e+=`Z`);return e}}class Or{static#e={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};static#t(e,t,n,r){r-=t;return(n-=e)===0?r>0?0:4:n===1?r+6:2-r}static#n=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#r(e,t,n,r,i,a,o){let s=this.#t(n,r,i,a);for(let i=0;i<8;i++){let a=(-i+s-o+16)%8;if(e[(n+this.#n[2*a])*t+(r+this.#n[2*a+1])]!==0)return a}return-1}static#i(e,t,n,r,i,a,o){let s=this.#t(n,r,i,a);for(let i=0;i<8;i++){let a=(i+s+o+16)%8;if(e[(n+this.#n[2*a])*t+(r+this.#n[2*a+1])]!==0)return a}return-1}static#a(e,t,n,r){let i=e.length,a=new Int32Array(i);for(let t=0;t<i;t++)a[t]=+(e[t]<=r);for(let e=1;e<n-1;e++)a[e*t]=a[e*t+t-1]=0;for(let e=0;e<t;e++)a[e]=a[t*n-1-e]=0;let o,s=1,c=[];for(let e=1;e<n-1;e++){o=1;for(let n=1;n<t-1;n++){let r=e*t+n,i=a[r];if(i===0)continue;let l=e,u=n;if(i===1&&a[r-1]===0){s+=1;--u}else{if(!(i>=1&&a[r+1]===0)){i!==1&&(o=Math.abs(i));continue}s+=1;u+=1;i>1&&(o=i)}let d=[n,e],f=u===n+1,p={isHole:f,points:d,id:s,parent:0};c.push(p);let m;for(let e of c)if(e.id===o){m=e;break}p.parent=m?m.isHole?f?m.parent:o:f?o:m.parent:f?o:0;let h=this.#r(a,t,e,n,l,u,0);if(h===-1){a[r]=-s;a[r]!==1&&(o=Math.abs(a[r]));continue}let g=this.#n[2*h],_=this.#n[2*h+1],v=e+g,y=n+_;l=v;u=y;let b=e,x=n;for(;;){let i=this.#i(a,t,b,x,l,u,1);g=this.#n[2*i];_=this.#n[2*i+1];let c=b+g,f=x+_;d.push(f,c);let p=b*t+x;a[p+1]===0?a[p]=-s:a[p]===1&&(a[p]=s);if(c===e&&f===n&&b===v&&x===y){a[r]!==1&&(o=Math.abs(a[r]));break}l=b;u=x;b=c;x=f}}}return c}static#o(e,t,n,r){if(n-t<=4){for(let i=t;i<n-2;i+=2)r.push(e[i],e[i+1]);return}let i=e[t],a=e[t+1],o=e[n-4]-i,s=e[n-3]-a,c=Math.hypot(o,s),l=o/c,u=s/c,d=l*a-u*i,f=s/o,p=1/c,m=Math.atan(f),h=Math.cos(m),g=Math.sin(m),_=p*(Math.abs(h)+Math.abs(g)),v=p*(1-_+_**2),y=Math.max(Math.atan(Math.abs(g+h)*v),Math.atan(Math.abs(g-h)*v)),b=0,x=t;for(let r=t+2;r<n-2;r+=2){let t=Math.abs(d-l*e[r+1]+u*e[r]);if(t>b){x=r;b=t}}if(b>(c*y)**2){this.#o(e,t,x+2,r);this.#o(e,x,n,r)}else r.push(i,a)}static#s(e){let t=[],n=e.length;this.#o(e,0,n,t);t.push(e[n-2],e[n-1]);return t.length<=4?null:t}static#c(e,t,n,r,i,a){let o=new Float32Array(a**2),s=-2*r**2,c=a>>1;for(let e=0;e<a;e++){let t=(e-c)**2;for(let n=0;n<a;n++)o[e*a+n]=Math.exp((t+(n-c)**2)/s)}let l=new Float32Array(256),u=-2*i**2;for(let e=0;e<256;e++)l[e]=Math.exp(e**2/u);let d=e.length,f=new Uint8Array(d),p=new Uint32Array(256);for(let r=0;r<n;r++)for(let i=0;i<t;i++){let s=r*t+i,u=e[s],d=0,m=0;for(let s=0;s<a;s++){let f=r+s-c;if(!(f<0||f>=n))for(let n=0;n<a;n++){let r=i+n-c;if(r<0||r>=t)continue;let p=e[f*t+r],h=o[s*a+n]*l[Math.abs(p-u)];d+=p*h;m+=h}}p[f[s]=Math.round(d/m)]++}return[f,p]}static#l(e){let t=new Uint32Array(256);for(let n of e)t[n]++;return t}static#u(e){let t=e.length,n=new Uint8ClampedArray(t>>2),r=-1/0,i=1/0;for(let t=0,a=n.length;t<a;t++){let a=n[t]=e[t<<2];r=Math.max(r,a);i=Math.min(i,a)}let a=255/(r-i);for(let e=0,t=n.length;e<t;e++)n[e]=(n[e]-i)*a;return n}static#d(e){let t,n=-1/0,r=-1/0,i=e.findIndex(e=>e!==0),a=i,o=i;for(t=i;t<256;t++){let i=e[t];if(i>n){if(t-a>r){r=t-a;o=t-1}n=i;a=t}}for(t=o-1;t>=0&&!(e[t]>e[t+1]);t--);return t}static#f(e){let t=e,{width:n,height:r}=e,{maxDim:i}=this.#e,a=n,o=r;if(n>i||r>i){let s=n,c=r,l=Math.log2(Math.max(n,r)/i),u=Math.floor(l);l=l===u?u-1:u;for(let n=0;n<l;n++){a=Math.ceil(s/2);o=Math.ceil(c/2);let n=new OffscreenCanvas(a,o);n.getContext(`2d`).drawImage(e,0,0,s,c,0,0,a,o);s=a;c=o;e!==t&&e.close();e=n.transferToImageBitmap()}let d=Math.min(i/a,i/o);a=Math.round(a*d);o=Math.round(o*d)}let s=new OffscreenCanvas(a,o).getContext(`2d`,{willReadFrequently:!0});s.fillStyle=`white`;s.fillRect(0,0,a,o);s.filter=`grayscale(1)`;s.drawImage(e,0,0,e.width,e.height,0,0,a,o);let c=s.getImageData(0,0,a,o).data;return[this.#u(c),a,o]}static extractContoursFromText(e,{fontFamily:t,fontStyle:n,fontWeight:r},i,a,o,s){let c=new OffscreenCanvas(1,1),l=c.getContext(`2d`,{alpha:!1}),u=l.font=`${n} ${r} 200px ${t}`,{actualBoundingBoxLeft:d,actualBoundingBoxRight:f,actualBoundingBoxAscent:p,actualBoundingBoxDescent:m,fontBoundingBoxAscent:h,fontBoundingBoxDescent:g,width:_}=l.measureText(e),v=1.5,y=Math.ceil(Math.max(Math.abs(d)+Math.abs(f)||0,_)*v),b=Math.ceil(Math.max(Math.abs(p)+Math.abs(m)||200,Math.abs(h)+Math.abs(g)||200)*v);c=new OffscreenCanvas(y,b);l=c.getContext(`2d`,{alpha:!0,willReadFrequently:!0});l.font=u;l.filter=`grayscale(1)`;l.fillStyle=`white`;l.fillRect(0,0,y,b);l.fillStyle=`black`;l.fillText(e,.5*y/2,1.5*b/2);let x=this.#u(l.getImageData(0,0,y,b).data),S=this.#l(x),C=this.#d(S),w=this.#a(x,y,b,C);return this.processDrawnLines({lines:{curves:w,width:y,height:b},pageWidth:i,pageHeight:a,rotation:o,innerMargin:s,mustSmooth:!0,areContours:!0})}static process(e,t,n,r,i){let[a,o,s]=this.#f(e),[c,l]=this.#c(a,o,s,Math.hypot(o,s)*this.#e.sigmaSFactor,this.#e.sigmaR,this.#e.kernelSize),u=this.#d(l),d=this.#a(c,o,s,u);return this.processDrawnLines({lines:{curves:d,width:o,height:s},pageWidth:t,pageHeight:n,rotation:r,innerMargin:i,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:e,pageWidth:t,pageHeight:n,rotation:r,innerMargin:i,mustSmooth:a,areContours:o}){r%180!=0&&([t,n]=[n,t]);let{curves:s,width:c,height:l}=e,u=e.thickness??0,d=[],f=Math.min(t/c,n/l),p=f/t,m=f/n,h=[];for(let{points:e}of s){let t=a?this.#s(e):e;if(!t)continue;h.push(t);let n=t.length,r=new Float32Array(n),i=new Float32Array(3*(n===2?2:n-2));d.push({line:i,points:r});if(n===2){r[0]=t[0]*p;r[1]=t[1]*m;i.set([NaN,NaN,NaN,NaN,r[0],r[1]],0);continue}let[o,s,c,l]=t;o*=p;s*=m;c*=p;l*=m;r.set([o,s,c,l],0);i.set([NaN,NaN,NaN,NaN,o,s],0);for(let e=4;e<n;e+=2){let n=r[e]=t[e]*p,a=r[e+1]=t[e+1]*m;i.set(Z.createBezierPoints(o,s,c,l,n,a),3*(e-2));[o,s,c,l]=[c,l,n,a]}}if(d.length===0)return null;let g=o?new Dr:new wr;g.build(d,t,n,1,r,o?0:u,i);return{outline:g,newCurves:h,areContours:o,thickness:u,width:c,height:l}}static async compressSignature({outlines:e,areContours:t,thickness:n,width:r,height:i}){let a,o=1/0,s=-1/0,c=0;for(let t of e){c+=t.length;for(let e=2,n=t.length;e<n;e++){let n=t[e]-t[e-2];o=Math.min(o,n);s=Math.max(s,n)}}a=o>=-128&&s<=127?Int8Array:o>=-32768&&s<=32767?Int16Array:Int32Array;let l=e.length,u=8+3*l,d=new Uint32Array(u),f=0;d[f++]=u*Uint32Array.BYTES_PER_ELEMENT+(c-2*l)*a.BYTES_PER_ELEMENT;d[f++]=0;d[f++]=r;d[f++]=i;d[f++]=+!t;d[f++]=Math.max(0,Math.floor(n??0));d[f++]=l;d[f++]=a.BYTES_PER_ELEMENT;for(let t of e){d[f++]=t.length-2;d[f++]=t[0];d[f++]=t[1]}let p=new CompressionStream(`deflate-raw`),m=p.writable.getWriter();await m.ready;m.write(d);let h=a.prototype.constructor;for(let t of e){let e=new h(t.length-2);for(let n=2,r=t.length;n<r;n++)e[n-2]=t[n]-t[n-2];m.write(e)}m.close();return(await new Response(p.readable).bytes()).toBase64()}static async decompressSignature(e){try{let t=Uint8Array.fromBase64(e),{readable:n,writable:r}=new DecompressionStream(`deflate-raw`),i=r.getWriter();await i.ready;i.write(t).then(async()=>{await i.ready;await i.close()}).catch(()=>{});let a=null,o=0;for await(let e of n){a||=new Uint8Array(new Uint32Array(e.buffer,0,4)[0]);a.set(e,o);o+=e.length}let s=new Uint32Array(a.buffer,0,a.length>>2),c=s[1];if(c!==0)throw Error(`Invalid version: ${c}`);let l=s[2],u=s[3],d=s[4]===0,f=s[5],p=s[6],m=s[7],h=[],g=(8+3*p)*Uint32Array.BYTES_PER_ELEMENT,_;switch(m){case Int8Array.BYTES_PER_ELEMENT:_=new Int8Array(a.buffer,g);break;case Int16Array.BYTES_PER_ELEMENT:_=new Int16Array(a.buffer,g);break;case Int32Array.BYTES_PER_ELEMENT:_=new Int32Array(a.buffer,g)}o=0;for(let e=0;e<p;e++){let t=s[3*e+8],n=new Float32Array(t+2);h.push(n);for(let t=0;t<2;t++)n[t]=s[3*e+8+t+1];for(let e=0;e<t;e++)n[e+2]=n[e]+_[o++]}return{areContours:d,thickness:f,outlines:h,width:l,height:u}}catch(e){E(`decompressSignature: ${e}`);return null}}}class kr extends Sr{constructor(){super();super.updateProperties({fill:H._defaultLineColor,"stroke-width":0})}clone(){let e=new kr;e.updateAll(this);return e}}class Ar extends Tr{constructor(e){super(e);super.updateProperties({stroke:H._defaultLineColor,"stroke-width":1})}clone(){let e=new Ar(this._viewParameters);e.updateAll(this);return e}}class jr extends ${#e=!1;#t=null;#n=null;#r=null;static _type=`signature`;static _editorType=_.SIGNATURE;static _defaultDrawingOptions=null;constructor(e){super({...e,mustBeCommitted:!0,name:`signatureEditor`});this._willKeepAspectRatio=!0;this.#n=e.signatureData||null;this.#t=null;this.defaultL10nId=`pdfjs-editor-signature-editor1`}static initialize(e,t){H.initialize(e,t);this._defaultDrawingOptions=new kr;this._defaultDrawnSignatureOptions=new Ar(t.viewParameters)}static getDefaultDrawingOptions(e){let t=this._defaultDrawingOptions.clone();t.updateProperties(e);return t}static get supportMultipleDrawings(){return!1}static get typesMap(){return j(this,`typesMap`,new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:`signature`,hasDescription:!!this.#t}}static computeTelemetryFinalData(e){let t=e.get(`hasDescription`);return{hasAltText:t.get(!0)??0,hasNoAltText:t.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let e,t,{_isCopy:n}=this;if(n){this._isCopy=!1;e=this.x;t=this.y}super.render();if(this._drawId===null){if(this.#n){let{lines:e,mustSmooth:t,areContours:n,description:r,uuid:i,heightInPage:a}=this.#n,{rawDims:{pageWidth:o,pageHeight:s},rotation:c}=this.parent.viewport,l=Or.processDrawnLines({lines:e,pageWidth:o,pageHeight:s,rotation:c,innerMargin:jr._INNER_MARGIN,mustSmooth:t,areContours:n});this.addSignature(l,a,r,i)}else{this.div.setAttribute(`data-l10n-args`,JSON.stringify({description:``}));this.div.hidden=!0;this._uiManager.getSignature(this)}}else this.div.setAttribute(`data-l10n-args`,JSON.stringify({description:this.#t||``}));if(n){this._isCopy=!0;this._moveAfterPaste(e,t)}return this.div}setUuid(e){this.#r=e;this.addEditToolbar()}getUuid(){return this.#r}get description(){return this.#t}set description(e){this.#t=e;if(this.div){this.div.setAttribute(`data-l10n-args`,JSON.stringify({description:e}));super.addEditToolbar().then(t=>{t?.updateEditSignatureButton(e)})}}getSignaturePreview(){let{newCurves:e,areContours:t,thickness:n,width:r,height:i}=this.#n,a=Math.max(r,i);return{areContours:t,outline:Or.processDrawnLines({lines:{curves:e.map(e=>({points:e})),thickness:n,width:r,height:i},pageWidth:a,pageHeight:a,rotation:0,innerMargin:0,mustSmooth:!1,areContours:t}).outline}}get toolbarButtons(){return this._uiManager.signatureManager?[[`editSignature`,this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(e,t,n,r){let{x:i,y:a}=this,{outline:o}=this.#n=e;this.#e=o instanceof Dr;this.description=n;let s;if(this.#e)s=jr.getDefaultDrawingOptions();else{s=jr._defaultDrawnSignatureOptions.clone();s.updateProperties({"stroke-width":o.thickness})}this._addOutlines({drawOutlines:o,drawingOptions:s});let[,c]=this.pageDimensions,l=t/c;l=l>=1?.5:l;this.width*=l/this.height;if(this.width>=1){l*=.9/this.width;this.width=.9}this.height=l;this.setDims();this.x=i;this.y=a;this.center();this._onResized();this.onScaleChanging();this.rotate();this._uiManager.addToAnnotationStorage(this);this.setUuid(r);this._reportTelemetry({action:`pdfjs.signature.inserted`,data:{hasBeenSaved:!!r,hasDescription:!!n}});this.div.hidden=!1}getFromImage(e){let{rawDims:{pageWidth:t,pageHeight:n},rotation:r}=this.parent.viewport;return Or.process(e,t,n,r,jr._INNER_MARGIN)}getFromText(e,t){let{rawDims:{pageWidth:n,pageHeight:r},rotation:i}=this.parent.viewport;return Or.extractContoursFromText(e,t,n,r,i,jr._INNER_MARGIN)}getDrawnSignature(e){let{rawDims:{pageWidth:t,pageHeight:n},rotation:r}=this.parent.viewport;return Or.processDrawnLines({lines:e,pageWidth:t,pageHeight:n,rotation:r,innerMargin:jr._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:t}){if(e)this._drawingOptions=jr.getDefaultDrawingOptions();else{this._drawingOptions=jr._defaultDrawnSignatureOptions.clone();this._drawingOptions.updateProperties({"stroke-width":t})}}serialize(e=!1){if(this.isEmpty())return null;let{lines:t,points:n}=this.serializeDraw(e),{_drawingOptions:{"stroke-width":r}}=this,i=Object.assign(super.serialize(e),{isSignature:!0,areContours:this.#e,color:[0,0,0],thickness:this.#e?0:r});this.addComment(i);if(e){i.paths={lines:t,points:n};i.uuid=this.#r;i.isCopy=!0}else i.lines=t;this.#t&&(i.accessibilityData={type:`Figure`,alt:this.#t});return i}static deserializeDraw(e,t,n,r,i,a){return a.areContours?Dr.deserialize(e,t,n,r,i,a):wr.deserialize(e,t,n,r,i,a)}static async deserialize(e,t,n){let r=await super.deserialize(e,t,n);r.#e=e.areContours;r.description=e.accessibilityData?.alt||``;r.#r=e.uuid;return r}}class Mr extends H{#e=null;#t=null;#n=null;#r=null;#i=null;#a=``;#o=null;#s=!1;#c=null;#l=!1;#u=!1;static _type=`stamp`;static _editorType=_.STAMP;constructor(e){super({...e,name:`stampEditor`});this.#r=e.bitmapUrl;this.#i=e.bitmapFile;this.defaultL10nId=`pdfjs-editor-stamp-editor`}static initialize(e,t){H.initialize(e,t)}static isHandlingMimeForPasting(e){return Ee.includes(e)}static paste(e,t){t.pasteEditor({mode:_.STAMP},{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1);super.altTextFinish()}get telemetryFinalData(){return{type:`stamp`,hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(e){let t=e.get(`hasAltText`);return{hasAltText:t.get(!0)??0,hasNoAltText:t.get(!1)??0}}#d(e,t=!1){if(e){this.#e=e.bitmap;if(!t){this.#t=e.id;this.#l=e.isSvg}e.file&&(this.#a=e.file.name);this.#m()}else this.remove()}#f(){this.#n=null;this._uiManager.enableWaiting(!1);if(this.#o){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#e)this.addEditToolbar().then(()=>{this._editToolbar.hide();this._uiManager.editAltText(this,!0)});else{if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#e){this._reportTelemetry({action:`pdfjs.image.image_added`,data:{alt_text_modal:!1,alt_text_type:`empty`}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}}async mlGuessAltText(e=null,t=!0){if(this.hasAltTextData())return null;let{mlManager:n}=this._uiManager;if(!n)throw Error(`No ML.`);if(!await n.isEnabledFor(`altText`))throw Error(`ML isn't enabled for alt text.`);let{data:r,width:i,height:a}=e||this.copyCanvas(null,null,!0).imageData,o=await n.guess({name:`altText`,request:{data:r,width:i,height:a,channels:r.length/(i*a)}});if(!o)throw Error(`No response from the AI service.`);if(o.error)throw Error(`Error from the AI service.`);if(o.cancel)return null;if(!o.output)throw Error(`No valid response from the AI service.`);let s=o.output;await this.setGuessedAltText(s);t&&!this.hasAltTextData()&&(this.altTextData={alt:s,decorative:!1});return s}#p(){if(this.#t){this._uiManager.enableWaiting(!0);this._uiManager.imageManager.getFromId(this.#t).then(e=>this.#d(e,!0)).finally(()=>this.#f());return}if(this.#r){let e=this.#r;this.#r=null;this._uiManager.enableWaiting(!0);this.#n=this._uiManager.imageManager.getFromUrl(e).then(e=>this.#d(e)).finally(()=>this.#f());return}if(this.#i){let e=this.#i;this.#i=null;this._uiManager.enableWaiting(!0);this.#n=this._uiManager.imageManager.getFromFile(e).then(e=>this.#d(e)).finally(()=>this.#f());return}let e=document.createElement(`input`);e.type=`file`;e.accept=Ee.join(`,`);let t=this._uiManager._signal;this.#n=new Promise(n=>{e.addEventListener(`change`,async()=>{if(e.files&&e.files.length!==0){this._uiManager.enableWaiting(!0);let t=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:`pdfjs.image.image_selected`,data:{alt_text_modal:this._uiManager.useNewAltTextFlow}});this.#d(t)}else this.remove();n()},{signal:t});e.addEventListener(`cancel`,()=>{this.remove();n()},{signal:t})}).finally(()=>this.#f());e.click()}remove(){if(this.#t){this.#e=null;this._uiManager.imageManager.deleteId(this.#t);this.#o?.remove();this.#o=null;if(this.#c){clearTimeout(this.#c);this.#c=null}}super.remove()}rebuild(){if(this.parent){super.rebuild();if(this.div!==null){this.#t&&this.#o===null&&this.#p();this.isAttachedToDOM||this.parent.add(this)}}else this.#t&&this.#p()}onceAdded(e){this._isDraggable=!0;e&&this.div.focus()}isEmpty(){return!(this.#n||this.#e||this.#r||this.#i||this.#t||this.#s)}get toolbarButtons(){return[[`altText`,this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let e,t;if(this._isCopy){e=this.x;t=this.y}super.render();this.div.hidden=!0;this.createAltText();this.#s||(this.#e?this.#m():this.#p());this._isCopy&&this._moveAfterPaste(e,t);this._uiManager.addShouldRescale(this);return this.div}setCanvas(e,t){let{id:n,bitmap:r}=this._uiManager.imageManager.getFromCanvas(e,t);t.remove();if(n&&this._uiManager.imageManager.isValidId(n)){this.#t=n;r&&(this.#e=r);this.#s=!1;this.#m()}}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;this.#c!==null&&clearTimeout(this.#c);this.#c=setTimeout(()=>{this.#c=null;this.#g()},200)}#m(){let{div:e}=this,{width:t,height:n}=this.#e,[r,i]=this.pageDimensions,a=.75;if(this.width){t=this.width*r;n=this.height*i}else if(t>a*r||n>a*i){let e=Math.min(a*r/t,a*i/n);t*=e;n*=e}this._uiManager.enableWaiting(!1);let o=this.#o=document.createElement(`canvas`);o.setAttribute(`role`,`img`);this.addContainer(o);this.width=t/r;this.height=n/i;this.setDims();this._initialOptions?.isCentered?this.center():this.fixAndSetPosition();this._initialOptions=null;this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(e.hidden=!1);this.#g();if(!this.#u){this.parent.addUndoableEditor(this);this.#u=!0}this._reportTelemetry({action:`inserted_image`});this.#a&&this.div.setAttribute(`aria-description`,this.#a);this.annotationElementId||this._uiManager.a11yAlert(H._l10nAlert.stamp)}copyCanvas(e,t,n=!1){e||=224;let{width:r,height:i}=this.#e,a=new Te,o=this.#e,s=r,c=i,l=null;if(t){if(r>t||i>t){let e=Math.min(t/r,t/i);s=Math.floor(r*e);c=Math.floor(i*e)}l=document.createElement(`canvas`);let e=l.width=Math.ceil(s*a.sx),n=l.height=Math.ceil(c*a.sy);this.#l||(o=this.#h(e,n));let u=l.getContext(`2d`);u.filter=this._uiManager.hcmFilter;let d=`white`,f=`#cfcfd8`;if(this._uiManager.hcmFilter!==`none`)f=`black`;else if(De.isDarkMode){d=`#8f8f9d`;f=`#42414d`}let p=15*a.sx,m=15*a.sy,h=new OffscreenCanvas(2*p,2*m),g=h.getContext(`2d`);g.fillStyle=d;g.fillRect(0,0,2*p,2*m);g.fillStyle=f;g.fillRect(0,0,p,m);g.fillRect(p,m,p,m);u.fillStyle=u.createPattern(h,`repeat`);u.fillRect(0,0,e,n);u.drawImage(o,0,0,o.width,o.height,0,0,e,n)}let u=null;if(n){let t,n;if(a.symmetric&&o.width<e&&o.height<e){t=o.width;n=o.height}else{o=this.#e;if(r>e||i>e){let a=Math.min(e/r,e/i);t=Math.floor(r*a);n=Math.floor(i*a);this.#l||(o=this.#h(t,n))}}let s=new OffscreenCanvas(t,n).getContext(`2d`,{willReadFrequently:!0});s.drawImage(o,0,0,o.width,o.height,0,0,t,n);u={width:t,height:n,data:s.getImageData(0,0,t,n).data}}return{canvas:l,width:s,height:c,imageData:u}}#h(e,t){let{width:n,height:r}=this.#e,i=n,a=r,o=this.#e;for(;i>2*e||a>2*t;){let n=i,r=a;i>2*e&&(i=Math.ceil(i/2));a>2*t&&(a=Math.ceil(a/2));let s=new OffscreenCanvas(i,a);s.getContext(`2d`).drawImage(o,0,0,n,r,0,0,i,a);o=s.transferToImageBitmap()}return o}#g(){let[e,t]=this.parentDimensions,{width:n,height:r}=this,i=new Te,a=Math.ceil(n*e*i.sx),o=Math.ceil(r*t*i.sy),s=this.#o;if(!s||s.width===a&&s.height===o)return;s.width=a;s.height=o;let c=this.#l?this.#e:this.#h(a,o),l=s.getContext(`2d`);l.filter=this._uiManager.hcmFilter;l.drawImage(c,0,0,c.width,c.height,0,0,a,o)}#_(e){if(e){if(this.#l){let e=this._uiManager.imageManager.getSvgUrl(this.#t);if(e)return e}let e=document.createElement(`canvas`);({width:e.width,height:e.height}=this.#e);e.getContext(`2d`).drawImage(this.#e,0,0);return e.toDataURL()}if(this.#l){let[e,t]=this.pageDimensions,n=Math.round(this.width*e*pe.PDF_TO_CSS_UNITS),r=Math.round(this.height*t*pe.PDF_TO_CSS_UNITS),i=new OffscreenCanvas(n,r);i.getContext(`2d`).drawImage(this.#e,0,0,this.#e.width,this.#e.height,0,0,n,r);return i.transferToImageBitmap()}return structuredClone(this.#e)}static async deserialize(e,t,n){let r=null,i=!1;if(e instanceof mr){let{data:{rect:a,rotation:o,id:s,structParent:c,popupRef:l,richText:u,contentsObj:d,creationDate:f,modificationDate:p},container:m,parent:{page:{pageNumber:g}},canvas:v}=e,y,b;if(v){delete e.canvas;({id:y,bitmap:b}=n.imageManager.getFromCanvas(m.id,v));v.remove()}else{i=!0;e._hasNoCanvas=!0}let x=(await t._structTree.getAriaAttributes(`${h}${s}`))?.get(`aria-label`)||``;r=e={annotationType:_.STAMP,bitmapId:y,bitmap:b,pageIndex:g-1,rect:a.slice(0),rotation:o,annotationElementId:s,id:s,deleted:!1,accessibilityData:{decorative:!1,altText:x},isSvg:!1,structParent:c,popupRef:l,richText:u,comment:d?.str||null,creationDate:f,modificationDate:p}}let a=await super.deserialize(e,t,n),{rect:o,bitmap:s,bitmapUrl:c,bitmapId:l,isSvg:u,accessibilityData:d}=e;if(i){n.addMissingCanvas(e.id,a);a.#s=!0}else if(l&&n.imageManager.isValidId(l)){a.#t=l;s&&(a.#e=s)}else a.#r=c;a.#l=u;let[f,p]=a.pageDimensions;a.width=(o[2]-o[0])/f;a.height=(o[3]-o[1])/p;d&&(a.altTextData=d);a._initialData=r;e.comment&&a.setCommentData(e);a.#u=!!r;return a}serialize(e=!1,t=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let n=Object.assign(super.serialize(e),{bitmapId:this.#t,isSvg:this.#l});this.addComment(n);if(e){n.bitmapUrl=this.#_(!0);n.accessibilityData=this.serializeAltText(!0);n.isCopy=!0;return n}let{decorative:r,altText:i}=this.serializeAltText(!1);!r&&i&&(n.accessibilityData={type:`Figure`,alt:i});if(this.annotationElementId){let e=this.#v(n);if(e.isSame)return null;e.isSameAltText?delete n.accessibilityData:n.accessibilityData.structParent=this._initialData.structParent??-1;n.id=this.annotationElementId;delete n.bitmapId;return n}if(t===null)return n;t.stamps||=new Map;let a=this.#l?(n.rect[2]-n.rect[0])*(n.rect[3]-n.rect[1]):null;if(t.stamps.has(this.#t)){if(this.#l){let e=t.stamps.get(this.#t);if(a>e.area){e.area=a;e.serialized.bitmap.close();e.serialized.bitmap=this.#_(!1)}}}else{t.stamps.set(this.#t,{area:a,serialized:n});n.bitmap=this.#_(!1)}return n}#v(e){let{pageIndex:t,accessibilityData:{altText:n}}=this._initialData,r=e.pageIndex===t,i=(e.accessibilityData?.alt||``)===n;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&r&&i,isSameAltText:i}}renderAnnotationElement(e){if(this.deleted){e.hide();return null}e.updateEdited({rect:this.getPDFRect(),popup:this.comment});return null}}class Nr{#e;#t=!1;#n=null;#r=null;#i=null;#a=new Map;#o=!1;#s=!1;#c=!1;#l=null;#u=null;#d=null;#f=null;#p=null;#m=-1;#h;static _initialized=!1;static#g=new Map([X,Er,Mr,Q,jr].map(e=>[e._editorType,e]));constructor({uiManager:e,pageIndex:t,div:n,structTreeLayer:r,accessibilityManager:i,annotationLayer:a,drawLayer:o,textLayer:s,viewport:c,l10n:l}){let u=[...Nr.#g.values()];if(!Nr._initialized){Nr._initialized=!0;for(let t of u)t.initialize(l,e)}e.registerEditorTypes(u);this.#h=e;this.pageIndex=t;this.div=n;this.#e=i;this.#n=a;this.viewport=c;this.#d=s;this.drawLayer=o;this._structTree=r;this.#h.addLayer(this)}get isEmpty(){return this.#a.size===0}get isInvisible(){return this.isEmpty&&this.#h.getMode()===_.NONE}updateToolbar(e){this.#h.updateToolbar(e)}updateMode(e=this.#h.getMode()){this.#S();switch(e){case _.NONE:this.div.classList.toggle(`nonEditing`,!0);this.disableTextSelection();this.togglePointerEvents(!1);this.toggleAnnotationLayerPointerEvents(!0);this.disableClick();return;case _.INK:this.disableTextSelection();this.togglePointerEvents(!0);this.enableClick();break;case _.HIGHLIGHT:this.enableTextSelection();this.togglePointerEvents(!1);this.disableClick();break;default:this.disableTextSelection();this.togglePointerEvents(!0);this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:t}=this.div;t.toggle(`nonEditing`,!1);if(e===_.POPUP)t.toggle(`commentEditing`,!0);else{t.toggle(`commentEditing`,!1);for(let n of Nr.#g.values())t.toggle(`${n._type}Editing`,e===n._editorType)}this.div.hidden=!1}hasTextLayer(e){return e===this.#d?.div}setEditingState(e){this.#h.setEditingState(e)}addCommands(e){this.#h.addCommands(e)}cleanUndoStack(e){this.#h.cleanUndoStack(e)}toggleDrawing(e=!1){this.div.classList.toggle(`drawing`,!e)}togglePointerEvents(e=!1){this.div.classList.toggle(`disabled`,!e)}toggleAnnotationLayerPointerEvents(e=!1){this.#n?.togglePointerEvents(e)}get#_(){return this.#a.size===0?this.#h.getEditors(this.pageIndex):this.#a.values()}async enable(){this.#c=!0;this.div.tabIndex=0;this.togglePointerEvents(!0);this.div.classList.toggle(`nonEditing`,!1);this.#p?.abort();this.#p=null;let e=new Set;for(let t of this.#_){t.enableEditing();t.show(!0);if(t.annotationElementId){this.#h.removeChangedExistingAnnotation(t);e.add(t.annotationElementId)}}let t=this.#n;if(t)for(let n of t.getEditableAnnotations()){n.hide();if(this.#h.isDeletedAnnotationElement(n.data.id))continue;if(e.has(n.data.id))continue;let t=await this.deserialize(n);if(t){this.addOrRebuild(t);t.enableEditing()}}this.#c=!1;this.#h._eventBus.dispatch(`editorsrendered`,{source:this,pageNumber:this.pageIndex+1})}disable(){this.#s=!0;this.div.tabIndex=-1;this.togglePointerEvents(!1);this.div.classList.toggle(`nonEditing`,!0);if(this.#d&&!this.#p){this.#p=new AbortController;let e=this.#h.combinedSignal(this.#p);this.#d.div.addEventListener(`pointerdown`,e=>{let{clientX:t,clientY:n,timeStamp:r}=e;if(r-this.#m>500){this.#m=r;return}this.#m=-1;let{classList:i}=this.div;i.toggle(`getElements`,!0);let a=document.elementsFromPoint(t,n);i.toggle(`getElements`,!1);if(!this.div.contains(a[0]))return;let o,s=RegExp(`^${g}[0-9]+$`);for(let e of a)if(s.test(e.id)){o=e.id;break}if(!o)return;let c=this.#a.get(o);if(c?.annotationElementId===null){R(e);c.dblclick(e)}},{signal:e,capture:!0})}let e=this.#n,t=[];if(e){let n=new Map,r=new Map;for(let e of this.#_){e.disableEditing();if(e.annotationElementId){if(e.serialize()===null){r.set(e.annotationElementId,e);this.getEditableAnnotation(e.annotationElementId)?.show();e.remove()}else n.set(e.annotationElementId,e)}else t.push(e)}for(let t of e.getEditableAnnotations()){let{id:e}=t.data;if(this.#h.isDeletedAnnotationElement(e)){t.updateEdited({deleted:!0});continue}let i=r.get(e);if(i){i.resetAnnotationElement(t);i.show(!1);t.show()}else{i=n.get(e);if(i){this.#h.addChangedExistingAnnotation(i);i.renderAnnotationElement(t)&&i.show(!1)}t.show()}}}this.#S();this.isEmpty&&(this.div.hidden=!0);let{classList:n}=this.div;for(let e of Nr.#g.values())n.remove(`${e._type}Editing`);this.disableTextSelection();this.toggleAnnotationLayerPointerEvents(!0);e?.updateFakeAnnotations(t);this.#s=!1}getEditableAnnotation(e){return this.#n?.getEditableAnnotation(e)||null}setActiveEditor(e){this.#h.getActive()!==e&&this.#h.setActiveEditor(e)}enableTextSelection(){this.div.tabIndex=-1;if(this.#d?.div&&!this.#f){this.#f=new AbortController;let e=this.#h.combinedSignal(this.#f);this.#d.div.addEventListener(`pointerdown`,this.#v.bind(this),{signal:e});this.#d.div.classList.add(`highlighting`)}}disableTextSelection(){this.div.tabIndex=0;if(this.#d?.div&&this.#f){this.#f.abort();this.#f=null;this.#d.div.classList.remove(`highlighting`)}}#v(e){this.#h.unselectAll();let{target:t}=e;if(t===this.#d.div||(t.getAttribute(`role`)===`img`||t.classList.contains(`endOfContent`)||t.classList.contains(`textLayerImages`)||t.classList.contains(`textLayerImagePlaceholder`))&&this.#d.div.contains(t)){let{isMac:t}=N.platform;if(e.button!==0||e.ctrlKey&&t)return;this.#h.showAllEditors(`highlight`,!0,!0);this.#d.div.classList.add(`free`);this.toggleDrawing();Q.startHighlighting(this,this.#h.direction===`ltr`,{target:this.#d.div,x:e.x,y:e.y});this.#d.div.addEventListener(`pointerup`,()=>{this.#d.div.classList.remove(`free`);this.toggleDrawing(!0)},{once:!0,signal:this.#h._signal});e.preventDefault()}}enableClick(){if(this.#r)return;this.#r=new AbortController;let e=this.#h.combinedSignal(this.#r);this.div.addEventListener(`pointerdown`,this.pointerdown.bind(this),{signal:e});let t=this.pointerup.bind(this);this.div.addEventListener(`pointerup`,t,{signal:e});this.div.addEventListener(`pointercancel`,t,{signal:e})}disableClick(){this.#r?.abort();this.#r=null}attach(e){this.#a.set(e.id,e);let{annotationElementId:t}=e;t&&this.#h.isDeletedAnnotationElement(t)&&this.#h.removeDeletedAnnotationElement(e)}detach(e){this.#a.delete(e.id);this.#e?.removePointerInTextLayer(e.contentDiv);!this.#s&&e.annotationElementId&&this.#h.addDeletedAnnotationElement(e)}remove(e){this.detach(e);this.#h.removeEditor(e);e.div.remove();e.isAttachedToDOM=!1}changeParent(e){if(e.parent!==this){if(e.parent&&e.annotationElementId){this.#h.addDeletedAnnotationElement(e);H.deleteAnnotationElement(e);e.annotationElementId=null}this.attach(e);e.parent?.detach(e);e.setParent(this);if(e.div&&e.isAttachedToDOM){e.div.remove();this.div.append(e.div)}}}add(e){if(e.parent!==this||!e.isAttachedToDOM){this.changeParent(e);this.#h.addEditor(e);this.attach(e);if(!e.isAttachedToDOM){let t=e.render();this.div.append(t);e.isAttachedToDOM=!0}e.fixAndSetPosition();e.onceAdded(!this.#c);this.#h.addToAnnotationStorage(e);e._reportTelemetry(e.telemetryInitialData)}}moveEditorInDOM(e){if(!e.isAttachedToDOM)return;let{activeElement:t}=document;if(e.div.contains(t)&&!this.#i){e._focusEventsAllowed=!1;this.#i=setTimeout(()=>{this.#i=null;if(e.div.contains(document.activeElement))e._focusEventsAllowed=!0;else{e.div.addEventListener(`focusin`,()=>{e._focusEventsAllowed=!0},{once:!0,signal:this.#h._signal});t.focus()}},0)}e._structTreeParentId=this.#e?.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){if(e.needsToBeRebuilt()){e.parent||=this;e.rebuild();e.show()}else this.add(e)}addUndoableEditor(e){this.addCommands({cmd:()=>e._uiManager.rebuild(e),undo:()=>{e.remove()},mustExec:!1})}getEditorByUID(e){for(let t of this.#a.values())if(t.uid===e)return t;return null}get#y(){return Nr.#g.get(this.#h.getMode())}combinedSignal(e){return this.#h.combinedSignal(e)}#b(e){let t=this.#y;return t?new t.prototype.constructor(e):null}canCreateNewEmptyEditor(){return this.#y?.canCreateNewEmptyEditor()}async pasteEditor(e,t){this.updateToolbar(e);await this.#h.updateMode(e.mode);let{offsetX:n,offsetY:r}=this.#x(),i=this.#h.getId(),a=this.#b({parent:this,id:i,x:n,y:r,uiManager:this.#h,isCentered:!0,...t});a&&this.add(a)}async deserialize(e){return await Nr.#g.get(e.annotationType??e.annotationEditorType)?.deserialize(e,this,this.#h)||null}createAndAddNewEditor(e,t,n={}){let r=this.#h.getId(),i=this.#b({parent:this,id:r,x:e.offsetX,y:e.offsetY,uiManager:this.#h,isCentered:t,...n});i&&this.add(i);return i}get boundingClientRect(){return this.div.getBoundingClientRect()}#x(){let{x:e,y:t,width:n,height:r}=this.boundingClientRect,i=Math.max(0,e),a=Math.max(0,t),o=(i+Math.min(window.innerWidth,e+n))/2-e,s=(a+Math.min(window.innerHeight,t+r))/2-t,[c,l]=this.viewport.rotation%180==0?[o,s]:[s,o];return{offsetX:c,offsetY:l}}addNewEditor(e={}){this.createAndAddNewEditor(this.#x(),!0,e)}setSelected(e){this.#h.setSelected(e)}toggleSelected(e){this.#h.toggleSelected(e)}unselect(e){this.#h.unselect(e)}pointerup(e){let{isMac:t}=N.platform;if(e.button!==0||e.ctrlKey&&t)return;if(e.target!==this.div)return;if(!this.#o)return;this.#o=!1;if(this.#y?.isDrawer&&this.#y.supportMultipleDrawings)return;if(!this.#t){this.#t=!0;return}let n=this.#h.getMode();n!==_.STAMP&&n!==_.POPUP&&n!==_.SIGNATURE?this.createAndAddNewEditor(e,!1):this.#h.unselectAll()}pointerdown(e){this.#h.getMode()===_.HIGHLIGHT&&this.enableTextSelection();if(this.#o){this.#o=!1;return}let{isMac:t}=N.platform;if(e.button!==0||e.ctrlKey&&t)return;if(e.target!==this.div)return;this.#o=!0;if(this.#y?.isDrawer){this.startDrawingSession(e);return}let n=this.#h.getActive();this.#t=!n||n.isEmpty()}startDrawingSession(e){this.div.focus({preventScroll:!0});if(this.#l){this.#y.startDrawing(this,this.#h,!1,e);return}this.#h.setCurrentDrawingSession(this);this.#l=new AbortController;let t=this.#h.combinedSignal(this.#l);this.div.addEventListener(`blur`,({relatedTarget:e})=>{if(e&&!this.div.contains(e)){this.#u=null;this.commitOrRemove()}},{signal:t});this.#y.startDrawing(this,this.#h,!1,e)}pause(e){if(e){let{activeElement:e}=document;this.div.contains(e)&&(this.#u=e);return}this.#u&&setTimeout(()=>{this.#u?.focus();this.#u=null},0)}endDrawingSession(e=!1){if(!this.#l)return null;this.#h.setCurrentDrawingSession(null);this.#l.abort();this.#l=null;this.#u=null;return this.#y.endDrawing(e)}findNewParent(e,t,n){let r=this.#h.findParent(t,n);if(r===null||r===this)return!1;r.changeParent(e);return!0}commitOrRemove(){if(this.#l){this.endDrawingSession();return!0}return!1}onScaleChanging(){this.#l&&this.#y.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove();if(this.#h.getActive()?.parent===this){this.#h.commitOrRemove();this.#h.setActiveEditor(null)}if(this.#i){clearTimeout(this.#i);this.#i=null}for(let e of this.#a.values()){this.#e?.removePointerInTextLayer(e.contentDiv);e.setParent(null);e.isAttachedToDOM=!1;e.div.remove()}this.div=null;this.#a.clear();this.#h.removeLayer(this)}#S(){for(let e of this.#a.values())e.isEmpty()&&e.remove()}async render({viewport:e}){this.viewport=e;we(this.div,e);for(let e of this.#h.getEditors(this.pageIndex)){this.add(e);e.rebuild()}await this.#h.findClonesForPage(this);this.div.hidden=this.isEmpty;this.updateMode()}update({viewport:e}){this.#h.commitOrRemove();this.#S();let t=this.viewport.rotation,n=e.rotation;this.viewport=e;we(this.div,{rotation:n});if(t!==n)for(let e of this.#a.values())e.rotate(n)}get pageDimensions(){let{pageWidth:e,pageHeight:t}=this.viewport.rawDims;return[e,t]}get scale(){return this.#h.viewParameters.realScale}}globalThis._pdfjsTestingUtils={HighlightOutliner:vr};const Pr={fonts:globalThis.fonts,createElement(e){if(e.toLowerCase()===`canvas`)return new OffscreenCanvas(1,1);return null}};class Fr{constructor(){this._pdfDocument=null;this._page=null;this._geospatialMetadata=null;this._baseViewport=null;this._inverseBaseViewport=null;this._pdfWorker=null;this._pdfWorkerBlobUrl=null;this._pdfWorkerPort=null}async loadPDF(n,s={}){let[{data:c},l]=await Promise.all([t(n.url,{responseType:`array-buffer`,signal:s?.signal}),this._getPDFWorker(s)]),u=Kn({data:c,wasmUrl:e(`esri/libs/pdfjs/wasm/`),ownerDocument:Pr,enableHWA:!0,useWorkerFetch:!0,worker:l,useWasm:!0,verbosity:0});this._pdfDocument=await u.promise;r(s);this._page=await this._pdfDocument.getPage(n.page);r(s);this._geospatialMetadata=await this._page.getGeospatialPDFMetadata();r(s);this._baseViewport=this._page.getViewport({scale:1});this._inverseBaseViewport=i();o(this._inverseBaseViewport,a(...this._baseViewport.transform));return{geospatialMetadata:this._geospatialMetadata}}destroy(){this._page?.cleanup?.();this._page=null;this._pdfDocument?.cleanup();this._pdfDocument=null;this._geospatialMetadata=null;this._baseViewport=null;this._inverseBaseViewport=null;this._pdfWorker?.destroy();this._pdfWorker=null;this._pdfWorkerPort?.terminate();this._pdfWorkerPort=null;if(this._pdfWorkerBlobUrl){URL.revokeObjectURL(this._pdfWorkerBlobUrl);this._pdfWorkerBlobUrl=null}}async renderPDF(e,t={}){if(!this._page||!this._baseViewport||!this._inverseBaseViewport)throw new n(`geospatial-pdf-layer-worker:not-loaded`,`PDF not loaded`);r(t);let{width:i,height:a,sourceExtentAsJSON:o,currentRing:l,ctm:u}=e,d=s.fromJSON(o),f=await c(d,i,a,u,this._page,this._baseViewport,this._inverseBaseViewport,l,t);r(t);return Ir(f,i,a)}async _getPDFWorker(n={}){if(this._pdfWorker)return this._pdfWorker;let r=e(`esri/libs/pdfjs/pdf.worker.mjs`),i=(await t(r,{responseType:`blob`,authMode:`anonymous`,signal:n.signal})).data,a=i.type===`application/javascript`||i.type===`text/javascript`?i:new Blob([i],{type:`application/javascript`}),o=URL.createObjectURL(a),s=null,c=null;try{s=new Worker(o,{type:`module`,name:`geospatial-pdf-pdfjs-worker`});c=new J({port:s,verbosity:0});this._pdfWorkerPort=s;this._pdfWorker=c;this._pdfWorkerBlobUrl=o;await c.promise;return c}catch(e){URL.revokeObjectURL(o);throw e}}}function Ir(e,t,r){let i=e.getContext(`2d`);if(!i)throw new n(`geospatial-pdf-raster:canvas`,`Failed to create canvas context.`);let a=i.getImageData(0,0,t,r).data,o=t*r,s=new Uint8Array(o),c=new Uint8Array(o),l=new Uint8Array(o),u=new Uint8Array(o);for(let e=0,t=0;e<o;e++,t+=4){s[e]=a[t];c[e]=a[t+1];l[e]=a[t+2];u[e]=a[t+3]}return{width:t,height:r,red:s,green:c,blue:l,mask:u}}export{Fr as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../config.js";import n from"../../../request.js";import{isSome as r,remove as i}from"../../../core/arrayUtils.js";import a from"../../../core/Error.js";import has from"../../../core/has.js";import{JSONMap as o}from"../../../core/jsonMap.js";import{Loadable as s}from"../../../core/Loadable.js";import c from"../../../core/Logger.js";import{setDeepValue as l}from"../../../core/object.js";import{debounce as u,after as d,throwIfAbortError as f}from"../../../core/promiseUtils.js";import{watch as p}from"../../../core/reactiveUtils.js";import{join as m}from"../../../core/urlUtils.js";import{generateBracedUUID as h}from"../../../core/uuid.js";import{property as g,subclass as _}from"../../../core/accessorSupport/decorators.js";import v from"../../../geometry/Extent.js";import y from"../../../geometry/SpatialReference.js";import b from"../../../geometry/support/MeshGeoreferencedVertexSpace.js";import{isRelativeVertexSpace as x}from"../../../geometry/support/meshVertexSpaceUtils.js";import{isOriginalExternal as S}from"../../../geometry/support/meshUtils/External.js";import{createFeatureEditResult as C,getFeatureJSON as w,getFeatureIds as T,getAttachmentEditsJSON as E,isProtectedOrPrivateVersionError as D,unpackEditResultData as O,createEditedFeatures as k}from"../applyEditsUtils.js";import{createDrawingInfo as A}from"./support/clientSideDefaults.js";import j from"./support/QueryTask.js";import{isHostedAgolService as M}from"../../support/arcgisLayerUrl.js";import{ensureLayerCredential as N}from"../../support/featureLayerUtils.js";import{getAssetMapTable as P}from"../../support/infoFor3D.js";import{executeQueryJSON as F}from"../../../rest/query/executeQueryJSON.js";import{unapplyEditsZUnitScaling as I}from"../../../rest/query/operations/editsZScale.js";import L from"../../../rest/support/Query.js";import R from"../../../time/TimeExtent.js";import{isSafeToEditVersion as z,isVersionInEditSession as B,isHistoricVersion as V,currentSessionId as H}from"../../../versionManagement/support/versionManagementUtils.js";const U=new o({originalAndCurrentFeatures:`original-and-current-features`,none:`none`}),W=new o({Started:`published`,Publishing:`publishing`,Stopped:`unavailable`});let G=class extends s{constructor(e){super(e),this.type=`feature-layer`,this.supportedSourceTypes=new Set([`Feature Layer`,`Oriented Imagery Layer`,`Table`,`Catalog Layer`,`Annotation Layer`,`Dimension Layer`]),this.refresh=u(async()=>{await this.load();let e=this.sourceJSON.editingInfo?.lastEditDate;if(e==null)return{dataChanged:!0,updates:{}};try{await this._fetchService(null)}catch{return{dataChanged:!0,updates:{}}}let t=e!==this.sourceJSON.editingInfo?.lastEditDate;return{dataChanged:t,updates:t?{editingInfo:this.sourceJSON.editingInfo,extent:this.sourceJSON.extent}:null}}),this._ongoingAssetUploads=new Map}load(e){let t=this.layer.sourceJSON,n=this._fetchService(t,{...e}).then(()=>this.layer.setUserPrivileges(this.sourceJSON.serviceItemId,e)).then(()=>this._ensureLatestMetadata(e));return this.addResolvingPromise(n),Promise.resolve(this)}async reload(e){let t=this.layer.userHasUpdateItemPrivileges&&this.sourceJSON.cacheMaxAge>0;await this._fetchService(null,{...e,cacheBust:t})}initialize(){this.addHandles([p(()=>{let e=this.layer;return e&&`lastEditsEventDate`in e?e.lastEditsEventDate:null},e=>this._handleLastEditsEventChange(e))])}destroy(){this._removeEditInterceptor()}get queryTask(){let{capabilities:e,parsedUrl:t,gdbVersion:n,spatialReference:r,fieldsIndex:i,uniqueIdFields:a}=this.layer,o=`infoFor3D`in this.layer?this.layer.infoFor3D:null,s=`dynamicDataSource`in this.layer?this.layer.dynamicDataSource:null,c=has(`featurelayer-pbf`)&&e?.query.supportsFormatPBF&&o==null,l=c&&e?.query.supportsFormatPBFWithCurves,u=e?.operations?.supportsQueryAttachments??!1,d=e?.query?.relativeTimeBinWindow??0,f=t.path;return new j({dynamicDataSource:s,fieldsIndex:i,gdbVersion:n,infoFor3D:o,pbfSupported:c,pbfSupportedWithCurves:l,queryAttachmentsSupported:u,relativeTimeBinWindow:d,sourceSpatialReference:r,uniqueIdFields:a,url:f})}async addAttachment(e,t,r){await this.load();let{layer:i}=this;await N(i,`editing`);let a=e.attributes[i.objectIdField],o=i.parsedUrl.path+`/`+a+`/addAttachment`,s=this._getLayerRequestOptions({query:r}),c=this._getFormDataForAttachment(t,s.query);try{let e=await n(o,{body:c});return C(e.data.addAttachmentResult)}catch(e){throw this._createAttachmentErrorResult(a,e)}}async updateAttachment(e,t,r,i){await this.load();let{layer:a}=this;await N(a,`editing`);let o=e.attributes[a.objectIdField],s=a.parsedUrl.path+`/`+o+`/updateAttachment`,c=this._getLayerRequestOptions({query:{attachmentId:t,...i}}),l=this._getFormDataForAttachment(r,c.query);try{let e=await n(s,{body:l});return C(e.data.updateAttachmentResult)}catch(e){throw this._createAttachmentErrorResult(o,e)}}async applyEdits(e,t){await this.load();let{layer:i}=this;await N(i,`editing`);let o=`infoFor3D`in i?i.infoFor3D:null,s=o!=null,c=s||(t?.globalIdUsed??!1),l=s?await this._uploadMeshesAndGetAssetMapEditsJSON(e):null,u=e.addFeatures?.map(e=>w(this.layer,e,o))??[],d=(await Promise.all(u)).filter(r),f=e.updateFeatures?.map(e=>w(this.layer,e,o))??[],p=(await Promise.all(f)).filter(r),m=T(this.layer,e.deleteFeatures,c);I(d,p,i.spatialReference);let h=await E(this.layer,e),g=i.capabilities.editing.supportsAsyncApplyEdits&&s,_=t?.gdbVersion||i.gdbVersion,v={gdbVersion:_,rollbackOnFailure:t?.rollbackOnFailureEnabled,useGlobalIds:c,returnEditMoment:t?.returnEditMoment,trueCurveClient:t?.editsRespectTrueCurves,usePreviousEditMoment:t?.usePreviousEditMoment,async:g};await z(this.layer.url,_,!0);let y=B(this.layer.url,_||null);if(await V(i.url,_,i.historicMoment))throw new a(`feature-layer-source:historic-version`,`Editing a historic version is not allowed`);t?.returnServiceEditsOption?(v.edits=JSON.stringify([{id:i.layerId,adds:d.length?d:null,updates:p.length?p:null,deletes:m.length?m:null,attachments:h,assetMaps:l}]),v.returnServiceEditsOption=U.toJSON(t?.returnServiceEditsOption),v.returnServiceEditsInSourceSR=t?.returnServiceEditsInSourceSR):(v.adds=d.length?JSON.stringify(d):null,v.updates=p.length?JSON.stringify(p):null,v.deletes=m.length?c?JSON.stringify(m):m.join(`,`):null,v.attachments=h&&JSON.stringify(h),v.assetMaps=l==null?void 0:JSON.stringify(l));let b=this._getLayerRequestOptions({method:`post`,query:v});y&&(b.authMode=`immediate`,b.query.returnEditMoment=!0,b.query.sessionId=H);let x=t?.returnServiceEditsOption?i.url:i.parsedUrl.path,S;try{S=g?await this._asyncApplyEdits(x+`/applyEdits`,b):await n(x+`/applyEdits`,b)}catch(e){if(D(e))b.authMode=`immediate`,S=g?await this._asyncApplyEdits(x+`/applyEdits`,b):await n(x+`/applyEdits`,b);else throw e}return this._createEditsResult(S)}async deleteAttachments(e,t,r){await this.load();let{layer:i}=this;await N(i,`editing`);let a=e.attributes[i.objectIdField],o=i.parsedUrl.path+`/`+a+`/deleteAttachments`;try{return(await n(o,this._getLayerRequestOptions({query:{attachmentIds:t.join(`,`),...r},method:`post`}))).data.deleteAttachmentResults.map(C)}catch(e){throw this._createAttachmentErrorResult(a,e)}}fetchRecomputedExtents(e={}){let t=e.signal;return this.load({signal:t}).then(async()=>{let t=this._getLayerRequestOptions({...e,query:{returnUpdates:!0}}),{layerId:r,url:i}=this.layer,{data:a}=await n(`${i}/${r}`,t),{id:o,extent:s,fullExtent:c,timeExtent:l}=a,u=s||c;return{id:o,fullExtent:u&&v.fromJSON(u),timeExtent:l&&R.fromJSON({start:l[0],end:l[1]})}})}async queryAttachments(e,t={}){await this.load();let n=this._getLayerRequestOptions(t);return this.queryTask.executeAttachmentQuery(e,n)}async queryFeatures(e,t){await this.load();let n=await this.queryTask.execute(e,{...t,query:this._createRequestQueryOptions(t)});if(e.outStatistics?.length&&n.features.length){let t=new Map;if(n.features.forEach(n=>{let r=n.attributes;e.outStatistics?.forEach(({outStatisticFieldName:e})=>{if(e){let n=e.toLowerCase();n&&n in r&&e!==n&&(r[e]=r[n],delete r[n],t.set(n,e))}})}),n.fields!=null)for(let e of n.fields){let n=t.get(e.name.toLowerCase());n!=null&&(e.name=n)}}return n}async queryFeaturesJSON(e,t){return await this.load(),this.queryTask.executeJSON(e,{...t,query:this._createRequestQueryOptions(t)})}async queryObjectIds(e,t){return await this.load(),this.queryTask.executeForIds(e,{...t,query:this._createRequestQueryOptions(t)})}async queryFeatureCount(e,t){return await this.load(),this.queryTask.executeForCount(e,{...t,query:this._createRequestQueryOptions(t)})}async queryExtent(e,t){return await this.load(),this.queryTask.executeForExtent(e,{...t,query:this._createRequestQueryOptions(t)})}async queryRelatedFeatures(e,t){return await this.load(),this.queryTask.executeRelationshipQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryRelatedFeaturesCount(e,t){return await this.load(),this.queryTask.executeRelationshipQueryForCount(e,{...t,query:this._createRequestQueryOptions(t)})}async queryPivot(e,t){return await this.load(),this.queryTask.executePivotQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopFeatures(e,t){return await this.load(),this.queryTask.executeTopFeaturesQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryAttributeBins(e,t){return await this.load(),this.queryTask.executeAttributeBinsQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopObjectIds(e,t){return await this.load(),this.queryTask.executeForTopIds(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopExtents(e,t){return await this.load(),this.queryTask.executeForTopExtents(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopCount(e,t){return await this.load(),this.queryTask.executeForTopCount(e,{...t,query:this._createRequestQueryOptions(t)})}async fetchPublishingStatus(){if(!M(this.layer.url))return`unavailable`;let e=m(this.layer.url,`status`),t=await n(e,{query:{f:`json`}});return W.fromJSON(t.data.status)}async uploadAssets(e,t){let{uploadAssets:n}=await import(`./support/uploadAssets.js`);return n(e,{layer:this.layer,ongoingUploads:this._ongoingAssetUploads},t)}_handleLastEditsEventChange(e){let t=this.layer;if(e==null||!(`capabilities`in t)||!(`effectiveCapabilities`in t)||t.capabilities?.operations?.supportsEditing||!t.effectiveCapabilities?.operations?.supportsEditing)return;let n=t.url;if(n==null)return;`layerId`in t&&(n=m(n,t.layerId.toString()));let r=this._getOrCreateEditInterceptor(n);r.before=t=>{let n=t.requestOptions.method??`auto`;if(n===`auto`||n===`head`){let n=t.requestOptions.query??{};n._ts=e.getTime(),t.requestOptions.query=n}}}_getOrCreateEditInterceptor(e){return this._editInterceptor??(this._editInterceptor={urls:e},t.request.internalInterceptors.push(this._editInterceptor)),this._editInterceptor}_removeEditInterceptor(){this._editInterceptor!=null&&(i(t.request.internalInterceptors,this._editInterceptor),this._editInterceptor=null)}async _asyncApplyEdits(e,t){let r=(await n(e,t)).data.statusUrl;for(;;){let e=(await n(r,{query:{f:`json`},responseType:`json`})).data;switch(e.status){case`Completed`:return n(e.resultUrl,{query:{f:`json`},responseType:`json`});case`CompletedWithErrors`:throw new a(`async-applyEdits-failed`,`asynchronous applyEdits call failed.`);case`Failed ImportChanges`:case`InProgress`:case`Pending`:case`ExportAttachments`:case`ExportChanges`:case`ExportingData`:case`ExportingSnapshot`:case`ImportAttachments`:case`ProvisioningReplica`:case`UnRegisteringReplica`:break;default:throw new a(`async-applyEdits-failed`,`asynchronous applyEdits call failed (undefined response status)`)}await d(K)}}_createRequestQueryOptions(e){let t={...this.layer.customParameters,token:this.layer.apiKey,...e?.query};return this.layer.datesInUnknownTimezone&&(t.timeReferenceUnknownClient=!0),t}async _fetchService(e,t){if(!e){let r={};has(`featurelayer-advanced-symbols`)&&(r.returnAdvancedSymbols=!0),t?.cacheBust&&(r._ts=Date.now());let{data:i}=await n(this.layer.parsedUrl.path,this._getLayerRequestOptions({query:r,signal:t?.signal}));e=i}this.layer.applyPreferredHost(e),this.sourceJSON=await this._patchServiceJSON(e,t?.signal);let r=e.type;if(!this.supportedSourceTypes.has(r))throw new a(`feature-layer-source:unsupported-type`,`Source type "${r}" is not supported`)}async _patchServiceJSON(e,t){if(e.type!==`Table`&&e.geometryType&&!e?.drawingInfo?.renderer&&!e.defaultSymbol){let t=A(e.geometryType).renderer;l(`drawingInfo.renderer`,t,e)}if(e.geometryType===`esriGeometryMultiPatch`&&e.infoFor3D&&(e.geometryType=`mesh`),e.extent==null)try{let{data:r}=await n(this.layer.url,this._getLayerRequestOptions({signal:t}));r.spatialReference&&(e.extent={xmin:0,ymin:0,xmax:0,ymax:0,spatialReference:r.spatialReference})}catch(e){f(e)}return e}async _ensureLatestMetadata(e){if(this.layer.userHasUpdateItemPrivileges&&this.sourceJSON.cacheMaxAge>0)return this._fetchService(null,{...e,cacheBust:!0})}async _uploadMeshesAndGetAssetMapEditsJSON(e){let{addAssetFeatures:t}=e;if(!t?.length||await this._areAllAssetsAlreadyMapped(t))return null;let n=e.addFeatures.filter(e=>e.geometry);if(t.length!==n.length+e.updateFeatures.length)throw new a(`feature-layer-source:unsupported-mesh-edits`,`Mixing attribute only edits with mesh geometry edits is not currently supported`);let r=[],i=new Map;for(let e of t){let{geometry:t}=e,{vertexSpace:n}=t;if(x(n))r.push(t);else{let n=t.origin,{convertMeshVertexSpace:a}=await import(`../../../geometry/support/meshUtils/convertMeshVertexSpace.js`),o=await a(t,new b({origin:[n.x,n.y,n.z??0]}));i.set(o,t),e.geometry=o,r.push(o)}}await this.uploadAssets(r);for(let[e,t]of i)t.addExternalSources(e.metadata.externalSources.items);return{adds:this._getAssetMapEditsJSON(t),updates:[],deletes:[]}}_getAssetMapEditsJSON(e){let t=[],n=this.layer.globalIdField,r=this.layer.parsedUrl;for(let i of e){let{metadata:e}=i.geometry,a=e.getExternalSourcesOnService(r),o=i.getAttribute(n);if(a.length===0){c.getLogger(this).error(`Skipping feature ${o}. The mesh it is associated with has not been uploaded to the service and cannot be mapped to it.`);continue}let{source:s}=a.find(S)??a[0];for(let e of s.assets){if(e.parts.length!==1){c.getLogger(this).error(`Skipping asset ${e.assetName}. It does not have exactly one part, so we cannot map it to a feature.`);continue}t.push({globalId:h(),parentGlobalId:o,assetName:e.assetName,assetHash:e.parts[0].partHash,flags:[]})}}return t}_createEditsResult(e){let t=e.data,{layerId:n}=this.layer,r=[],i=null;if(Array.isArray(t))for(let e of t)e.editedFeatures!=null&&r.push({id:e.id,editedFeatures:e.editedFeatures}),e.id===n&&(i={addResults:e.addResults??[],updateResults:e.updateResults??[],deleteResults:e.deleteResults??[],attachments:e.attachments,editMoment:e.editMoment});else i=t;let a=O(i);if(r.length>0){a.editedFeatureResults=[];for(let e of r){let{editedFeatures:t}=e,n=t?.spatialReference?new y(t.spatialReference):null;a.editedFeatureResults.push({layerId:e.id,editedFeatures:k(t,n)})}}return a}_createAttachmentErrorResult(e,t){let n=t.details.messages?.[0]||t.message,r=t.details.httpStatus||t.details.messageCode;return{objectId:e,globalId:null,error:new a(`feature-layer-source:attachment-failure`,n,{code:r})}}_getFormDataForAttachment(e,t){let n=e instanceof FormData?e:e&&e.elements?new FormData(e):null;if(n)for(let e in t){let r=t[e];r!=null&&(n.set?n.set(e,r):n.append(e,r))}return n}_getLayerRequestOptions(e={}){let{layer:t,layer:{parsedUrl:n,gdbVersion:r}}=this;return{...e,query:{gdbVersion:r,layer:`dynamicDataSource`in t&&t.dynamicDataSource?JSON.stringify({source:t.dynamicDataSource}):void 0,...n.query,f:`json`,...this._createRequestQueryOptions(e)},responseType:`json`}}async _areAllAssetsAlreadyMapped(e){let{layer:t}=this,{globalIdField:n,parsedUrl:i}=t,a=`infoFor3D`in t?t.infoFor3D:null;if(a==null||n==null)return!1;let o=P(a);if(o==null)return!1;let s=m(i.path,`../${o.id}`),c=[];for(let t of e)if(t.geometry.metadata.getExternalSourcesOnService(i).length>0)c.push(t);else return!1;let l=c.map(e=>e.getAttribute(n)).filter(r);if(l.length===0)return!1;let{assetMapFieldRoles:{parentGlobalId:u,assetHash:d}}=a,f=new L({where:`${u} IN (${l.map(e=>`'${e}'`)})`,outFields:[d,u],returnGeometry:!1}),{features:p}=await F(s,f);return p.length!==0&&!c.some(e=>{let t=e.getAttribute(n);if(!t)return!0;let{metadata:r}=e.geometry,a=p.filter(e=>e.getAttribute(u)===t);if(a.length===0)return!0;let o=a.map(e=>e.getAttribute(d));return r.getExternalSourcesOnService(i).flatMap(({source:e})=>e.assets.flatMap(e=>e.parts.map(e=>e.partHash))).some(e=>o.every(t=>e!==t))})}};e([g()],G.prototype,`type`,void 0),e([g({constructOnly:!0})],G.prototype,`layer`,void 0),e([g({constructOnly:!0})],G.prototype,`supportedSourceTypes`,void 0),e([g({readOnly:!0})],G.prototype,`queryTask`,null),G=e([_(`esri.layers.graphics.sources.FeatureLayerSource`)],G);const K=1e3;export{G as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../config.js";import n from"../../../request.js";import{isSome as r,remove as i}from"../../../core/arrayUtils.js";import a from"../../../core/Error.js";import has from"../../../core/has.js";import{JSONMap as o}from"../../../core/jsonMap.js";import{Loadable as s}from"../../../core/Loadable.js";import c from"../../../core/Logger.js";import{setDeepValue as l}from"../../../core/object.js";import{debounce as u,after as d,throwIfAbortError as f}from"../../../core/promiseUtils.js";import{watch as p}from"../../../core/reactiveUtils.js";import{join as m}from"../../../core/urlUtils.js";import{generateBracedUUID as h}from"../../../core/uuid.js";import{property as g,subclass as _}from"../../../core/accessorSupport/decorators.js";import v from"../../../geometry/Extent.js";import y from"../../../geometry/SpatialReference.js";import b from"../../../geometry/support/MeshGeoreferencedVertexSpace.js";import{isRelativeVertexSpace as x}from"../../../geometry/support/meshVertexSpaceUtils.js";import{isOriginalExternal as S}from"../../../geometry/support/meshUtils/External.js";import{createFeatureEditResult as C,getFeatureJSON as w,getFeatureIds as T,getAttachmentEditsJSON as E,isProtectedOrPrivateVersionError as D,unpackEditResultData as O,createEditedFeatures as k}from"../applyEditsUtils.js";import{createDrawingInfo as A}from"./support/clientSideDefaults.js";import j from"./support/QueryTask.js";import{isHostedAgolService as M}from"../../support/arcgisLayerUrl.js";import{ensureLayerCredential as N}from"../../support/featureLayerUtils.js";import{getAssetMapTable as P}from"../../support/infoFor3D.js";import F from"../../support/TimeInformation.js";import{executeQueryJSON as I}from"../../../rest/query/executeQueryJSON.js";import{unapplyEditsZUnitScaling as L}from"../../../rest/query/operations/editsZScale.js";import R from"../../../rest/support/Query.js";import z from"../../../time/TimeExtent.js";import{isSafeToEditVersion as B,isVersionInEditSession as V,isHistoricVersion as H,currentSessionId as U}from"../../../versionManagement/support/versionManagementUtils.js";const W=new o({originalAndCurrentFeatures:`original-and-current-features`,none:`none`}),G=new o({Started:`published`,Publishing:`publishing`,Stopped:`unavailable`});let K=class extends s{constructor(e){super(e),this.type=`feature-layer`,this.supportedSourceTypes=new Set([`Feature Layer`,`Oriented Imagery Layer`,`Table`,`Catalog Layer`,`Annotation Layer`,`Dimension Layer`]),this.refresh=u(async()=>{await this.load();let e=this.sourceJSON.editingInfo?.lastEditDate;if(e==null)return{dataChanged:!0,updates:{}};try{await this._fetchService(null)}catch{return{dataChanged:!0,updates:{}}}let t=e!==this.sourceJSON.editingInfo?.lastEditDate;return{dataChanged:t,updates:t?{editingInfo:this.sourceJSON.editingInfo,extent:this.sourceJSON.extent}:null}}),this._ongoingAssetUploads=new Map}load(e){let t=this.layer.sourceJSON,n=this._fetchService(t,{...e}).then(()=>this.layer.setUserPrivileges(this.sourceJSON.serviceItemId,e)).then(()=>this._ensureLatestMetadata(e));return this.addResolvingPromise(n),Promise.resolve(this)}async reload(e){let t=this.layer.userHasUpdateItemPrivileges&&this.sourceJSON.cacheMaxAge>0;await this._fetchService(null,{...e,cacheBust:t})}initialize(){this.addHandles([p(()=>{let e=this.layer;return e&&`lastEditsEventDate`in e?e.lastEditsEventDate:null},e=>this._handleLastEditsEventChange(e))])}destroy(){this._removeEditInterceptor()}get queryTask(){let{layer:e}=this,{capabilities:t,parsedUrl:n,gdbVersion:r,spatialReference:i,fieldsIndex:a,uniqueIdFields:o}=e,s=`infoFor3D`in e?e.infoFor3D:null,c=`dynamicDataSource`in e?e.dynamicDataSource:null,l=has(`featurelayer-pbf`)&&t?.query.supportsFormatPBF&&s==null,u=l&&t?.query.supportsFormatPBFWithCurves,d=t?.operations?.supportsQueryAttachments??!1,f=t?.query?.relativeTimeBinWindow??0,p=new F({fieldsIndex:a,layer:e}),m=n.path;return new j({dynamicDataSource:c,fieldsIndex:a,gdbVersion:r,infoFor3D:s,pbfSupported:l,pbfSupportedWithCurves:u,queryAttachmentsSupported:d,relativeTimeBinWindow:f,sourceSpatialReference:i,timeInformation:p,uniqueIdFields:o,url:m})}async addAttachment(e,t,r){await this.load();let{layer:i}=this;await N(i,`editing`);let a=e.attributes[i.objectIdField],o=i.parsedUrl.path+`/`+a+`/addAttachment`,s=this._getLayerRequestOptions({query:r}),c=this._getFormDataForAttachment(t,s.query);try{let e=await n(o,{body:c});return C(e.data.addAttachmentResult)}catch(e){throw this._createAttachmentErrorResult(a,e)}}async updateAttachment(e,t,r,i){await this.load();let{layer:a}=this;await N(a,`editing`);let o=e.attributes[a.objectIdField],s=a.parsedUrl.path+`/`+o+`/updateAttachment`,c=this._getLayerRequestOptions({query:{attachmentId:t,...i}}),l=this._getFormDataForAttachment(r,c.query);try{let e=await n(s,{body:l});return C(e.data.updateAttachmentResult)}catch(e){throw this._createAttachmentErrorResult(o,e)}}async applyEdits(e,t){await this.load();let{layer:i}=this;await N(i,`editing`);let o=`infoFor3D`in i?i.infoFor3D:null,s=o!=null,c=s||(t?.globalIdUsed??!1),l=s?await this._uploadMeshesAndGetAssetMapEditsJSON(e):null,u=e.addFeatures?.map(e=>w(this.layer,e,o))??[],d=(await Promise.all(u)).filter(r),f=e.updateFeatures?.map(e=>w(this.layer,e,o))??[],p=(await Promise.all(f)).filter(r),m=T(this.layer,e.deleteFeatures,c);L(d,p,i.spatialReference);let h=await E(this.layer,e),g=i.capabilities.editing.supportsAsyncApplyEdits&&s,_=t?.gdbVersion||i.gdbVersion,v={gdbVersion:_,rollbackOnFailure:t?.rollbackOnFailureEnabled,useGlobalIds:c,returnEditMoment:t?.returnEditMoment,trueCurveClient:t?.editsRespectTrueCurves,usePreviousEditMoment:t?.usePreviousEditMoment,async:g};await B(this.layer.url,_,!0);let y=V(this.layer.url,_||null);if(await H(i.url,_,i.historicMoment))throw new a(`feature-layer-source:historic-version`,`Editing a historic version is not allowed`);t?.returnServiceEditsOption?(v.edits=JSON.stringify([{id:i.layerId,adds:d.length?d:null,updates:p.length?p:null,deletes:m.length?m:null,attachments:h,assetMaps:l}]),v.returnServiceEditsOption=W.toJSON(t?.returnServiceEditsOption),v.returnServiceEditsInSourceSR=t?.returnServiceEditsInSourceSR):(v.adds=d.length?JSON.stringify(d):null,v.updates=p.length?JSON.stringify(p):null,v.deletes=m.length?c?JSON.stringify(m):m.join(`,`):null,v.attachments=h&&JSON.stringify(h),v.assetMaps=l==null?void 0:JSON.stringify(l));let b=this._getLayerRequestOptions({method:`post`,query:v});y&&(b.authMode=`immediate`,b.query.returnEditMoment=!0,b.query.sessionId=U);let x=t?.returnServiceEditsOption?i.url:i.parsedUrl.path,S;try{S=g?await this._asyncApplyEdits(x+`/applyEdits`,b):await n(x+`/applyEdits`,b)}catch(e){if(D(e))b.authMode=`immediate`,S=g?await this._asyncApplyEdits(x+`/applyEdits`,b):await n(x+`/applyEdits`,b);else throw e}return this._createEditsResult(S)}async deleteAttachments(e,t,r){await this.load();let{layer:i}=this;await N(i,`editing`);let a=e.attributes[i.objectIdField],o=i.parsedUrl.path+`/`+a+`/deleteAttachments`;try{return(await n(o,this._getLayerRequestOptions({query:{attachmentIds:t.join(`,`),...r},method:`post`}))).data.deleteAttachmentResults.map(C)}catch(e){throw this._createAttachmentErrorResult(a,e)}}fetchRecomputedExtents(e={}){let t=e.signal;return this.load({signal:t}).then(async()=>{let t=this._getLayerRequestOptions({...e,query:{returnUpdates:!0}}),{layerId:r,url:i}=this.layer,{data:a}=await n(`${i}/${r}`,t),{id:o,extent:s,fullExtent:c,timeExtent:l}=a,u=s||c;return{id:o,fullExtent:u&&v.fromJSON(u),timeExtent:l&&z.fromJSON({start:l[0],end:l[1]})}})}async queryAttachments(e,t={}){await this.load();let n=this._getLayerRequestOptions(t);return this.queryTask.executeAttachmentQuery(e,n)}async queryFeatures(e,t){await this.load();let n=await this.queryTask.execute(e,{...t,query:this._createRequestQueryOptions(t)});if(e.outStatistics?.length&&n.features.length){let t=new Map;if(n.features.forEach(n=>{let r=n.attributes;e.outStatistics?.forEach(({outStatisticFieldName:e})=>{if(e){let n=e.toLowerCase();n&&n in r&&e!==n&&(r[e]=r[n],delete r[n],t.set(n,e))}})}),n.fields!=null)for(let e of n.fields){let n=t.get(e.name.toLowerCase());n!=null&&(e.name=n)}}return n}async queryFeaturesJSON(e,t){return await this.load(),this.queryTask.executeJSON(e,{...t,query:this._createRequestQueryOptions(t)})}async queryObjectIds(e,t){return await this.load(),this.queryTask.executeForIds(e,{...t,query:this._createRequestQueryOptions(t)})}async queryFeatureCount(e,t){return await this.load(),this.queryTask.executeForCount(e,{...t,query:this._createRequestQueryOptions(t)})}async queryExtent(e,t){return await this.load(),this.queryTask.executeForExtent(e,{...t,query:this._createRequestQueryOptions(t)})}async queryRelatedFeatures(e,t){return await this.load(),this.queryTask.executeRelationshipQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryRelatedFeaturesCount(e,t){return await this.load(),this.queryTask.executeRelationshipQueryForCount(e,{...t,query:this._createRequestQueryOptions(t)})}async queryPivot(e,t){return await this.load(),this.queryTask.executePivotQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopFeatures(e,t){return await this.load(),this.queryTask.executeTopFeaturesQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryAttributeBins(e,t){return await this.load(),this.queryTask.executeAttributeBinsQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopObjectIds(e,t){return await this.load(),this.queryTask.executeForTopIds(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopExtents(e,t){return await this.load(),this.queryTask.executeForTopExtents(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopCount(e,t){return await this.load(),this.queryTask.executeForTopCount(e,{...t,query:this._createRequestQueryOptions(t)})}async fetchPublishingStatus(){if(!M(this.layer.url))return`unavailable`;let e=m(this.layer.url,`status`),t=await n(e,{query:{f:`json`}});return G.fromJSON(t.data.status)}async uploadAssets(e,t){let{uploadAssets:n}=await import(`./support/uploadAssets.js`);return n(e,{layer:this.layer,ongoingUploads:this._ongoingAssetUploads},t)}_handleLastEditsEventChange(e){let t=this.layer;if(e==null||!(`capabilities`in t)||!(`effectiveCapabilities`in t)||t.capabilities?.operations?.supportsEditing||!t.effectiveCapabilities?.operations?.supportsEditing)return;let n=t.url;if(n==null)return;`layerId`in t&&(n=m(n,t.layerId.toString()));let r=this._getOrCreateEditInterceptor(n);r.before=t=>{let n=t.requestOptions.method??`auto`;if(n===`auto`||n===`head`){let n=t.requestOptions.query??{};n._ts=e.getTime(),t.requestOptions.query=n}}}_getOrCreateEditInterceptor(e){return this._editInterceptor??(this._editInterceptor={urls:e},t.request.internalInterceptors.push(this._editInterceptor)),this._editInterceptor}_removeEditInterceptor(){this._editInterceptor!=null&&(i(t.request.internalInterceptors,this._editInterceptor),this._editInterceptor=null)}async _asyncApplyEdits(e,t){let r=(await n(e,t)).data.statusUrl;for(;;){let e=(await n(r,{query:{f:`json`},responseType:`json`})).data;switch(e.status){case`Completed`:return n(e.resultUrl,{query:{f:`json`},responseType:`json`});case`CompletedWithErrors`:throw new a(`async-applyEdits-failed`,`asynchronous applyEdits call failed.`);case`Failed ImportChanges`:case`InProgress`:case`Pending`:case`ExportAttachments`:case`ExportChanges`:case`ExportingData`:case`ExportingSnapshot`:case`ImportAttachments`:case`ProvisioningReplica`:case`UnRegisteringReplica`:break;default:throw new a(`async-applyEdits-failed`,`asynchronous applyEdits call failed (undefined response status)`)}await d(q)}}_createRequestQueryOptions(e){let t={...this.layer.customParameters,token:this.layer.apiKey,...e?.query};return this.layer.datesInUnknownTimezone&&(t.timeReferenceUnknownClient=!0),t}async _fetchService(e,t){if(!e){let r={};has(`featurelayer-advanced-symbols`)&&(r.returnAdvancedSymbols=!0),t?.cacheBust&&(r._ts=Date.now());let{data:i}=await n(this.layer.parsedUrl.path,this._getLayerRequestOptions({query:r,signal:t?.signal}));e=i}this.layer.applyPreferredHost(e),this.sourceJSON=await this._patchServiceJSON(e,t?.signal);let r=e.type;if(!this.supportedSourceTypes.has(r))throw new a(`feature-layer-source:unsupported-type`,`Source type "${r}" is not supported`)}async _patchServiceJSON(e,t){if(e.type!==`Table`&&e.geometryType&&!e?.drawingInfo?.renderer&&!e.defaultSymbol){let t=A(e.geometryType).renderer;l(`drawingInfo.renderer`,t,e)}if(e.geometryType===`esriGeometryMultiPatch`&&e.infoFor3D&&(e.geometryType=`mesh`),e.extent==null)try{let{data:r}=await n(this.layer.url,this._getLayerRequestOptions({signal:t}));r.spatialReference&&(e.extent={xmin:0,ymin:0,xmax:0,ymax:0,spatialReference:r.spatialReference})}catch(e){f(e)}return e}async _ensureLatestMetadata(e){if(this.layer.userHasUpdateItemPrivileges&&this.sourceJSON.cacheMaxAge>0)return this._fetchService(null,{...e,cacheBust:!0})}async _uploadMeshesAndGetAssetMapEditsJSON(e){let{addAssetFeatures:t}=e;if(!t?.length||await this._areAllAssetsAlreadyMapped(t))return null;let n=e.addFeatures.filter(e=>e.geometry);if(t.length!==n.length+e.updateFeatures.length)throw new a(`feature-layer-source:unsupported-mesh-edits`,`Mixing attribute only edits with mesh geometry edits is not currently supported`);let r=[],i=new Map;for(let e of t){let{geometry:t}=e,{vertexSpace:n}=t;if(x(n))r.push(t);else{let n=t.origin,{convertMeshVertexSpace:a}=await import(`../../../geometry/support/meshUtils/convertMeshVertexSpace.js`),o=await a(t,new b({origin:[n.x,n.y,n.z??0]}));i.set(o,t),e.geometry=o,r.push(o)}}await this.uploadAssets(r);for(let[e,t]of i)t.addExternalSources(e.metadata.externalSources.items);return{adds:this._getAssetMapEditsJSON(t),updates:[],deletes:[]}}_getAssetMapEditsJSON(e){let t=[],n=this.layer.globalIdField,r=this.layer.parsedUrl;for(let i of e){let{metadata:e}=i.geometry,a=e.getExternalSourcesOnService(r),o=i.getAttribute(n);if(a.length===0){c.getLogger(this).error(`Skipping feature ${o}. The mesh it is associated with has not been uploaded to the service and cannot be mapped to it.`);continue}let{source:s}=a.find(S)??a[0];for(let e of s.assets){if(e.parts.length!==1){c.getLogger(this).error(`Skipping asset ${e.assetName}. It does not have exactly one part, so we cannot map it to a feature.`);continue}t.push({globalId:h(),parentGlobalId:o,assetName:e.assetName,assetHash:e.parts[0].partHash,flags:[]})}}return t}_createEditsResult(e){let t=e.data,{layerId:n}=this.layer,r=[],i=null;if(Array.isArray(t))for(let e of t)e.editedFeatures!=null&&r.push({id:e.id,editedFeatures:e.editedFeatures}),e.id===n&&(i={addResults:e.addResults??[],updateResults:e.updateResults??[],deleteResults:e.deleteResults??[],attachments:e.attachments,editMoment:e.editMoment});else i=t;let a=O(i);if(r.length>0){a.editedFeatureResults=[];for(let e of r){let{editedFeatures:t}=e,n=t?.spatialReference?new y(t.spatialReference):null;a.editedFeatureResults.push({layerId:e.id,editedFeatures:k(t,n)})}}return a}_createAttachmentErrorResult(e,t){let n=t.details.messages?.[0]||t.message,r=t.details.httpStatus||t.details.messageCode;return{objectId:e,globalId:null,error:new a(`feature-layer-source:attachment-failure`,n,{code:r})}}_getFormDataForAttachment(e,t){let n=e instanceof FormData?e:e&&e.elements?new FormData(e):null;if(n)for(let e in t){let r=t[e];r!=null&&(n.set?n.set(e,r):n.append(e,r))}return n}_getLayerRequestOptions(e={}){let{layer:t,layer:{parsedUrl:n,gdbVersion:r}}=this;return{...e,query:{gdbVersion:r,layer:`dynamicDataSource`in t&&t.dynamicDataSource?JSON.stringify(t.dynamicDataSource.toLayerSourceJSON()):void 0,...n.query,f:`json`,...this._createRequestQueryOptions(e)},responseType:`json`}}async _areAllAssetsAlreadyMapped(e){let{layer:t}=this,{globalIdField:n,parsedUrl:i}=t,a=`infoFor3D`in t?t.infoFor3D:null;if(a==null||n==null)return!1;let o=P(a);if(o==null)return!1;let s=m(i.path,`../${o.id}`),c=[];for(let t of e)if(t.geometry.metadata.getExternalSourcesOnService(i).length>0)c.push(t);else return!1;let l=c.map(e=>e.getAttribute(n)).filter(r);if(l.length===0)return!1;let{assetMapFieldRoles:{parentGlobalId:u,assetHash:d}}=a,f=new R({where:`${u} IN (${l.map(e=>`'${e}'`)})`,outFields:[d,u],returnGeometry:!1}),{features:p}=await I(s,f);return p.length!==0&&!c.some(e=>{let t=e.getAttribute(n);if(!t)return!0;let{metadata:r}=e.geometry,a=p.filter(e=>e.getAttribute(u)===t);if(a.length===0)return!0;let o=a.map(e=>e.getAttribute(d));return r.getExternalSourcesOnService(i).flatMap(({source:e})=>e.assets.flatMap(e=>e.parts.map(e=>e.partHash))).some(e=>o.every(t=>e!==t))})}};e([g()],K.prototype,`type`,void 0),e([g({constructOnly:!0})],K.prototype,`layer`,void 0),e([g({constructOnly:!0})],K.prototype,`supportedSourceTypes`,void 0),e([g({readOnly:!0})],K.prototype,`queryTask`,null),K=e([_(`esri.layers.graphics.sources.FeatureLayerSource`)],K);const q=1e3;export{K as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import n from"../../../../core/Error.js";import has from"../../../../core/has.js";import{whenOrAbort as r}from"../../../../core/promiseUtils.js";import{urlToObject as i}from"../../../../core/urlUtils.js";import{property as a,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{equals as s}from"../../../../geometry/support/spatialReferenceUtils.js";import{getGltfQueryFormat as c}from"../../../support/infoFor3D.js";import{parseUrl as l}from"../../../../rest/utils.js";import u
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import n from"../../../../core/Error.js";import has from"../../../../core/has.js";import{whenOrAbort as r}from"../../../../core/promiseUtils.js";import{urlToObject as i}from"../../../../core/urlUtils.js";import{property as a,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{equals as s}from"../../../../geometry/support/spatialReferenceUtils.js";import{getGltfQueryFormat as c}from"../../../support/infoFor3D.js";import{parseUrl as l}from"../../../../rest/utils.js";import{dynamicDataSourceTypes as u}from"../../../../rest/layerSources/typeUtils.js";import{executeForCount as d}from"../../../../rest/query/executeForCount.js";import{executeForExtent as f}from"../../../../rest/query/executeForExtent.js";import{executeForIds as p}from"../../../../rest/query/executeForIds.js";import{executeRawQueryJSON as m}from"../../../../rest/query/executeQueryJSON.js";import{executeRawQueryPBF as h}from"../../../../rest/query/executeQueryPBF.js";import g from"../../../../rest/support/FeatureSet.js";import _ from"../../../../rest/support/Query.js";let v=class extends t{constructor(e){super(e),this.dynamicDataSource=null,this.fieldsIndex=null,this.gdbVersion=null,this.infoFor3D=null,this.pbfSupported=!1,this.pbfSupportedWithCurves=!1,this.queryAttachmentsSupported=!1,this.relativeTimeBinWindow=0,this.sourceSpatialReference=null,this.timeInformation=null,this.uniqueIdFields=null,this.url=null}get parsedUrl(){return i(this.url)}async execute(e,t){let n=await this.executeJSON(e,t);return this.featureSetFromJSON(e,n,t)}async executeJSON(e,t){let n=this._normalizeQuery(e),r=e.outStatistics?.[0]!=null,i=has(`featurelayer-pbf-statistics`),a=this.pbfSupported&&(!r||i)&&(!e.returnTrueCurves||this.pbfSupportedWithCurves),o;if(a)try{o=await h(this.url,n,t,{timeInformation:this.timeInformation,uniqueIdFields:this.uniqueIdFields})}catch(e){if(e.name===`query:parsing-pbf`)this.pbfSupported=!1;else throw e}return o??=await m(this.url,n,t,{timeInformation:this.timeInformation,uniqueIdFields:this.uniqueIdFields}),this._normalizeFields(o.fields),o}async featureSetFromJSON(e,t,n){if(!this._queryGet3DObjectFormat(e)||this.infoFor3D==null||!t.features)return g.fromJSON(t);let{meshFeatureSetFromJSON:i}=await r(import(`../../../../rest/support/meshFeatureSet.js`),n);return i(e,this.infoFor3D,t)}executeForCount(e,t){return d(this.url,this._normalizeQuery(e),t,{timeInformation:this.timeInformation,uniqueIdFields:this.uniqueIdFields})}executeForExtent(e,t){return f(this.url,this._normalizeQuery(e),t)}executeForIds(e,t){return p(this.url,this._normalizeQuery(e),t,{timeInformation:this.timeInformation,uniqueIdFields:this.uniqueIdFields})}async executeRelationshipQuery(e,t){let[{default:n},{executeRelationshipQuery:i}]=await r(Promise.all([import(`../../../../rest/support/RelationshipQuery.js`),import(`../../../../rest/query/executeRelationshipQuery.js`)]),t),a=n.from(e);return(this.gdbVersion||this.dynamicDataSource)&&(a=a.clone(),a.gdbVersion=a.gdbVersion||this.gdbVersion,a.dynamicDataSource=a.dynamicDataSource||this.dynamicDataSource),i(this.url,a,t)}async executeRelationshipQueryForCount(e,t){let[{default:n},{executeRelationshipQueryForCount:i}]=await r(Promise.all([import(`../../../../rest/support/RelationshipQuery.js`),import(`../../../../rest/query/executeRelationshipQuery.js`)]),t),a=n.from(e);return(this.gdbVersion||this.dynamicDataSource)&&(a=a.clone(),a.gdbVersion=a.gdbVersion||this.gdbVersion,a.dynamicDataSource=a.dynamicDataSource||this.dynamicDataSource),i(this.url,a,t)}async executeAttachmentQuery(e,t){let{executeAttachmentQuery:n,fetchAttachments:i,processAttachmentQueryResult:a}=await r(import(`../../../../rest/query/operations/queryAttachments.js`),t),o=l(this.url);return a(o,await(this.queryAttachmentsSupported?n(o,e,t):i(o,e,t)))}async executeAttributeBinsQuery(e,t){let{executeAttributeBinsQuery:n}=await r(import(`../../../../rest/query/executeAttributeBinsQuery.js`),t);return n(this.parsedUrl,e,t)}async executePivotQuery(e,t){let{executePivotQuery:n}=await r(import(`../../../../rest/query/executePivotQuery.js`),t);return n(this.parsedUrl,e,t)}async executeTopFeaturesQuery(e,t){let{executeTopFeaturesQuery:n}=await r(import(`../../../../rest/query/executeTopFeaturesQuery.js`),t);return n(this.parsedUrl,e,this.sourceSpatialReference,t)}async executeForTopIds(e,t){let{executeForTopIds:n}=await r(import(`../../../../rest/query/executeForTopIds.js`),t);return n(this.parsedUrl,e,t)}async executeForTopExtents(e,t){let{executeForTopExtents:n}=await r(import(`../../../../rest/query/executeForTopExtents.js`),t);return n(this.parsedUrl,e,t)}async executeForTopCount(e,t){let{executeForTopCount:n}=await r(import(`../../../../rest/query/executeForTopCount.js`),t);return n(this.parsedUrl,e,t)}_normalizeQuery(e){let t=_.from(e);t.sourceSpatialReference=t.sourceSpatialReference||this.sourceSpatialReference,(this.gdbVersion||this.dynamicDataSource)&&(t=t===e?t.clone():t,t.gdbVersion=e.gdbVersion||this.gdbVersion,t.dynamicDataSource=e.dynamicDataSource||this.dynamicDataSource);let{infoFor3D:r}=this,i=this._queryGet3DObjectFormat(e);if(r!=null&&i){if(t=t===e?t.clone():t,t.formatOf3DObjects=i,t.outSpatialReference&&!s(t.outSpatialReference,this.sourceSpatialReference))throw new n(`query:unsupported-out-spatial-reference`,`3D object feature services do not support projection of geometries`);if(t.outFields==null||!t.outFields.includes(`*`)){t=t===e?t.clone():t,t.outFields??(t.outFields=[]);let{originX:n,originY:i,originZ:a,translationX:o,translationY:s,translationZ:c,scaleX:l,scaleY:u,scaleZ:d,rotationX:f,rotationY:p,rotationZ:m,rotationDeg:h}=r.transformFieldRoles;t.outFields.push(n,i,a,o,s,c,l,u,d,f,p,m,h)}}return t}_normalizeFields(e){if(this.fieldsIndex!=null&&e!=null)for(let t of e){let e=this.fieldsIndex.get(t.name);e&&Object.assign(t,e.toJSON())}}_queryGet3DObjectFormat({returnGeometry:e,multipatchOption:t,outStatistics:n}){return e===!0&&t!==`xyFootprint`&&!n?c(this.infoFor3D):null}};e([a({types:u})],v.prototype,`dynamicDataSource`,void 0),e([a()],v.prototype,`fieldsIndex`,void 0),e([a()],v.prototype,`gdbVersion`,void 0),e([a()],v.prototype,`infoFor3D`,void 0),e([a({readOnly:!0})],v.prototype,`parsedUrl`,null),e([a()],v.prototype,`pbfSupported`,void 0),e([a()],v.prototype,`pbfSupportedWithCurves`,void 0),e([a()],v.prototype,`queryAttachmentsSupported`,void 0),e([a()],v.prototype,`relativeTimeBinWindow`,void 0),e([a()],v.prototype,`sourceSpatialReference`,void 0),e([a()],v.prototype,`timeInformation`,void 0),e([a()],v.prototype,`uniqueIdFields`,void 0),e([a({type:String})],v.prototype,`url`,void 0),v=e([o(`esri.layers.graphics.sources.support.QueryTask`)],v);export{v as default};
|