// // Copyright 2020 FoxyUtils ehf. All rights reserved. // // This is a commercial product and requires a license to operate. // A trial license can be obtained at https://unidoc.io // // DO NOT EDIT: generated by unitwist Go source code obfuscator. // // Use of this source code is governed by the UniDoc End User License Agreement // terms that can be accessed at https://unidoc.io/eula/ package jbig2 ;import (_d "github.com/unidoc/unipdf/v3/internal/bitwise";_c "github.com/unidoc/unipdf/v3/internal/jbig2/decoder";_ga "github.com/unidoc/unipdf/v3/internal/jbig2/document";_g "github.com/unidoc/unipdf/v3/internal/jbig2/document/segments"; _ea "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_df "sort";);func DecodeGlobals (encoded []byte )(Globals ,error ){const _ce ="\u0044\u0065\u0063\u006f\u0064\u0065\u0047\u006c\u006f\u0062\u0061\u006c\u0073";_cf :=_d .NewReader (encoded );_eb ,_a :=_ga .DecodeDocument (_cf ,nil ); if _a !=nil {return nil ,_ea .Wrap (_a ,_ce ,"");};if _eb .GlobalSegments ==nil ||(_eb .GlobalSegments .Segments ==nil ){return nil ,_ea .Error (_ce ,"\u006eo\u0020\u0067\u006c\u006f\u0062\u0061\u006c\u0020\u0073\u0065\u0067m\u0065\u006e\u0074\u0073\u0020\u0066\u006f\u0075\u006e\u0064"); };_ac :=Globals {};for _ ,_b :=range _eb .GlobalSegments .Segments {_ac [int (_b .SegmentNumber )]=_b ;};return _ac ,nil ;};func DecodeBytes (encoded []byte ,parameters _c .Parameters ,globals ...Globals )([]byte ,error ){var _ef Globals ;if len (globals )> 0{_ef =globals [0]; };_f ,_dd :=_c .Decode (encoded ,parameters ,_ef .ToDocumentGlobals ());if _dd !=nil {return nil ,_dd ;};return _f .DecodeNextPage ();};func (_ab Globals )ToDocumentGlobals ()*_ga .Globals {if _ab ==nil {return nil ;};_gag :=[]*_g .Header {};for _ ,_ceg :=range _ab {_gag =append (_gag ,_ceg ); };_df .Slice (_gag ,func (_af ,_cd int )bool {return _gag [_af ].SegmentNumber < _gag [_cd ].SegmentNumber });return &_ga .Globals {Segments :_gag };};type Globals map[int ]*_g .Header ;